From eb60cfe315fcfd8885f1703a546f405b30da71b1 Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Sun, 23 Apr 2017 13:51:53 +0200 Subject: [PATCH] Very simple .LIST and .NLIST implementation. Thanks to Don North. Also added a simple test. Fixes #3. --- assemble.c | 10 +++++++--- tests/RunTests | 1 + tests/test-listing.lst.ok | 26 ++++++++++++++++++++++++++ tests/test-listing.mac | 22 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 tests/test-listing.lst.ok create mode 100644 tests/test-listing.mac diff --git a/assemble.c b/assemble.c index a4df153..b20c866 100644 --- a/assemble.c +++ b/assemble.c @@ -277,12 +277,16 @@ static int assemble( case P_ENDR: case P_ENDM: case P_SBTTL: - case P_LIST: - case P_NLIST: case P_PRINT: return 1; /* Accepted, ignored. (An obvious need: get assembly listing - controls working. ) */ + controls working fully. ) */ + case P_LIST: + if (pass > 0) list_level++; + return 1; + case P_NLIST: + if (pass > 0) list_level--; + return 1; case P_IDENT: { diff --git a/tests/RunTests b/tests/RunTests index d9c28d6..b9796be 100755 --- a/tests/RunTests +++ b/tests/RunTests @@ -14,6 +14,7 @@ TESTS="test-asciz \ test-impword \ test-include \ test-jmp \ + test-listing \ test-locals \ test-macro-comma \ test-prec \ diff --git a/tests/test-listing.lst.ok b/tests/test-listing.lst.ok new file mode 100644 index 0000000..176e53e --- /dev/null +++ b/tests/test-listing.lst.ok @@ -0,0 +1,26 @@ + 1 ;;;;;; + 2 ; + 3 ; Test the (so far very basic) .LIST and .NLIST directives. + 4 ; + 5 + 6 ; This should get listed (list_level 1) + 7 .nlist + 10 ; This should get listed (list_level 1) + 11 .list + 12 ; This should get listed (list_level 2) + 13 .nlist + 14 ; This should get listed (list_level 1) + 15 .nlist + 22 ; This should get listed (list_level 1) + 22 + + +Symbol table + +. ******R 001 + + +Program sections: + +. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) + 000000 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-listing.mac b/tests/test-listing.mac new file mode 100644 index 0000000..1b8dd7d --- /dev/null +++ b/tests/test-listing.mac @@ -0,0 +1,22 @@ +;;;;;; +; +; Test the (so far very basic) .LIST and .NLIST directives. +; + +; This should get listed (list_level 1) + .nlist +; This should NOT get listed (list_level 0) + .list +; This should get listed (list_level 1) + .list +; This should get listed (list_level 2) + .nlist +; This should get listed (list_level 1) + .nlist +; This should NOT get listed (list_level 0) + .nlist +; This should NOT get listed (list_level -1) + .list +; This should NOT get listed (list_level 0) + .list +; This should get listed (list_level 1)