Commit graph

7196 commits

Author SHA1 Message Date
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
George Koehler b8c921ca70 Allow mfspr, mtspr with a register number.
PowerPC has a few hundred special-purpose registers.  The assembler
had only accepted the names "xer", "lr", "ctr".  Most programs use
only those three SPRs.  If I add more names, they would almost never
get used, and they might conflict with labels.

I want to use "mfspr r3, 0x3f0" and "mtspr 0x3f0, r3" in
plat/qemu/boot.s to access register hid0 from supervisor mode.
2016-12-07 17:28:00 -05:00
David Given 97acc7bcad Merge pull request #25 from davidgiven/dtrg-inn
Fix endianess issue with inn.
2016-12-06 22:24:31 +01:00
David Given 1039c0a747 Add a test for #22. 2016-12-06 22:07:22 +01:00
David Given 67e7d226ad Disable qemuppc tests; turns out qemu-system-ppc won't load more than the first
4kB of a kernel...
2016-12-06 22:06:17 +01:00
David Given cc3d72e884 Fix redirection so stray stderr output from qemu doesn't cause mysterious test
failures.
2016-12-06 22:05:14 +01:00
David Given 55e24e1f24 inn was assuming that bitfields were arrays of bytes, when actually they're
arrays of words (which makes the LSB move on big-endian systems).
2016-12-06 21:45:20 +01:00
David Given 6a77309e96 Merge pull request #23 from kernigh/pr-osx
new platforms osx386 and osxppc
2016-12-06 16:28:24 +01:00
George Koehler 6cbea83f7f Don't share as, ncg, top between Linux and Mac OS X.
Telling osx386 and osxppc to build and run their own tools, not to
reuse the tools from linux386 and linuxppc.  This wastes time to build
identical tools, but it removes some bogus dependencies.  OS X tools
had wrongly depended on Linux descr files and aelflod; now they don't.

Discussion in https://github.com/davidgiven/ack/pull/23
2016-12-05 20:13:29 -05:00
David Given 3fe285f8f8 Fix some shell issues that would occasionally cause hangs if no tests failed. 2016-12-05 21:06:38 +01:00
David Given c569ca15d8 Clean up how the language libraries refer to plat headers; they should be using
the +pkg forms of the rules and getting the headers via the paths in descr,
rather than depending on the +headers version.
2016-12-05 21:05:24 +01:00