1
0
mirror of https://github.com/wfjm/w11.git synced 2026-03-01 01:50:01 +00:00
Files
wfjm.w11/tools/asm-11/tests/test_0300_macro.mac
wfjm 3b033ebfa8 major asm-11 update
- tools/bin
  - asm-11
    - add .if, .if(f|t|tf), .endc, .rept, .endr, .mexit directives
    - add .error, .print, .mcall, .mdelete directives
    - add .narg, .nchr, .ntype directives
    - rewrite macro definition and call argument parsing & handling
    - add -L option (to set .mcall pathlist)
    - add auto-generated ...top label
    - add flag (MRmrd) column in output format
  - asm-11_expect
    - add simple substitution mechanism (for macro testing)
    - handle new flag column in output format
- tools/asm-11
  - tests(-err): many tests added
  - tests(-err)/Makefile: distclean target added
  - mlib: macro library, accessed by .mcall
2023-01-26 16:13:36 +01:00

88 lines
2.7 KiB
Plaintext

; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2019-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
; test .macro basics
;
.asect
. = 1000
; list macro expansion
.list me
; define simple macros
.macro push,src
mov src,-(sp) ;;!! $l1
.endm
.macro word,val
.word val ;;!! $l1
.endm
;
; use a simple macro with all addressing modes
;
v1: .word 0
.word 0
v2: .word v1
.word v1+2
off = 2
;
push r5 ;;!= l1 = 010546
push (r4) ;;!= l1 = 011446
push (r3)+ ;;!= l1 = 012346
push @(r2)+ ;;!= l1 = 013246
push -(r1) ;;!= l1 = 014146
push @-(r0) ;;!= l1 = 015046
push 10(r0) ;;!= l1 = 016046 000010
push 10+2(r1) ;;!= l1 = 016146 000012
push 10+<1+2*2>(r2) ;;!= l1 = 016246 000016
push @20(r3) ;;!= l1 = 017346 000020
push @20+^b100(r4) ;;!= l1 = 017446 000024
push v1 ;;!= l1 = 016746 177724
push @v2 ;;!= l1 = 017746 177724
;
; simple word generation
;
a = 1
b = 2
word 100 ;;!= l1 = 000100
word a+b+1 ;;!= l1 = 000004
word <^b1010+b-2*a> ;;!= l1 = 000012
;
; define and a macro with 3 arguments (use . and $ in key names)
;
.macro test x .x $x
.word x ;;!! 001001
.word .x ;;!! 001002
.word $x ;;!! 001003
.endm
test 1001 1002 1003
;
; some simple macro usage
;
.macro scall,dst
jsr pc,dst ;;!! $l1
.endm
.macro sret
rts pc ;;!! $l1
.endm
.macro push,src
mov src,-(sp) ;;!! $l1
.endm
.macro pop,dst
mov (sp)+,dst ;;!! $l1
.endm
;
. = 2000
t01: scall t01sub ;;!= l1 = 002000: 004767 000002
halt
1$: ;;!! 002006:
t01sub: push r0 ;;!= l1 = 002006: 010046
push r1 ;;!= l1 = 002010: 010146
pop r1 ;;!= l1 = 002012: 012601
pop r0 ;;!= l1 = 002014: 012600
sret ;;!= l1 = 002016: 000207
1$: ;;!! 002020:
.end