From 1c37223977115cc57bd9d143ff9b6f93661e0e20 Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Sun, 14 Nov 2021 22:49:44 +0100 Subject: [PATCH] Make sure .word R0 etc are output as absolute values. Previously it was generated as relocatable. --- assemble_aux.c | 4 ++++ tests/test-word-comma.lst.ok | 8 +++++--- tests/test-word-comma.mac | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/assemble_aux.c b/assemble_aux.c index 2218033..f678185 100644 --- a/assemble_aux.c +++ b/assemble_aux.c @@ -671,6 +671,10 @@ void store_value( } else { if (SYM_IS_IMPORTED(sym)) { store_global_offset_word(stack->top, tr, size, sym->value + offset, sym->label); + } else if (sym->section->type == SECTION_REGISTER) { + /* Delayed action: evaluate_rec() excludes SECTION_REGISTER when + * turning symbols into EX_LIT. Do it here now. */ + store_word(stack->top, tr, size, sym->value + offset); } else if (sym->section != current_pc->section) { store_psect_offset_word(stack->top, tr, size, sym->value + offset, sym->section->label); } else { diff --git a/tests/test-word-comma.lst.ok b/tests/test-word-comma.lst.ok index eceef7c..047e2fb 100644 --- a/tests/test-word-comma.lst.ok +++ b/tests/test-word-comma.lst.ok @@ -10,15 +10,17 @@ 10 000042 000001 000000 000003 .word 1,,3 ; 3 words 11 000050 000001 000002 000003 .word 1,2,3 ; 3 words 12 - 12 + 13 000056 000000 000001 000002 .word r0,wait,r1+1,wait+2,%4,%4+1 ; 0, 1, 2, 3, 4, 5 + 000064 000003 000004 000005 + 13 Symbol table -. 000056R 001 START 000000R 001 +. 000072R 001 START 000000R 001 Program sections: . ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) - 000056 001 (RW,I,LCL,REL,CON,NOSAV) + 000072 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-word-comma.mac b/tests/test-word-comma.mac index 16a594e..acdb3ca 100644 --- a/tests/test-word-comma.mac +++ b/tests/test-word-comma.mac @@ -10,3 +10,4 @@ start: .word 123 ; 1 word .word 1,,3 ; 3 words .word 1,2,3 ; 3 words + .word r0,wait,r1+1,wait+2,%4,%4+1 ; 0, 1, 2, 3, 4, 5