Commit graph

7206 commits

Author SHA1 Message Date
David Given
efab08178b Fix a bunch of issues with pushing and popping mismatched sizes, which the B
compiler does a lot; dup 8 for pairs of words is now optimised.
2017-01-07 18:47:00 +01:00
David Given
5a38ce2a69 Pre-and-post-modification operators now work substantially better (i.e.,
working).
2017-01-07 18:46:03 +01:00
David Given
39215c131e Moved the inc/dec operator tests into their own source file; more exhaustive
testing.
2017-01-07 18:38:43 +01:00
David Given
6b4f8d72b8 ine and ste are now declared to modify memory (preventing cached values being
propagated across the modification).
2017-01-07 13:25:09 +01:00
David Given
7710c76d56 Introduce sequence points before store instructions to prevent loads from the
same address being delayed until after the store (at which point they'll return
the wrong value).
2017-01-07 13:17:39 +01:00
David Given
0da248dced Use a better NOT; and after remembering that PowerPC bit numbers are all
backwards in the documentation, rewrote IFEQ/IFLT/IFLE to actually work.
Probably. Thanks to the B test suite for spotting this.
2017-01-07 01:03:15 +01:00
David Given
77fc62285d Extern variables can now be written to. 2017-01-06 23:24:05 +01:00
David Given
73922f1d16 Ensure that procedure labels are word-aligned. 2017-01-06 22:29:52 +01:00
David Given
72766a02de Fix typo in the descr file which was stopping -B from working. Add B
documentation to the ack man page.
2017-01-04 13:28:40 +00:00
David Given
aeb9d4952d Added an abmodules tool which detects B modules and generates an initialiser
function for them (in C, unfortunately).
2017-01-03 18:54:13 +00:00
David Given
e2751f76b5 Add a control flow test. 2017-01-01 23:51:48 +00:00
David Given
62bc2ab97a Jump tables for switch now go in ROM (required by the EM spec). Forward gotos
now work.
2017-01-01 23:28:41 +00:00
David Given
8b8910595a Add proper support for negative constants in external initialisers. 2017-01-01 17:56:53 +00:00
David Given
049aff9f33 Remove the negative-constant code from the compiler; I think it's going to
break a=-1 (with no spaces). Backed out changeset dead3363ac7d.
2017-01-01 17:44:55 +00:00
David Given
be909fe045 Add tests for more operators. 2017-01-01 17:44:03 +00:00
David Given
374e7a1c57 Add support for the ~ operator. 2017-01-01 17:40:06 +00:00
David Given
b1576e2c77 Add support for negative constants in external initialisers. 2016-12-31 19:43:03 +00:00
David Given
a01523a893 Allow programs to override binit() (so they can register their own modules). 2016-12-31 17:39:51 +00:00
David Given
1beedca590 Add support for B tests; add a test for the B operators (finding several
compiler bugs in the process).
2016-12-31 17:38:52 +00:00
David Given
803b81e3f4 Add support for the xor operator. 2016-12-31 17:36:12 +00:00
David Given
c3e1ef1064 B patch table names shouldn't be in the B symbol namespace. 2016-12-31 00:14:28 +00:00
David Given
fa02a855e8 Fix issue where !x was actually calculating !!x. 2016-12-31 00:14:04 +00:00
David Given
462529a7d2 Trying to install openbios-ppc causes Travis to error out now (not sure why). 2016-12-29 17:30:47 +00:00
David Given
e460adc923 Add a B version of the hilo program. 2016-12-29 17:20:51 +00:00
David Given
4e68af9781 Add a declaration for the -Bxyz module name flag, used by the B compiler.
Rename some of the Basic flags to avoid confusion.
2016-12-29 17:12:40 +00:00
David Given
0e10329876 Fix an issue throughout where B couldn't be built by ackprogram due to symbol
laziness.
2016-12-29 17:11:53 +00:00
David Given
a43258fe9d Build the B compiler and standard library (also the Basic one, which was
missing).
2016-12-29 17:11:07 +00:00
David Given
ebd424e7f1 First draft of the B module code; a module name can now be specified as a
compiler flag, which is used to set the name of the patch table. The compiler
now understands C preprocessor line directives. Extend the standard library
somewhat.
2016-12-29 17:10:21 +00:00
David Given
e3f8fb84dc Change the i80 assembler to be three-pass, which allows forward references;
required for assembling B.
2016-12-29 17:08:53 +00:00
David Given
52f82a76b6 Don't crash when using the -u option to enter undefined symbols. 2016-12-28 23:49:55 +00:00
David Given
49dd5724ca Correctly export PREFIX to the Lua build system. 2016-12-28 19:16:15 +00:00
David Given
3cdceaa700 Merge in B changes. 2016-12-28 17:30:14 +00:00
David Given
e50f4be710 Merge from default. 2016-12-26 19:44:48 +00:00
David Given
decf0f5e9c Merge pull request #29 from kernigh/pr-elf-symbol
ELF symbol table from aelflod
2016-12-14 22:30:44 +01:00
George Koehler
7e39a821f4 Update aelflod.1 to describe options, mention symbol table. 2016-12-13 17:22:45 -05:00
George Koehler
5cf2a68438 Teach aelflod to write the ELF symbol table.
Convert each ack.out symbol to ELF, preserving its name and value, and
some but not all other symbol info.  The ELF symbol table comes with
ELF section headers.  If the input file has no symbols (ack -Rled-s),
then the output file has no ELF section headers.

