open-simh.simtools/tests/test-endm.mac

64 lines
1.4 KiB
Plaintext

;;;;;
;
; Test nested macros and name on .ENDM
;
.macro M1
.word 1
.endm M1 ; ok
M1
.macro M2
.word 2
.macro M3
.word 3
.endm M3 ; ok
.endm M2 ; ok
M2
M3
.macro M4
.word 4
.macro M4
.endm M4 ; ok
.endm M4 ; ok
M4
M4 ; should be empty now
.macro M5
.word 5
.macro M5
.endm notM5 ; wrong; detected when M5 is expanded
.endm M5 ; ok
M5
M5
.macro M6
.endm notM6 ; wrong
.endm ; end without macro
.endr ; end without repetition
.endc ; end without condition
; Test that a macro that is defined inside another macro isn't already
; defined while defining the outer macro.
; This is a bit tricky: macros are kept between passes, so just
; testing M3 before M2 (like above) won't work.
.macro M7
.word 7
.if p2
.macro M8 ; only defined in pass 2
.word 8.
.endm M8 ; ok
.endc
.endm M7 ; ok
M8 ; not defined yet; will be taken as implied .word.
M7 ; defines M8.
M8 ; which can now be used.