open-simh.simtools/tests/test-reg.mac
Olaf Seibert 3a9d809b75 Optimize the previous version.
Fold the functionality of pull_up_reg() into evaluate_rec().
pull_up_reg() essentially returned a flag (EX_REG at the top, or not)
which can be represented with the outgoing flags word.
The check for recursion depth is made unneeded by doing the
"exceptional" case outside the recursion; luckily it is actually the
common case.
2021-11-15 21:35:37 +01:00

96 lines
3.0 KiB
Plaintext

;;;;;
;
; Test expressions that evaluate to registers.
;
; !!! THIS TEST IS NOT RUN YET BECAUSE MANY OF THE CASES FAIL !!!
;
; All lines not marked "error" should assemble without complaint
; as absolute values (no relocation etc).
;
; Section 3.4 (page 3-8) is a bit vague about the expressions that are allowed
; after a %, but "the digit specifying the register can be replaced by any valid,
; absolute term that can be evaluated during the first assembly pass."
; It specifically mentions %3+1 to be the same as %4.
; For the rest there is no indication where exactly register labels can be used.
.psect abs,abs
A = 1
l1 = %1
l2 = %1+1
l3 = %a
l4 = %a + 1
l5 = %<1+1>
l6 = <%1>+1 ; must be register!
l7 = <%a>+1 ; must be register!
l8 = %1 + %2
l8a = <%1> + <%2> ; must be register!
l9 = %<%1 + %2>
l9c = %<%<%1 + %2>>
l9d = %<%<%<%1 + %2>>>
l9a = %<R1 + R2>
l9b = %<R1>
B = rti ; 2
l10 = %B
l11 = %wait ; 1
l12 = %1.
l13 = %7.
l14 = %10 ; error: too large (error R), but symbol is still def'd
l15 = %8. ; error: too large (error R), but symbol is still def'd
mov #R2,R2
mov #%2,%2 ; 012702 000002 must be absolute, not reloc!
mov #l1,%2 ; 012702 000001 (idem)
mov #<%1+%2>,%3 ; 012703 000003 (idem)
mov #<l1+1>,%3 ; 012703 000002 (idem)
mov #<%l1+1>,%3 ; 012703 000002 (idem)
mov #r0,%2 ; 012702 000000 (idem)
here: mov #here,%2
mov #rti,%2
mov %2,%2 ; 010202
mov l1,%2 ; 010102
mov <%1+%2>,%3 ; 010303
mov <l1+1>,%3 ; 010203
mov R1+1,%3 ; 010203
mov <%l1+1>,%3 ; 010203
mov %1,r2 ; mov r1,r2
mov %0+1,r2 ; mov r1,r2
mov %<0+1>,r2 ; mov r1,r2
mov r0,r2 ; mov r0,r2
mov ----r1,<r2> ; mov r1,r2
mov r0+1,r2 ; mov r1,r2
mov r1+7,r2 ; error: too large
; R 58 000066 016702 000010' mov r1+7,r2 ; too large
; this shows that after a % comes a unary expr,
; not an arbitrary binary expr:
l30 = 1+%2*2 ; %6.
l31 = <1+%2>*3 ; %9. error: too large, but symbol is still defined (R error)
mov l31,r0 ; error: bad register; code 011100 (R error)
l32 = 1+%<2*2> ; %5
l33 = 1+<%2*2> ; %5
l20 = %l1
l21 = %l20
l22 = l1 ; still a register
l23 = l22 ; still a register
.globl extrn
l40 = %extrn ; A error; L40 =%******
mov l40,r0 ; U error; code 010000
.word r0,wait,r1+1,wait+2,%4 ; 0, 1, 2, 3, 4
.end