Append the symbol table and section headers to the ELF file.  Linux
ignores this appended info when it execs the file.  The info might
pollute the last page of the ELF segment, but Linux clears this
pollution.  Tools like nm and gdb can read the ELF symbol table.

I include code to translate debugger symbols to an ELF .stab section.
I did not test this code, because I did not find a platform that can
put S_STB symbols in the ack.out file.
2016-12-13 16:41:22 -05:00
George Koehler
8280ca8745 In aslod, remove some unused m68k2 stuff. 2016-12-13 16:02:38 -05:00
George Koehler
2874806048 Tweak man syntax in aelflod.1 and aslod.1
Put end of sentence at end of line.  This is roff(7) syntax so the
formatter can make spacing between sentences.

Use the macro .PP to break paragraphs.  Use bold for the command name
in SYNOPSIS, to match other ack manuals.
2016-12-13 15:54:38 -05:00
David Given
bf2e0be69a Merge pull request #27 from kernigh/pr-qemu-doze
Teach qemuppc to halt the cpu on _exit().
2016-12-11 23:17:12 +01:00
David Given
62edb90641 Convert the inn test to work with the test library and not import InOut; it now
runs on qemuppc again. Reenable qemuppc tests.
2016-12-11 23:06:37 +01:00
David Given
65fdb03231 Merge pull request #28 from kernigh/pr-set-ppc
add Modula-2 set operations to PowerPC ncg
2016-12-11 22:25:04 +01:00
George Koehler
8605a2fcfc Add Modula-2 set operations to PowerPC ncg.
This provides and, ior, xor, com, zer, set, cms when defined($1) and
ior, set when !defined($1).  I don't provide the other operations
!defined($1) because our Modula-2 compiler hasn't used them.

I wrote a Modula-2 example in
https://gist.github.com/kernigh/add79662bb3c63ffb7c46d01dc8ae788

Put a dummy comment in mach/powerpc/libem/build.lua so git checkout
will touch that file.  Without the touch, the build system doesn't see
the new *.s files.
2016-12-10 12:23:07 -05:00
George Koehler
fcda786fe9 Add some missing clauses to los, sts, aar, inn, cmi, cmu.
We only implement 'los 4', 'sts 4', 'cmi 4', 'cmu 4', not for sizes
other than 4.  Add clause $1==4.

We only implement inn when defined($1).

The rule for aar needs 'kills ALL' because it kills many registers,
like other rules that call libem.
2016-12-09 19:49:50 -05:00
George Koehler
436114fce4 Add a move from CONST smalls(%val) to GPR.
This allows 'move {CONST, $1}, R3' with a small enough $1 to emit one
instruction (addi) instead of two instructions (addis, ori).  The
CONST token confusingly isn't in the CONST_ALL set.
2016-12-09 18:40:14 -05:00
George Koehler
17211eef47 Fix ass to match the EM spec.
The spec says, "ASS w: Adjust the stack pointer by w-byte integer".
The w argument "can either be given as argument or on top of the
stack."  Therefore, 'ass 4' would pop the 4-byte integer from the
stack, but 'ass' would pop the size w from the stack, then pop the
w-byte integer.

PowerPC ncg wrongly implemented 'ass' as if it was 'ass 4'.  Fix it to
accept only 'ass 4'.
2016-12-09 17:32:42 -05:00
George Koehler
5bd0ad4269 Remove the bogus rules for 'lor 2' and 'str 2'.
These instructions would load or store the EM heap pointer.  They
don't work.  Programs must use brk() or sbrk() in libsys.

The last file to use 'lor 2' and 'str 2' was lang/pc/libpc/sav.e in
the Pascal library.  Commit c084f9f deleted the file, so we no longer
need rules 'lor 2' or 'str 2' to build the ACK.
2016-12-09 17:00:56 -05:00
George Koehler
805883e377 Fill in a hint for enabling the COMMENT macro.
If you want to enable comments in the .s file, change

    #define COMMENT(n) /* comment {LABEL, n} */

to

    #define COMMENT(n) comment {LABEL, n}
2016-12-09 16:58:47 -05:00
George Koehler
244e554f2f Remove trailing whitespace in mach/powerpc/ncg/table 2016-12-09 16:36:42 -05:00
George Koehler
df86e3b84f Fix typo: msr0 should be msr. 2016-12-09 16:04:21 -05:00
George Koehler
d94ea4c508 Teach qemuppc to halt the cpu on _exit().
Without this, qemu-system-ppc spins the host cpu until I close its
window.  I assume the default G3 emulation.  The emulator yields the
host cpu if I set certain flags in hid0 then msr.  The hid0 flag can
be any of DOZE, NAP, SLEEP, so I just set all 3.  I encode mfmsr and
mtmsr with .data4, because our assembler doesn't know instructions for
supervisor mode.

Also move some common symbols from .rom to .bss.  Our assembler puts
common symbols in any section.

Also clean up the file.  Delete a comment about linuxppc that is wrong
here.  Delete redundant .extern because .define is the same.
2016-12-07 18:11:12 -05:00