├── test ├── incl2.inc ├── incl02.mac ├── xxx.mac ├── xx1.mac ├── xx2.mac ├── incl1.inc ├── ident.mac ├── test.280 ├── xx.mac ├── incl01.mac ├── test5.mac ├── error_check │ ├── ext0.mac │ ├── expr3.mac │ ├── macro23.mac │ ├── macro15.mac │ ├── dstest.mac │ ├── exttest.mac │ ├── macro11.mac │ ├── local1.mac │ ├── exttest1.mac │ ├── macro10a.mac │ ├── macro13.mac │ ├── macro22.mac │ ├── macro3a.mac │ ├── irp.mac │ ├── expr2.mac │ ├── irpc.mac │ ├── macro26.mac │ ├── irp1.mac │ ├── cconst.mac │ ├── expr.mac │ ├── dudops.mac │ └── zsmtst2.mac ├── test1.mac ├── dseg0.mac ├── exttest2.mac ├── exttest4.mac ├── macro4.mac ├── pp.mac ├── macro1.mac ├── exttest3.mac ├── asegtst.mac ├── exttest.mac ├── macro12.mac ├── incl0.mac ├── dszero.mac ├── macro10.mac ├── macro14.mac ├── macro2.mac ├── comment.mac ├── sltest.mac ├── macro8.mac ├── common2.mac ├── defz.mac ├── local1.mac ├── macro28.mac ├── 128.mac ├── macro27.mac ├── exttest1.mac ├── rqst.mac ├── macro10a.mac ├── rept.mac ├── macro5.mac ├── common.mac ├── radix.mac ├── iftest.mac ├── macro3.mac ├── macro7.mac ├── even.mac ├── macro11.mac ├── macro29.mac ├── reltest.mac ├── rept1.mac ├── common3.mac ├── irp.mac ├── macro0.mac ├── ldwtest.mac ├── common1.mac ├── macro6.mac ├── macro9.mac ├── macro22.mac ├── macro16.mac ├── macro1a.mac ├── local2.mac ├── test3.mac ├── local.mac ├── else.mac ├── cputest.mac ├── iext.mac ├── macro13.mac ├── segtest.mac ├── macro17.mac ├── expr2.mac ├── irpc.mac ├── macro3a.mac ├── macro26.mac ├── test4.mac ├── irp1.mac ├── ifbnb.mac ├── iferrc.mac ├── ifidndif.mac ├── cconst.mac ├── lesstest.mac ├── ifdef.mac ├── expr.mac ├── nultest.mac ├── macro25.mac ├── macro24.mac ├── phase.mac ├── test2.mac ├── symtest.mac ├── test816.280 ├── Makefile ├── test2a.mac ├── ra280.mac ├── test816.mac ├── qio.inc ├── testz80.mac ├── macro20.mac └── macro21.mac ├── fcslib.lib ├── syslib.lib ├── bin ├── zsm4.com ├── zsm4_rsx180.tsk └── zsm4_rsx280.tsk ├── docs ├── zsm4.odt └── zsm4.pdf ├── README.md ├── fcslib.inc ├── Makefile ├── zsm.inc ├── gcml.inc ├── errors.inc ├── sysfn.inc ├── fcb.inc ├── alloc.mac ├── tcb.inc ├── genrel.mac ├── symbols.mac └── LICENSE /test/incl2.inc: -------------------------------------------------------------------------------- 1 | lvl2 equ $ 2 | -------------------------------------------------------------------------------- /test/incl02.mac: -------------------------------------------------------------------------------- 1 | db 4,5,6 2 | end 3 | -------------------------------------------------------------------------------- /test/xxx.mac: -------------------------------------------------------------------------------- 1 | aaa: 2 | db 1 3 | end 4 | -------------------------------------------------------------------------------- /test/xx1.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | ld a,xyz 3 | end 4 | -------------------------------------------------------------------------------- /test/xx2.mac: -------------------------------------------------------------------------------- 1 | aa equ 1 2 | aa equ 2 3 | end 4 | -------------------------------------------------------------------------------- /test/incl1.inc: -------------------------------------------------------------------------------- 1 | include incl2.inc 2 | lvl1 equ $ 3 | -------------------------------------------------------------------------------- /fcslib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/fcslib.lib -------------------------------------------------------------------------------- /syslib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/syslib.lib -------------------------------------------------------------------------------- /bin/zsm4.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/bin/zsm4.com -------------------------------------------------------------------------------- /test/ident.mac: -------------------------------------------------------------------------------- 1 | name 'name' 2 | ident 'ident' 3 | db 1 4 | end 5 | -------------------------------------------------------------------------------- /docs/zsm4.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/docs/zsm4.odt -------------------------------------------------------------------------------- /docs/zsm4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/docs/zsm4.pdf -------------------------------------------------------------------------------- /test/test.280: -------------------------------------------------------------------------------- 1 | ldw hl,(hl+0) 2 | ld a,(ix+iy) 3 | sc 88 4 | end 5 | -------------------------------------------------------------------------------- /bin/zsm4_rsx180.tsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/bin/zsm4_rsx180.tsk -------------------------------------------------------------------------------- /bin/zsm4_rsx280.tsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hperaza/ZSM4/HEAD/bin/zsm4_rsx280.tsk -------------------------------------------------------------------------------- /test/xx.mac: -------------------------------------------------------------------------------- 1 | dw 1,2,3,4 2 | db 1 3 | .xlist 4 | if 0 5 | db 2 6 | end 7 | -------------------------------------------------------------------------------- /test/incl01.mac: -------------------------------------------------------------------------------- 1 | ; chained include test 2 | 3 | db 1,2,3 4 | include incl02.mac 5 | -------------------------------------------------------------------------------- /test/test5.mac: -------------------------------------------------------------------------------- 1 | public p1 2 | extrn e1 3 | 4 | p1: 5 | l1: 6 | dw e1 7 | end 8 | -------------------------------------------------------------------------------- /test/error_check/ext0.mac: -------------------------------------------------------------------------------- 1 | extrn foobar 2 | aseg 3 | org 0 4 | dw foobar/1 5 | end 6 |  -------------------------------------------------------------------------------- /test/test1.mac: -------------------------------------------------------------------------------- 1 | org 100h 2 | db 1,2,3,4,5 3 | org 9Eh 4 | db 6,7,8,9,10 5 | end 6 | -------------------------------------------------------------------------------- /test/dseg0.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | dw aa 4 | 5 | dseg 6 | 7 | aa: 8 | 9 | end 10 | -------------------------------------------------------------------------------- /test/exttest2.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | extrn x 3 | cseg 4 | ld hl,x 5 | dseg 6 | dw x 7 | end 8 |  -------------------------------------------------------------------------------- /test/exttest4.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | cseg 3 | extrn a1 4 | ld hl,a1 5 | dw a1+5 6 | dw a1 7 | dw a1-5 8 | end a1 9 |  -------------------------------------------------------------------------------- /test/macro4.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | test macro 3 | db 1 4 | include incl2.inc 5 | db 2 6 | endm 7 | test 8 | end 9 | -------------------------------------------------------------------------------- /test/pp.mac: -------------------------------------------------------------------------------- 1 | public pp,qq,rr 2 | 3 | db 33 4 | 5 | pp equ 1234h 6 | qq equ $ 7 | rr: 8 | 9 | end 10 | -------------------------------------------------------------------------------- /test/macro1.mac: -------------------------------------------------------------------------------- 1 | ; Simple MACRO with arguments 2 | 3 | test1 macro a,b,c 4 | db a,b,c 5 | endm 6 | test1 1,2,3 7 | end 8 | -------------------------------------------------------------------------------- /test/exttest3.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | extrn x 3 | cseg 4 | org 20h 5 | ld hl,x 6 | dseg 7 | org 40h 8 | dw x 9 | end 10 |  -------------------------------------------------------------------------------- /test/asegtst.mac: -------------------------------------------------------------------------------- 1 | ; ASEG test 2 | 3 | cseg 4 | db 1 5 | aseg 6 | org 100h 7 | a1:: ds 10 8 | a2: db 1 9 | 10 | end a1 11 | -------------------------------------------------------------------------------- /test/error_check/expr3.mac: -------------------------------------------------------------------------------- 1 | db and 1 2 | db 1 and 3 | db and not 1 4 | db 1 and not 5 | if and not 1 6 | db 1 7 | endif 8 | end 9 | -------------------------------------------------------------------------------- /test/exttest.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | cseg 3 | extrn a1 4 | ld hl,a1 5 | dw a1+5 6 | dw a1 7 | dw a1 8 | dw a1-5 9 | end a1 10 |  -------------------------------------------------------------------------------- /test/macro12.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | t1 macro str 4 | db str 5 | endm 6 | 7 | t1 <'Hello, world!',0Dh,0Ah,0> 8 | 9 | end 10 | -------------------------------------------------------------------------------- /test/incl0.mac: -------------------------------------------------------------------------------- 1 | ; Nested include test: 2 | ; incl0.mac 3 | ; incl1.inc 4 | ; incl2.inc 5 | 6 | include incl1.inc 7 | root: db 0 8 | end 9 | -------------------------------------------------------------------------------- /test/dszero.mac: -------------------------------------------------------------------------------- 1 | ; Test for /M option 2 | 3 | cseg 4 | 5 | test:: ds 10 6 | ds 10 7 | 8 | dseg 9 | 10 | ds 100 11 | 12 | end 13 | -------------------------------------------------------------------------------- /test/macro10.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | test macro a,,b 4 | db a,b 5 | endm 6 | 7 | test 1,2 8 | test 1,,2 9 | test 1,2,3 10 | 11 | end 12 | -------------------------------------------------------------------------------- /test/macro14.mac: -------------------------------------------------------------------------------- 1 | tt macro 2 | db 1 3 | tt macro 4 | db 2 5 | endm 6 | endm 7 | 8 | tt 9 | tt 10 | tt 11 | tt 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/macro2.mac: -------------------------------------------------------------------------------- 1 | test1 macro a,b,c 2 | db a,b,c 3 | endm 4 | test2 macro 5 | test1 1,2,3 6 | endm 7 | test1 1,2,3 8 | test2 9 | end 10 | -------------------------------------------------------------------------------- /test/comment.mac: -------------------------------------------------------------------------------- 1 | ; .COMMENT block test 2 | 3 | cseg 4 | 5 | db 1,2,3 6 | .comment % 7 | db 4,5,6 8 | % 9 | db 7,8,9 10 | 11 | end 12 | -------------------------------------------------------------------------------- /test/error_check/macro23.mac: -------------------------------------------------------------------------------- 1 | ; label before ENDM 2 | 3 | test macro 4 | local label 5 | jp label 6 | label: endm 7 | 8 | test 9 | 10 | end 11 | -------------------------------------------------------------------------------- /test/sltest.mac: -------------------------------------------------------------------------------- 1 | public long$symbol$1,long$symbol$2 2 | 3 | long$symbol$1: db 0 4 | long$symbol$2: db 0 5 | long$symbol$3: db 0 6 | long$symbol$4: db 0 7 | 8 | end 9 | -------------------------------------------------------------------------------- /test/macro8.mac: -------------------------------------------------------------------------------- 1 | ; if1 2 | ; db 0 3 | ; endif 4 | 5 | test 6 | 7 | dd: 8 | ee equ $ 9 | ff equ dd 10 | 11 | test macro 12 | db 1 13 | endm 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/common2.mac: -------------------------------------------------------------------------------- 1 | ; COMMON data overlap test 2 | 3 | common /c1/ 4 | aa: db 0,1,2 5 | common /c1/ 6 | bb: db 3,4,5 7 | dd: dw 1000 8 | public aa,bb,dd 9 | 10 | end 11 | -------------------------------------------------------------------------------- /test/error_check/macro15.mac: -------------------------------------------------------------------------------- 1 | big macro a 2 | db a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a 3 | endm 4 | 5 | big 'Testing input buffer overflow during macro expansion' 6 | 7 | end 8 | -------------------------------------------------------------------------------- /test/defz.mac: -------------------------------------------------------------------------------- 1 | ; DEFZ statement test 2 | 3 | dseg 4 | 5 | cr equ 0Dh 6 | lf equ 0Ah 7 | 8 | defz 'Hello, world!',cr,lf 9 | defz 3,2,1 10 | defz '' 11 | 12 | end 13 | -------------------------------------------------------------------------------- /test/error_check/dstest.mac: -------------------------------------------------------------------------------- 1 | ; DS test: argument can be only a non-reloc constant 2 | 3 | cseg 4 | aa: 5 | ds aa ; not allowed 6 | extrn bb 7 | ds bb ; not allowed 8 | 9 | end 10 | -------------------------------------------------------------------------------- /test/local1.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | irpc c,abc 4 | m&c macro 5 | local d ;; allowed 6 | d aset d+1 7 | db '&c' 8 | endm 9 | endm 10 | 11 | ma 12 | mb 13 | mc 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/macro28.mac: -------------------------------------------------------------------------------- 1 | t macro n 2 | local v 3 | v defl 0 4 | aaaaa&n:rept n 5 | db v 6 | v defl v+1 7 | endm 8 | endm 9 | 10 | t 0 11 | t 1 12 | t 2 13 | t 8 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/128.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | ld hl,1 3 | ld de,2 4 | ld bc,3 5 | ldir 6 | 7 | ld hl,1 8 | ld de,2 9 | ld bc,3 10 | ldir 11 | 12 | ld hl,1 13 | ld de,2 14 | ld bc,3 15 | ldir 16 | end 17 | -------------------------------------------------------------------------------- /test/macro27.mac: -------------------------------------------------------------------------------- 1 | ; M80 does not pass this test 2 | 3 | test macro x,y,z,t 4 | &x &y &z 5 | db 1 6 | &t 7 | endm 8 | 9 | test a1,macro,,endm 10 | a1 11 | test ,rept,5,endm 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/error_check/exttest.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | cseg 3 | extrn a1 4 | ld hl,a1 5 | dw a1+5 6 | dw a1 7 | dw a1 8 | dw a1-5 9 | b1: 10 | dw 2*b1 11 | dw b1*2 12 | dw 2*a1 13 | dw a1*2 14 | end a1 15 |  -------------------------------------------------------------------------------- /test/exttest1.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | extrn e1 3 | extrn e4 4 | public p1 5 | ld hl,e1 6 | ld hl,e1## 7 | c1: ld hl,e2 8 | ld hl,e2## 9 | ld hl,e3 10 | ld hl,e3## 11 | ld hl,e3 12 | ld hl,c1 13 | end 14 | -------------------------------------------------------------------------------- /test/rqst.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | 3 | .request syslib,forlib 4 | 5 | ld hl,100h 6 | ld de,200h 7 | ld bc,5 8 | ldir 9 | 10 | .request extralib 11 | .request 0lib ; error - invalid name 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/macro10a.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | test2 macro a,b,c 4 | db '&a' 5 | db '&b' 6 | db '&c' 7 | endm 8 | 9 | test2 1,2,3 10 | test2 1,,3 11 | test2 ,2,3 12 | test2 ,,3 13 | test2 1,, 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/rept.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | rept 0 4 | db 0 5 | endm 6 | 7 | rept 10 8 | db 8 9 | endm 10 | 11 | rept 2 12 | db 2 13 | rept 5 14 | db 15 ; comment 15 | endm 16 | db 3 17 | endm 18 | 19 | end 20 | -------------------------------------------------------------------------------- /test/macro5.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | test macro abc 3 | abc&de: db '&abcde' 4 | de&abc: db 'abc&de' 5 | abc#de: 6 | de#abc: 7 | db '&abc' 8 | db '&abc de' 9 | db '&abc#de' 10 | db '&abc!de' 11 | endm 12 | test xz 13 | end 14 | -------------------------------------------------------------------------------- /test/common.mac: -------------------------------------------------------------------------------- 1 | ; COMMON segment test: second /ABC/ must overlap first (not concatenate) 2 | 3 | common /ABC/ 4 | 5 | aa: db 1 6 | 7 | dseg 8 | 9 | dd: db 1 10 | 11 | common /ABC/ 12 | 13 | bb: db 1 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/radix.mac: -------------------------------------------------------------------------------- 1 | ; .RADIX test 2 | 3 | .radix 2 4 | db 10 ; 02h 5 | .radix 8 6 | db 10 ; 08h 7 | .radix 10 8 | db 10 ; 0Ah 9 | .radix 16 10 | db 10 ; 10h 11 | .radix 5 ; error 12 | .radix 10 ; default 13 | 14 | end 15 | -------------------------------------------------------------------------------- /test/iftest.mac: -------------------------------------------------------------------------------- 1 | ; IF/ELSE/ENDIF test 2 | 3 | a1 equ 1 4 | a0 equ 0 5 | ; 6 | c1: if a1 7 | l1: db 0 8 | c2: else 9 | l1: dw 0 10 | endif 11 | ; 12 | d1: if a0 13 | l2: db 0 14 | d2: else 15 | l2: dw 0 16 | endif 17 | ; 18 | end 19 | -------------------------------------------------------------------------------- /test/macro3.mac: -------------------------------------------------------------------------------- 1 | test1 macro a,b,c 2 | db a,b,c 3 | endm 4 | 5 | test2 macro a,b 6 | test3 macro c 7 | db c 8 | endm 9 | test3 a 10 | db b 11 | endm 12 | 13 | test1 1,2,3 14 | test2 4,5 15 | test3 6 16 | test2 7,8 17 | 18 | end 19 | -------------------------------------------------------------------------------- /test/macro7.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | test1 macro 4 | db 1 5 | exitm 6 | db 2 7 | endm 8 | 9 | test2 macro 10 | db 10 11 | test1 12 | db 11 13 | exitm 14 | test1 15 | db 12 16 | endm 17 | 18 | test1 19 | 20 | test2 21 | 22 | end 23 | -------------------------------------------------------------------------------- /test/even.mac: -------------------------------------------------------------------------------- 1 | ; .EVEN pseudo-op test (requires that linker loads the module at word boundary) 2 | 3 | db 0 4 | .even 5 | db 0,0 6 | .even 7 | db 0 8 | .even 9 | db 0 10 | .odd 11 | db 0 12 | .odd 13 | db 0,0 14 | .odd 15 | db 0 16 | 17 | end 18 | -------------------------------------------------------------------------------- /test/macro11.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | test1 macro a,b,c 4 | db a,b,c 5 | endm 6 | 7 | test2 macro a,b 8 | test3 macro a 9 | db a 10 | endm 11 | test3 a 12 | db b 13 | endm 14 | 15 | test1 1,2,3 16 | test2 4,5 17 | test3 6 18 | test2 7,8 19 | 20 | end 21 | -------------------------------------------------------------------------------- /test/macro29.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | m macro a 4 | local x 5 | ifb 6 | x: defs 5 7 | endif 8 | endm 9 | 10 | .xall 11 | m 1 12 | m 13 | 14 | .lall 15 | m 1 16 | m 17 | 18 | .sfcond 19 | m 1 20 | m 21 | 22 | .xall 23 | m 1 24 | m 25 | 26 | end 27 | -------------------------------------------------------------------------------- /test/error_check/macro11.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | test1 macro a,b,c 4 | db a,b,c 5 | endm 6 | 7 | test2 macro a,b 8 | test3 macro a 9 | db a 10 | endm 11 | test3 a 12 | db b 13 | endm 14 | 15 | test1 1,2,3 16 | test2 4,5 17 | test3 6 18 | test2 7,8 19 | 20 | end 21 | -------------------------------------------------------------------------------- /test/reltest.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | cseg 3 | a1: ld a,1 4 | a2: ld a,2 5 | a3: ld a,3 6 | dseg 7 | d1: ds 10 8 | d2: ds 10 9 | d3: ds 10 10 | dw d2+d3 11 | dw d2+a2 12 | extrn c1 13 | dw c1+a1 14 | dw c1-a1 15 | dw c1+d1 16 | dw c1-d1 17 | dw a1+d1 18 | dw a1-d1 19 | end 20 |  -------------------------------------------------------------------------------- /test/error_check/local1.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | irpc c,abc 4 | local d ;; error 5 | d aset d+1 6 | db '&c' 7 | endm 8 | 9 | irpc c,abc 10 | m&c macro 11 | local d ;; allowed 12 | d aset d+1 13 | db '&c' 14 | endm 15 | endm 16 | 17 | ma 18 | mb 19 | mc 20 | 21 | end 22 | -------------------------------------------------------------------------------- /test/rept1.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | rept 0 4 | db 0 5 | endm 6 | 7 | rept 10 8 | db 8 ; this comment should appear in the expansion 9 | db 9 ;; but not this one 10 | endm 11 | 12 | rept 2 13 | db 2 14 | rept 5 15 | db 15 ; comment 16 | endm 17 | db 3 18 | endm 19 | 20 | end 21 | -------------------------------------------------------------------------------- /test/common3.mac: -------------------------------------------------------------------------------- 1 | ; COMMON segment switching and referencing test 2 | 3 | cseg 4 | 5 | dw a1 6 | dw a2 7 | dw a3 8 | dw a4 9 | db 0 10 | 11 | common /c1/ 12 | a1:: db 1 13 | 14 | common /c2/ 15 | a2:: db 2 16 | 17 | common /c3/ 18 | a3:: db 3 19 | a4:: db 4 20 | 21 | end a1 22 | -------------------------------------------------------------------------------- /test/error_check/exttest1.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | extrn e1 3 | extrn e4 4 | public p1 5 | ld hl,e1 6 | ld hl,e1## 7 | c1: ld hl,e2## 8 | ld hl,e2 9 | ld hl,e2## 10 | ld hl,e3 11 | ld hl,e3## 12 | ld hl,e3 13 | ld hl,p1 14 | ld hl,p1## 15 | ld hl,c1 16 | ld hl,c1## 17 | ld hl,e5 18 | end 19 | -------------------------------------------------------------------------------- /test/irp.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | irp a,<1,2,3,4,5,6,7,8,9,0> 4 | db a+1 5 | endm 6 | 7 | irp a,<12345> 8 | dw a 9 | endm 10 | 11 | irp a,<12345 6789> 12 | dw a+1 13 | endm 14 | 15 | irp a,<12345,67890> 16 | db '&a' 17 | endm 18 | 19 | irp a,<> ; null arg 20 | db '&a' 21 | endm 22 | 23 | end 24 | -------------------------------------------------------------------------------- /test/macro0.mac: -------------------------------------------------------------------------------- 1 | ; Nested MACRO definitions 2 | 3 | cseg 4 | test1 macro 5 | db 1,2,3 6 | test2 macro 7 | db 4,5,6 8 | endm 9 | db 7,8,9 10 | endm 11 | 12 | test2 13 | test1 14 | test2 15 | test1 16 | 17 | test3 macro 18 | rept 4 19 | db 0 20 | endm 21 | endm 22 | 23 | test3 24 | 25 | end 26 | -------------------------------------------------------------------------------- /test/ldwtest.mac: -------------------------------------------------------------------------------- 1 | .z280 2 | extrn ee 3 | ldw ix,(ix+0) 4 | ldw ix,(ix+ee) 5 | ldw ix,(ix) 6 | ldw ix,(ix+5) 7 | ldw hl,(ix+0) 8 | cc equ 0 9 | ldw ix,(ix+cc) 10 | cpw hl ; ok 11 | cpw hl 12 | ld ix,(ix+0) 13 | ld ix,(ix) 14 | ld a,(ix) 15 | ld ix,(ix) 16 | .z80 17 | ld a,(ix) 18 | ld a,(ix+2) 19 | end 20 | -------------------------------------------------------------------------------- /test/common1.mac: -------------------------------------------------------------------------------- 1 | ; COMMON segment switching test 2 | 3 | common /C1/ 4 | cc: dw aa 5 | aa: dw bb ; reference to variable in /C2/ 6 | dw cc 7 | dw aa 8 | dw aa 9 | dw bb 10 | db 1,2,3,4 11 | dw bb 12 | db 1,2,3,4 13 | ds 5 14 | ds 5 15 | db 1,2,3,4 16 | dw bb,bb,bb 17 | COMMON /C2/ 18 | bb: dw 1234 19 | end 20 | -------------------------------------------------------------------------------- /test/error_check/macro10a.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | test macro a,,b 4 | db a,b 5 | endm 6 | 7 | test 1,2 8 | test 1,,2 9 | test 1,2,3 10 | 11 | test2 macro a,b,c 12 | db '&a' 13 | db '&b' 14 | db '&c' 15 | endm 16 | 17 | test2 1,2,3 18 | test2 1,,3 19 | test2 ,2,3 20 | test2 ,,3 21 | test2 1,, 22 | 23 | end 24 | -------------------------------------------------------------------------------- /test/macro6.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | test macro c 4 | db '&c' 5 | endm 6 | 7 | test1 macro abc 8 | db abc 9 | endm 10 | 11 | test 1 12 | 13 | test a 14 | 15 | test1 2 16 | 17 | test2 macro n 18 | rept n 19 | db 'Hello, world!',0 20 | endm 21 | endm 22 | 23 | test2 1 24 | 25 | test2 5 26 | 27 | end 28 | -------------------------------------------------------------------------------- /test/macro9.mac: -------------------------------------------------------------------------------- 1 | pr macro a 2 | .printx '&a' 3 | endm 4 | 5 | if1 6 | xx set 0 7 | endif 8 | 9 | test 10 | db 10 11 | dd: 12 | pr %dd 13 | 14 | xx set xx+dd 15 | dw xx 16 | 17 | test macro 18 | if2 19 | db 0 20 | endif 21 | endm 22 | 23 | ;pr macro a 24 | ; .printx '&a' 25 | ; endm 26 | 27 | 28 | end 29 | -------------------------------------------------------------------------------- /test/macro22.mac: -------------------------------------------------------------------------------- 1 | list macros 2 | 3 | ; Testing nested < > in macro arguments 4 | 5 | m1 MACRO arg 6 | dw arg 7 | ENDM 8 | 9 | m2 MACRO arg 10 | m1 arg 11 | ENDM 12 | 13 | m1 100 ; OK 14 | 15 | m2 100 ; OK 16 | 17 | m2 <100> ; OK 18 | 19 | m1 <100h OR 20h> ; OK 20 | 21 | m2 <<100h OR 20h>> ; OK 22 | 23 | end 24 | -------------------------------------------------------------------------------- /test/macro16.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | n1 defl 1 4 | n2 equ 1234 5 | 6 | test macro a,b,c 7 | n1 defl n1+1 8 | db '&a' ; this comment should appear in the expansion 9 | db '&b' ;; but not this one 10 | L&c: db '&c' 11 | db n1 12 | endm 13 | 14 | test n2,456,789 15 | 16 | test %n2,!%n2,456 17 | 18 | test ,%n1,A 19 | 20 | end 21 | -------------------------------------------------------------------------------- /test/macro1a.mac: -------------------------------------------------------------------------------- 1 | test1 macro a,b,c 2 | aa defl 5 3 | db a,b,c 4 | endm 5 | test2 macro a, b, c 6 | db a,b,c,aa 7 | endm 8 | test3 macro a, b, c ; d 9 | db a,b,c;d 10 | db a, b, c ;d 11 | endm 12 | test1 1,2,3 13 | test1 1, 2, 3 14 | test2 1,2,3 15 | test2 1, 2, 3 16 | test3 1,2,3 17 | test3 1,2,3,4 18 | test3 1,2,3;4 19 | test3 1,2,3 ;4 20 | end 21 | -------------------------------------------------------------------------------- /test/local2.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | test1 macro 4 | local l1 5 | ifndef l1 6 | l1 defl 0 7 | else 8 | l1 defl l1+1 9 | endif 10 | dw l1 11 | test2 macro 12 | local l2 13 | ifndef l2 14 | l2 defl 0 15 | else 16 | l2 defl l2+1 17 | endif 18 | dw l1,l2 19 | endm 20 | l1 defl l1+1 21 | dw l1 22 | endm 23 | 24 | test1 25 | 26 | test2 27 | test2 28 | 29 | end 30 | -------------------------------------------------------------------------------- /test/test3.mac: -------------------------------------------------------------------------------- 1 | equ 0 2 | 3 | ld 4 | add 5 | add a, 6 | sub 7 | or 8 | and 9 | xor 10 | 11 | if 12 | endif 13 | 14 | macro 15 | endm 16 | 17 | equ 10h 18 | 19 | aa defl 5 20 | equ 6 21 | 22 | defl 23 | equ 24 | 25 | dd defl 26 | ee equ 27 | 28 | mm: macro 29 | db 1 30 | endm 31 | 32 | bb: 33 | : 34 | 35 | mm 36 | 37 | mm: 38 | 39 | end 40 | -------------------------------------------------------------------------------- /test/local.mac: -------------------------------------------------------------------------------- 1 | ; LOCAL variables in MACROs 2 | 3 | cseg 4 | 5 | ltest macro a,b,c 6 | local x,y,z 7 | x:: db a 8 | y:: db b 9 | dw x 10 | endm 11 | 12 | ltest2 macro a,b,c 13 | local x 14 | local y 15 | local z 16 | x: db a 17 | y: db b 18 | dw x 19 | endm 20 | 21 | ltest 1,2,3 22 | ltest 4,5,6 23 | ltest 7,8,9 24 | 25 | ltest2 10,11,12 26 | ltest2 20,21,22 27 | 28 | end 29 | -------------------------------------------------------------------------------- /test/else.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | 3 | if 1 4 | db 1 5 | else 6 | db 2 7 | else ; 'C' error 8 | db 3 9 | endif 10 | 11 | if 0 12 | db 1 13 | else 14 | db 2 15 | else ; 'C' error 16 | db 3 17 | endif 18 | 19 | if 0 20 | if 1 21 | db 1 22 | else 23 | db 2 24 | else ; no error 25 | db 3 26 | endif 27 | endif 28 | 29 | else ; 'C' error 30 | 31 | if 1 32 | 33 | end ; 'T' error 34 | -------------------------------------------------------------------------------- /test/cputest.mac: -------------------------------------------------------------------------------- 1 | cputest macro 2 | ifz80 3 | if2 4 | .printx 'CPU is Z80' 5 | endif 6 | db 0 7 | endif 8 | ifz180 9 | if2 10 | .printx 'CPU is Z180' 11 | endif 12 | db 1 13 | endif 14 | ifz280 15 | if2 16 | .printx 'CPU is Z280' 17 | endif 18 | db 2 19 | endif 20 | endm 21 | 22 | cputest ; default is Z80 23 | .z80 24 | cputest 25 | .z180 26 | cputest 27 | .z280 28 | cputest 29 | .z80 30 | cputest 31 | 32 | end 33 | -------------------------------------------------------------------------------- /test/iext.mac: -------------------------------------------------------------------------------- 1 | ; Implicit external test, assemble with /U option 2 | 3 | cseg 4 | 5 | test:: ld de,str 6 | ld c,9 7 | call bdos ; implicit external 8 | ld e,0Dh 9 | ld c,2 10 | call bdos ; implicit external 11 | ld e,lf ; implicit external? 12 | ld c,2 13 | call bdos ; implicit external 14 | jp wboot ; implicit external 15 | 16 | dseg 17 | 18 | str: db 'test$' 19 | dw bdos ; implicit external 20 | 21 | end 22 | -------------------------------------------------------------------------------- /test/macro13.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | m1 macro 4 | db 'abcdefghijklmnopqrstuvwxyz' 5 | endm 6 | 7 | m2 macro 8 | m1 9 | db '0123456789' ;cccccccccccccccccccccccccccccccc 10 | endm 11 | 12 | m3 macro 13 | m2 14 | dw 1,2,3,4,5 ;wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww 15 | dw 6,7,8,9,0 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 16 | endm 17 | 18 | m macro 19 | m3 ;m3m3m3m3m3m3m3m3m3m3m3m3m3m3m3m3 20 | endm 21 | 22 | m 23 | 24 | end 25 | -------------------------------------------------------------------------------- /test/error_check/macro13.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | m1 macro a b 4 | db 'abcdefghijklmnopqrstuvwxyz' 5 | endm 6 | 7 | m2 macro 8 | m1 9 | db '0123456789' ;cccccccccccccccccccccccccccccccc 10 | endm 11 | 12 | m3 macro 13 | m2 14 | dw 1,2,3,4,5 ;wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww 15 | dw 6,7,8,9,0 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 16 | endm 17 | 18 | m macro 19 | m3 ;m3m3m3m3m3m3m3m3m3m3m3m3m3m3m3m3 20 | endm 21 | 22 | m 23 | 24 | end 25 | -------------------------------------------------------------------------------- /test/error_check/macro22.mac: -------------------------------------------------------------------------------- 1 | list macros 2 | 3 | ; Testing nested < > in macro arguments 4 | 5 | m1 MACRO arg 6 | dw arg 7 | ENDM 8 | 9 | m2 MACRO arg 10 | m1 arg 11 | ENDM 12 | 13 | m1 100 ; OK 14 | 15 | m2 100 ; OK 16 | 17 | m2 <100> ; OK 18 | 19 | m1 100h OR 20h ; error 20 | 21 | m1 <100h OR 20h> ; OK 22 | 23 | m2 100h OR 20h ; error 24 | 25 | m2 <100h OR 20h> ; error 26 | 27 | m2 <<100h OR 20h>> ; OK 28 | 29 | end 30 | -------------------------------------------------------------------------------- /test/segtest.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | db 1,2,3 3 | db 4,5,6 4 | db 7,8,9 5 | dseg 6 | db 10h,11h,12h,13h,14h 7 | aseg 8 | db -1,-2,-3,-4 9 | dseg 10 | d1: db 10,11,12 11 | cseg 12 | c1: db 15h,16h,17h,18h,19h 13 | aseg 14 | db -5,-6,-7,-8 15 | .z280 16 | cseg 17 | extrn e1,e2 18 | ldw ,d1 19 | ldw (c1),d1 20 | ldw ,c1 21 | ldw (d1),c1 22 | ldw ,c1 23 | ldw (e1),d1 24 | ldw ,e1 25 | ldw (c1),e1 26 | ldw ,e2 27 | ldw (e1),e2 28 | end 1234h 29 | -------------------------------------------------------------------------------- /test/macro17.mac: -------------------------------------------------------------------------------- 1 | ; .LALL/.SALL/.XALL + .LIST/.XLIST test 2 | 3 | .xlist 4 | include QIO.INC 5 | .list 6 | 7 | lun equ 1 8 | efn equ 3 9 | 10 | test macro 11 | db 'abcdefghijk',0,0,0,0,0,0,0,0,0 12 | ds 140 13 | endm 14 | 15 | .lall 16 | QIOW$ IO.RLB,lun,efn,iosb,, 17 | test 18 | .sall 19 | QIOW$ IO.RLB,lun,efn,iosb,, 20 | test 21 | .xall 22 | QIOW$ IO.RLB,lun,efn,iosb,, 23 | test 24 | 25 | iosb: ds 4 26 | buf: ds 512 27 | 28 | end 29 | -------------------------------------------------------------------------------- /test/expr2.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | a1 equ 1234h ; 1234 4 | 5 | b1 equ low a1 ; 0034 6 | b2 equ high a1 ; 0012 7 | 8 | c1 equ low(a1) ; 0034 9 | c2 equ low(a1)+1000h ; 1034 10 | c3 equ low(a1+1000h) ; 0034 11 | 12 | a2 equ low a1 + 1000h ; 1034 13 | a3 equ high a1 + 1000h ; 1012 14 | a4 equ 1000h + low a1 ; 1034 15 | a5 equ 1000h + high a1 ; 1012 16 | 17 | a8 equ not a1 ; EDCB 18 | 19 | a10 equ low a1 or high a1 shl 8 ; 1234 20 | 21 | a11 equ 1 shl 1 + 1 ; 0003 22 | 23 | end 24 | -------------------------------------------------------------------------------- /test/irpc.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | irpc a,1234567890 4 | db a+1 5 | endm 6 | 7 | irpc a,<123456> 8 | db a 9 | endm 10 | 11 | irpc a,<12345,67890> ; expansion must include the comma 12 | db '&a' 13 | endm 14 | 15 | irpc a,<> ; null arg is permissible 16 | db '&a' 17 | endm 18 | 19 | irpc a,12345678 20 | db a+1 ; this comment should appear in the expansion 21 | db a+2 ;; but not this one 22 | endm 23 | 24 | irpc a,<12<3>> ; nested <>s 25 | db '&a' 26 | endm 27 | 28 | end 29 | -------------------------------------------------------------------------------- /test/macro3a.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | test1 macro a,b,c 4 | db a,b,c 5 | endm 6 | 7 | test2 macro a,b 8 | test3 macro c 9 | db c 10 | endm 11 | test3 a 12 | db b 13 | dw &w ; this comment should appear in the expansion 14 | dw '&w' ;; but not this one 15 | dw &b 16 | dw '&b' 17 | dw ab 18 | dw &01 19 | L&b: dw 'b' 20 | endm 21 | 22 | xx equ 1234 23 | 24 | test1 1,2,3 25 | test2 4,5 26 | test3 6 27 | test2 7,8 28 | 29 | test3 %xx 30 | test2 %xx,<%yy,xx,!%yy> 31 | 32 | end 33 | -------------------------------------------------------------------------------- /test/macro26.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | L1 equ $ 4 | 5 | V1 equ 1 6 | V2 equ 2 7 | V3 equ 3 8 | 9 | extrn E1 10 | 11 | test macro val 12 | db '&val' 13 | endm 14 | 15 | test2 macro val1,val2 16 | db '&val1,&val2' 17 | endm 18 | 19 | test 1 ; db '1' 20 | test L1 ; db 'L1' 21 | test %V1+V2 ; db '3' 22 | test %(V1+V2) ; db '3' 23 | 24 | test2 1,2 ; db '1,2' 25 | test2 L1,V1 ; db 'L1,V1' 26 | test2 %V1+V2,%V2*V3 ; db '3,6' 27 | test2 %(V1+V2),%(V3%V2) ; db '3,1' 28 | 29 | end 30 | -------------------------------------------------------------------------------- /test/error_check/macro3a.mac: -------------------------------------------------------------------------------- 1 | .lall 2 | 3 | test1 macro a,b,c 4 | db a,b,c 5 | endm 6 | 7 | test2 macro a,b 8 | test3 macro c 9 | db c 10 | endm 11 | test3 a 12 | db b 13 | dw &w ; this comment should appear in the expansion 14 | dw '&w' ;; but not this one 15 | dw &b 16 | dw '&b' 17 | dw ab 18 | dw &01 19 | L&b: dw 'b' 20 | endm 21 | 22 | xx equ 1234 23 | 24 | test1 1,2,3 25 | test2 4,5 26 | test3 6 27 | test2 7,8 28 | 29 | test3 %xx 30 | test2 %xx,<%yy,xx,!%yy> 31 | 32 | end 33 | -------------------------------------------------------------------------------- /test/error_check/irp.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | irp a,<1,2,3,4,5,6,7,8,9,0> 4 | db a+1 5 | endm 6 | 7 | irp a,<12345> 8 | dw a 9 | endm 10 | 11 | irp a,<12345 6789> 12 | dw a+1 13 | endm 14 | 15 | irp a,<12345,67890> 16 | db '&a' 17 | endm 18 | 19 | irp a,12345,6789 ; error, <> required 20 | dw a+1 21 | endm 22 | 23 | irp a,12345 ; error, <> required 24 | dw a+1 25 | endm 26 | 27 | irp a ; error, no arg 28 | db a 29 | endm 30 | 31 | irp a,<> ; null arg 32 | db '&a' 33 | endm 34 | 35 | end 36 | -------------------------------------------------------------------------------- /test/test4.mac: -------------------------------------------------------------------------------- 1 | .xlist 2 | 3 | ld a,1 4 | 5 | .list 6 | 7 | ld a,5 8 | stc 9 | ret 10 | 11 | if 1 12 | a equ 1 13 | else 14 | a equ 2 15 | endif 16 | 17 | if 0 18 | b equ 1 19 | else 20 | b equ 2 21 | else 22 | b equ 3 23 | endif 24 | 25 | tta macro a 26 | db a 27 | endm 28 | tt1 macro 29 | db 1 30 | endm 31 | 32 | cc 33 | equ 8 34 | dd: 35 | equ 9 36 | 37 | dd1: ld hl,dd1 38 | dd2 ld hl,dd2 39 | dd3: 40 | ld hl,dd3 41 | dd4 42 | ld hl,dd4 43 | 44 | tta 1 45 | tt1 46 | 47 | ee1 tt1 48 | ee2: tt1 49 | 50 | end 51 | -------------------------------------------------------------------------------- /test/irp1.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | irp a,<1,2,3,4,5,6,7,8,9,0> 4 | db a+1 5 | endm 6 | 7 | irp a,<123456> 8 | db '&a' 9 | endm 10 | 11 | irp a,<12345 67890> 12 | db '&a' 13 | endm 14 | 15 | irp a,<12345,67890> 16 | db '&a' 17 | endm 18 | 19 | irp a,<> ; null arg is permissible 20 | db '&a' 21 | endm 22 | 23 | irp a,<1,,2> 24 | db '&a' 25 | endm 26 | 27 | irp a,<1,2,3,4,5,6,7,8> 28 | db a+1 ; this comment should appear in the expansion 29 | db a+2 ;; but not this one 30 | endm 31 | 32 | irp a,<1,<,2,>,> 33 | db '&a' 34 | endm 35 | 36 | end 37 | -------------------------------------------------------------------------------- /test/ifbnb.mac: -------------------------------------------------------------------------------- 1 | ; IFB/IFNB conditional test 2 | 3 | cseg 4 | 5 | isblank macro str 6 | ifb <&str> 7 | .printx '<&str> is blank' 8 | else 9 | .printx '<&str> is not blank' 10 | endif 11 | ifnb <&str> 12 | .printx '<&str> is not blank' 13 | else 14 | .printx '<&str> is blank' 15 | endif 16 | endm 17 | 18 | ifb <> 19 | db 1 20 | endif 21 | 22 | ifnb <> 23 | db 1 24 | endif 25 | 26 | ifb 27 | db 1 28 | endif 29 | 30 | ifnb 31 | db 1 32 | endif 33 | 34 | isblank 35 | isblank ; is blank 36 | isblank a 37 | isblank a ; is not blank 38 | isblank 39 | 40 | end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [ZSM 4.6](http://p112.sourceforge.net/index.php?zsm4), a Z80/Z180/Z280 Macro Assembler 2 | 3 | ZSM 4.6 is a macro-assembler for the Z80, Z180 and Z280 microprocessors. 4 | It uses standard Zilog/Mostek mnemonics, supports conditional assembly and 5 | produces a REL file suitable for linking with Microsoft's L80 or Digital 6 | Research's LINK. ZSM 4.6 is a disk based assembler, i.e. source code is 7 | read from disk, the resulting object code is written to disk and an optional 8 | print file can be written to disk. Alternatively the print file can be 9 | redirected to the console or to the printer. 10 | 11 | See the full documentation in the docs directory. 12 | 13 | -------------------------------------------------------------------------------- /test/error_check/expr2.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | a1 equ 1234h ; 1234 4 | 5 | b1 equ low a1 ; 0034 6 | b2 equ high a1 ; 0012 7 | 8 | c1 equ low(a1) ; 0034 9 | c2 equ low(a1)+1000h ; 1034 10 | c3 equ low(a1+1000h) ; 0034 11 | 12 | a2 equ low a1 + 1000h ; 1034 13 | a3 equ high a1 + 1000h ; 1012 14 | a4 equ 1000h + low a1 ; 1034 15 | a5 equ 1000h + high a1 ; 1012 16 | 17 | a6 equ a1 + low ; error 18 | a7 equ a1 low ; error 19 | 20 | a8 equ not a1 ; EDCB 21 | a9 equ a1 not ; error 22 | 23 | a10 equ low a1 or high a1 shl 8 ; 1234 24 | 25 | a11 equ 1 shl 1 + 1 ; 0003 26 | 27 | a12 equ 2 + ; error 28 | 29 | a13 equ 1 low 2 ; error 30 | 31 | end 32 | -------------------------------------------------------------------------------- /test/iferrc.mac: -------------------------------------------------------------------------------- 1 | ; Test of IF error code not appearing on error line 2 | 3 | a equ 1 4 | z equ 0 5 | 6 | IF a 7 | ld a,1 8 | ELSE 9 | ld a,2 10 | ENDIF 11 | 12 | IF b ; 'U' error 13 | ld a,1 14 | ELSE 15 | ld a,2 16 | ENDIF 17 | 18 | IF a 19 | IF b ; 'U' error 20 | ld a,1 21 | ELSE 22 | ld a,2 23 | ENDIF 24 | ENDIF 25 | 26 | IF b ; 'U' error 27 | IF a 28 | ld a,1 29 | ELSE 30 | ld a,2 31 | ENDIF 32 | ENDIF 33 | 34 | IF b ; 'U' error 35 | IF b ; no 'U' error 36 | ld a,1 37 | ELSE 38 | ld a,2 39 | ENDIF 40 | ENDIF 41 | 42 | IF z 43 | IF b ; no 'U' error 44 | ld a,1 45 | ELSE 46 | ld a,2 47 | ENDIF 48 | ENDIF 49 | 50 | END 51 | -------------------------------------------------------------------------------- /test/ifidndif.mac: -------------------------------------------------------------------------------- 1 | ; IFIDN/IFDIF conditional test 2 | 3 | .z80 4 | 5 | list nocond,macros 6 | 7 | val equ 1234 8 | 9 | streq macro s1,s2 10 | ifidn , 11 | .printx "<&s1> and <&s2> are identical" 12 | else 13 | .printx "<&s1> and <&s2> are different" 14 | endif 15 | ifdif , 16 | .printx "<&s1> and <&s2> are different" 17 | else 18 | .printx "<&s1> and <&s2> are identical" 19 | endif 20 | endm 21 | 22 | streq 1,2 23 | streq ,a 24 | streq a, 25 | streq 123456,123456 26 | streq ,aa ; different 27 | streq aa, ; different 28 | streq 123456,123456 ; identical 29 | streq , 30 | streq , ; identical 31 | streq 'abc','abc' 32 | streq %val,%val 33 | 34 | end 35 | 36 | -------------------------------------------------------------------------------- /test/error_check/irpc.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | irpc a,1234567890 4 | db a+1 5 | endm 6 | 7 | irpc a,<123456> 8 | db a 9 | endm 10 | 11 | irpc a,12345 67890 ; error - extra arg 67890 ignored 12 | db a+1 13 | endm 14 | 15 | irpc a,12345,67890 ; error - extra arg 67890 ignored 16 | db a+1 17 | endm 18 | 19 | irpc a,<12345,67890> ; expansion must include the comma 20 | db '&a' 21 | endm 22 | 23 | irpc a ; error - no arg 24 | db '&a' 25 | endm 26 | 27 | irpc a,<> ; null arg is permissible 28 | db '&a' 29 | endm 30 | 31 | irpc a,12345678 32 | db a+1 ; this comment should appear in the expansion 33 | db a+2 ;; but not this one 34 | endm 35 | 36 | irpc a,<12<3>> ; nested <>s 37 | db '&a' 38 | endm 39 | 40 | end 41 | -------------------------------------------------------------------------------- /test/cconst.mac: -------------------------------------------------------------------------------- 1 | ; Character constant test 2 | 3 | .z80 4 | 5 | db 1,'abc',2,'a'+1,5 6 | db 'ab' 7 | 8 | db 'a' ; 61 9 | db 'a'+1 ; 62 10 | 11 | dw 'ab' ; 61 62 12 | dw 'ab'+1 ; 61 63 13 | 14 | dw 'a' ; 61 00 15 | dw 'a'+1 ; 62 00 16 | 17 | db '''' ; 27 18 | db ''''+1 ; 28 19 | 20 | dw '''a' ; 27 61 21 | dw 'a''' ; 61 27 22 | 23 | dw '''a'+1 ; 27 62 24 | dw 'a'''+1 ; 61 28 25 | 26 | ld a,'''' ; 27 27 | ld a,''''+1 ; 28 28 | 29 | ld hl,'''a' ; 27 61 30 | ld hl,'''a'+1 ; 27 62 31 | ld hl,'a''' ; 61 27 32 | ld hl,'a'''+1 ; 61 28 33 | 34 | db '' 35 | ld a,'' 36 | ld a,'' ; 3E 00 37 | ld a,'''' 38 | 39 | ld hl,'''''' ; 21 27 27 40 | ld hl,'''''' 41 | 42 | db 'a' 43 | db 'a'+1 44 | 45 | dw 'ab' 46 | dw 'ab'+1 47 | 48 | end 49 | -------------------------------------------------------------------------------- /test/error_check/macro26.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | L1 equ $ 4 | 5 | V1 equ 1 6 | V2 equ 2 7 | V3 equ 3 8 | 9 | extrn E1 10 | 11 | test macro val 12 | db '&val' 13 | endm 14 | 15 | test2 macro val1,val2 16 | db '&val1,&val2' 17 | endm 18 | 19 | test 1 ; db '1' 20 | test L1 ; db 'L1' 21 | test %L1 ; R error, db '0000' 22 | test %E1 ; R error, db '0000' 23 | test %U1 ; U error, db '0000' 24 | test %V1+V2 ; db '3' 25 | test %(V1+V2) ; db '3' 26 | test %(L1+V2) ; R error 27 | 28 | test2 1,2 ; db '1' 29 | test2 L1,V1 ; db 'L1' 30 | test2 %L1,%V1 ; R error, db '0000' 31 | test2 %E1,%V1+%V2 ; R error, db '0000' 32 | test2 %U1,V1 ; U error, db '0000' 33 | test2 %V1+V2,%V2*V3 ; db '3' 34 | test2 %(V1+V2),%(V3%V2) ; db '3' 35 | test2 %(L1+V2),%(LOW V3) ; R error 36 | 37 | end 38 | -------------------------------------------------------------------------------- /test/error_check/irp1.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | irp a,<1,2,3,4,5,6,7,8,9,0> 4 | db a+1 5 | endm 6 | 7 | irp a,<123456> 8 | db '&a' 9 | endm 10 | 11 | irp a,<12345 67890> 12 | db '&a' 13 | endm 14 | 15 | irp a,<12345,67890> 16 | db '&a' 17 | endm 18 | 19 | irp a,12345,67890 ; error - angle brackets missing 20 | db '&a' 21 | endm 22 | 23 | irp a,123456 ; error - angle brackets missing 24 | db '&a' 25 | endm 26 | 27 | irp a ; error - arg missing 28 | db a 29 | endm 30 | 31 | irp a,<> ; null arg is permissible 32 | db '&a' 33 | endm 34 | 35 | irp a,<1,,2> 36 | db '&a' 37 | endm 38 | 39 | irp a,<1,2,3,4,5,6,7,8> 40 | db a+1 ; this comment should appear in the expansion 41 | db a+2 ;; but not this one 42 | endm 43 | 44 | irp a,<1,<,2,>,> 45 | db '&a' 46 | endm 47 | 48 | end 49 | -------------------------------------------------------------------------------- /test/lesstest.mac: -------------------------------------------------------------------------------- 1 | tstless macro a,b 2 | if1 3 | if a less b 4 | .printx /a less b/ 5 | else 6 | .printx /b less= a/ 7 | endif 8 | if a lt b 9 | .printx /a lt b/ 10 | else 11 | .printx /b le a/ 12 | endif 13 | endif 14 | endm 15 | 16 | tstless -32768,-32767 17 | tstless -30000,-1000 18 | tstless -1000,-10 19 | tstless -10,0 20 | tstless -10,-1 21 | tstless -10,10 22 | tstless -10,32767 23 | tstless -10000,-10001 24 | tstless -10001,-10000 25 | tstless -10000,10000 26 | tstless 1234,1235 27 | tstless -10001,-10000 28 | tstless -10000,-10001 29 | tstless 10000,-10000 30 | tstless 1235,1234 31 | tstless -1000,1000 32 | tstless 1000,-1000 33 | tstless -1,-1 34 | tstless -256,-256 35 | tstless 1,1 36 | tstless 256,256 37 | tstless 0,0 38 | tstless -32767,-32767 39 | tstless -32768,-32768 40 | tstless 32768,32768 41 | 42 | end 43 | -------------------------------------------------------------------------------- /test/ifdef.mac: -------------------------------------------------------------------------------- 1 | ; IFDEF/IFNDEF conditional test 2 | 3 | abc equ 1 4 | 5 | extrn def 6 | 7 | ifdef abc 8 | db 1 ; yes 9 | endif 10 | 11 | ifdef def 12 | db 1 ; no 13 | endif 14 | 15 | ifdef ghi 16 | db 1 ; no 17 | endif 18 | 19 | ifndef abc 20 | db 1 ; no 21 | endif 22 | 23 | ifndef def 24 | db 1 ; yes 25 | endif 26 | 27 | ifndef ghi 28 | db 1 ; yes 29 | endif 30 | 31 | ifdef abc 32 | db 1 ; yes 33 | else 34 | db 1 ; no 35 | endif 36 | 37 | ifdef def 38 | db 1 ; no 39 | else 40 | db 1 ; yes 41 | endif 42 | 43 | ifdef ghi 44 | db 1 ; no 45 | else 46 | db 1 ; yes 47 | endif 48 | 49 | ifndef abc 50 | db 1 ; no 51 | else 52 | db 1 ; yes 53 | endif 54 | 55 | ifndef def 56 | db 1 ; yes 57 | else 58 | db 1 ; no 59 | endif 60 | 61 | ifndef ghi 62 | db 1 ; yes 63 | else 64 | db 1 ; no 65 | endif 66 | 67 | end 68 | -------------------------------------------------------------------------------- /test/expr.mac: -------------------------------------------------------------------------------- 1 | ; Expression test 2 | 3 | ; Result: old new 4 | ; ZSM 2.8 ZSM 4.0 5 | ; ------- ------- 6 | 7 | a1 equ 1+2*3 ; 9 7 8 | a2 equ -2 ; -2 -2 9 | a3 equ +2 ; 2 2 10 | a4 equ 3*-2 ; 1 -6 11 | a5 equ 3*+2 ; 5 6 12 | 13 | ld a,(ix+5) ; 5 5 14 | ld a,(ix-5) ; -5 -5 15 | 16 | a6 equ not 2 ; -3 -3 17 | a7 equ 1 + not 2 ; 2+error -2 18 | a8 equ 1 + not 2 + 3 ; 5+error -5 19 | a9 equ 1 + (not 2) + 3 ; error 1 20 | 21 | x equ 5 22 | y equ 6 23 | z equ 7 24 | 25 | a10 equ x + y * z ; 77 47 26 | a11 equ x * y + z ; 37 37 27 | 28 | a12 equ 1 gt 2 ; 0 0 29 | a13 equ 1 lt 2 ; -1 -1 30 | 31 | ld a,(hl) 32 | ld a,(ix+(5+1)) ; error 6 33 | 34 | ld a,(5) 35 | a14 equ (5) 36 | 37 | a15 equ 1 shl 5 38 | a16 equ 8000h shr 5 39 | 40 | a17 equ (1 shl 2) or (1 shl 3) 41 | 42 | end 43 | -------------------------------------------------------------------------------- /test/error_check/cconst.mac: -------------------------------------------------------------------------------- 1 | ; Character constant test 2 | 3 | .z80 4 | 5 | db 1,'abc',2,'a'+1,5 6 | db 'ab' 7 | 8 | db 'a' ; 61 9 | db 'a'+1 ; 62 10 | db 'ab'+1 ; A error 11 | db 'abc'+1 ; O error 12 | 13 | dw 'ab' ; 61 62 14 | dw 'ab'+1 ; 61 63 15 | 16 | dw 'a' ; 61 00 17 | dw 'a'+1 ; 62 00 18 | dw 'abcd'+1 ; O error 19 | 20 | db '''' ; 27 21 | db ''''+1 ; 28 22 | 23 | dw '''a' ; 27 61 24 | dw 'a''' ; 61 27 25 | 26 | dw '''a'+1 ; 27 62 27 | dw 'a'''+1 ; 61 28 28 | 29 | ld a,'''' ; 27 30 | ld a,''''+1 ; 28 31 | 32 | ld hl,'''a' ; 27 61 33 | ld hl,'''a'+1 ; 27 62 34 | ld hl,'a''' ; 61 27 35 | ld hl,'a'''+1 ; 61 28 36 | 37 | ld a,''aa' 38 | ld a,'a'' 39 | 40 | db '' 41 | ld a,'' 42 | ld a,'' ; 3E 00 43 | ld a,'''' 44 | 45 | ld hl,'''''' ; 21 27 27 46 | ld hl,'''''' 47 | 48 | db 'a' 49 | db 'a'+1 50 | 51 | dw 'ab' 52 | dw 'ab'+1 53 | 54 | db 'ab'+1 55 | db 'abc'+1 56 | 57 | dw 'abcd'+1 58 | 59 | end 60 | -------------------------------------------------------------------------------- /test/nultest.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | if 1 4 | list nocond,macros 5 | else 6 | .lfcond 7 | .lall 8 | endif 9 | 10 | test macro arg1,arg2 11 | if2 12 | if nul arg1 13 | .printx 'arg1 is null' 14 | endif 15 | if nul arg2 16 | .printx 'arg2 is null' 17 | endif 18 | endif 19 | endm 20 | 21 | test2 macro arg1,arg2 22 | if2 23 | .printx 'arg1=&arg1, arg2=&arg2' 24 | if arg1 and not nul arg2 25 | .printx 'arg1<>0 and arg2 is not null' 26 | endif 27 | .printx '' 28 | endif 29 | endm 30 | 31 | test 32 | test , 33 | test 1 34 | test 1,2 35 | test ,2 36 | test 1, 37 | test <>,2 38 | test 1,<> 39 | 40 | test ; comment 41 | test , ; comment 42 | test 1 ; comment 43 | test 1,2 ; comment 44 | test ,2 ; comment 45 | test 1, ; comment 46 | test <>,2 ; comment 47 | test 1,<> ; comment 48 | 49 | test2 0 50 | test2 1 51 | test2 0,2 52 | test2 1,2 53 | test2 0,<> 54 | test2 1,<> 55 | test2 0, 56 | test2 1, 57 | 58 | test2 ; error 59 | 60 | end 61 | -------------------------------------------------------------------------------- /test/macro25.mac: -------------------------------------------------------------------------------- 1 | CSEG 2 | 3 | ; SAMPLE PROGRAM SHOWING RECURSIVE MACROS 4 | 5 | BDOS EQU 0005h ;ENTRY TO BDOS 6 | CONOUT EQU 2 ;CONSOLE CHARACTER OUT 7 | MSGOUT EQU 9 ;PRINT MESSAGE 'TIL $ 8 | CR EQU 0Dh ;CARRIAGE RETURN 9 | LF EQU 0Ah ;LINE FEED 10 | 11 | WCHAR MACRO CHR 12 | ;WRITE THE CHARACTER CHR TO CONSOLE 13 | CBDOS CONOUT,CHR ;;CALL BDOS 14 | ENDM 15 | 16 | CBDOS MACRO FUNC,INFO 17 | ;GENERAL PURPOSE BDOS CALL MACRO 18 | ;FUNC IS THE FUNCTION NUMBER, 19 | ;INFO IS THE INFORMATION ADDRESS OR NUL 20 | ;CHECK FOR FUNCTION 9, SEND CRLF FIRST IF SO 21 | IFIDN , 22 | ;PRINT CRLF FIRST 23 | WCHAR CR 24 | WCHAR LF 25 | ENDIF 26 | ;NOW PERFORM THE FUNCTION 27 | LD C,FUNC 28 | ;INCLUDE LD TO DE IF INFO NOT EMPTY 29 | IFNB 30 | LD DE,INFO 31 | ENDIF 32 | CALL BDOS 33 | ENDM 34 | 35 | WCHAR 'h' ;SEND "H" TO CONSOLE 36 | WCHAR 'i' ;SEND "I" TO CONSOLE 37 | CBDOS MSGOUT,MSGADDR ;SEND MESSAGE 38 | RET ;TERMINATE PROGRAM 39 | 40 | MSGADDR: 41 | DB ' and lois$' 42 | 43 | END 44 | -------------------------------------------------------------------------------- /test/error_check/expr.mac: -------------------------------------------------------------------------------- 1 | ; Expression test 2 | 3 | ; Result: old new 4 | ; ZSM 2.8 ZSM 4.0 5 | ; ------- ------- 6 | 7 | a1 equ 1+2*3 ; 9 7 8 | a2 equ -2 ; -2 -2 9 | a3 equ +2 ; 2 2 10 | a4 equ 3*-2 ; 1 -6 11 | a5 equ 3*+2 ; 5 6 12 | 13 | ld a,(ix+5) ; 5 5 14 | ld a,(ix-5) ; -5 -5 15 | 16 | a6 equ not 2 ; -3 -3 17 | a7 equ 1 + not 2 ; 2+error -2 18 | a8 equ 1 + not 2 + 3 ; 5+error -5 19 | a9 equ 1 + (not 2) + 3 ; error 1 20 | 21 | x equ 5 22 | y equ 6 23 | z equ 7 24 | 25 | a10 equ x + y * z ; 77 47 26 | a11 equ x * y + z ; 37 37 27 | 28 | a12 equ 1 gt 2 ; 0 0 29 | a13 equ 1 lt 2 ; -1 -1 30 | 31 | ld a,(hl) 32 | ld a,(ix+(5+1)) ; error 6 33 | 34 | ld a,(5) 35 | a14 equ (5) 36 | 37 | a15 equ 1 shl 5 38 | a16 equ 8000h shr 5 39 | 40 | a17 equ (1 shl 2) or (1 shl 3) 41 | 42 | ; Errors: 43 | 44 | e1 equ (x+y 45 | e2 equ x+y) 46 | 47 | end 48 | -------------------------------------------------------------------------------- /fcslib.inc: -------------------------------------------------------------------------------- 1 | ; Structure used by file I/O functions 2 | 3 | FC.FDB equ 0 ; FDB address (2 bytes) 4 | FC.MODE equ FC.FDB + 2 ; access mode and status bits (1 byte) 5 | FC.LUN equ FC.MODE + 1 ; LUN (1 byte) 6 | FC.EFN equ FC.LUN + 1 ; event flag number (1 byte) 7 | FC.BUF equ FC.EFN + 1 ; I/O buffer address (2 bytes) 8 | FC.CNT equ FC.BUF + 2 ; chars in buffer (2 bytes) 9 | FC.CUR equ FC.CNT + 2 ; index of current char in buffer (2 bytes) 10 | FC.BLK equ FC.CUR + 2 ; current block number in buffer (4 bytes) 11 | 12 | FCSIZ equ FC.BLK + 4 ; size of the above structure 13 | 14 | ; Mode bits 15 | 16 | FM.RD equ 0 ; open for read 17 | FM.WR equ 1 ; open for write 18 | FM.WA equ 2 ; open for append 19 | FM.DV equ 3 ; device mode (not a file) 20 | FM.TT equ 4 ; device is a terminal 21 | 22 | ; Status bits 23 | 24 | FS.BV equ 5 ; buffer contains valid data 25 | FS.BM equ 6 ; buffer modified (write pending) 26 | 27 | ; Macro to generate a storage region for file I/O 28 | 29 | FSR$ MACRO fdb,mode,lun,efn,buf 30 | local lfdb,lbuf 31 | ifnb 32 | dw fdb 33 | else 34 | dw lfdb 35 | endif 36 | db mode,lun,efn 37 | ifnb 38 | dw buf 39 | else 40 | dw lbuf 41 | endif 42 | dw 0,0,0,0 43 | ifb 44 | lfdb: ds FINFSZ 45 | endif 46 | ifb 47 | lbuf: ds 512 48 | endif 49 | ENDM 50 | 51 | -------------------------------------------------------------------------------- /test/macro24.mac: -------------------------------------------------------------------------------- 1 | CSEG 2 | 3 | MOVE MACRO SOURCE,DEST,COUNT 4 | LOCAL PASTSUB ;; label at end of subroutine 5 | ; Move data from address gyven by 'SOURCE' 6 | ; to address given by 'DEST' for 'COUNT' bytes 7 | JR PASTSUB ;; jump around inline subroutine 8 | @MOVE: ;; inline subroutine to perform move operation 9 | ; HL is source, DE is destination, BC is count 10 | LD A,C ;; low order count 11 | OR B ;; zero count? 12 | RET Z ;; stop move if zero remainder 13 | LD A,(HL) ;; get next source character 14 | LD (DE),A ;; put next dest character 15 | INC HL ;; address following source 16 | INC DE ;; address following dest 17 | DEC BC ;; count = count-1 18 | JR @MOVE ;; for another byte to move 19 | PASTSUB: 20 | ; Arrive here on first invocation - redefine MOVE 21 | MOVE MACRO ?S,?D,?C ;; change parm names 22 | LD HL,?S ;; address the source string 23 | LD DE,?D ;; address the dest string 24 | LD BC,?C ;; prepare the count 25 | CALL @MOVE ;; move the string 26 | ENDM 27 | ; Continue here on the first invocation to use 28 | ; the redefined macro to perform the first move 29 | MOVE SOURCE,DEST,COUNT 30 | ENDM 31 | 32 | .LALL 33 | 34 | MOVE X1,X2,5 ; move 5 chars from X1 to X2 35 | MOVE 3000h,1000h,1500h ; big mover 36 | RET 37 | 38 | DSEG 39 | 40 | X1: DB 'here is some data to move' 41 | X2: DB 'xxxxxwe are!' 42 | 43 | END 44 | -------------------------------------------------------------------------------- /test/phase.mac: -------------------------------------------------------------------------------- 1 | ; .PHASE/.DEPHASE test 2 | 3 | .z80 4 | 5 | cseg 6 | 7 | extrn ex 8 | 9 | org 220h 10 | 11 | ld hl,aa 12 | ld hl,bb 13 | aa: .phase 8000h 14 | bb: ld hl,aa 15 | ld hl,bb 16 | .dephase 17 | 18 | .phase 6000h 19 | cc: dw aa,bb,cc 20 | .phase 9000h ; error 21 | dd: dw aa,bb,cc,dd 22 | dseg ; M80 accepts this, but screws up address 23 | ss: dw dd 24 | .dephase 25 | .dephase ; error 26 | 27 | zz equ $ ; back to cseg (or dseg if M80) 28 | 29 | dseg 30 | 31 | ee: dw zz 32 | dw dd 33 | dw cc 34 | dw bb 35 | dw aa 36 | dw ee 37 | dw ff 38 | dw gg 39 | dw ss 40 | 41 | .phase 1000h 42 | ff: dw ee 43 | cseg ; M80 accepts this, but screws up address 44 | gg: dw ff 45 | .dephase 46 | 47 | .phase aa ; M80 accepts reloc - questionable 48 | jj: dw jj,hh 49 | .dephase 50 | 51 | .phase ee ; M80 accepts reloc - questionable 52 | ii: dw ii,hh,ex 53 | .dephase 54 | 55 | hh equ $ 56 | 57 | .phase ex ; U error 58 | nn: dw hh,nn 59 | .dephase 60 | 61 | mm equ $ 62 | 63 | .Z280 64 | 65 | org 1000h 66 | 67 | L1 equ $ 68 | 69 | .phase 8000h 70 | L2: ld a,b 71 | jr L2 72 | jr L1 73 | ld a, 74 | ld a, 75 | jr $+8 76 | jp $+8 77 | jp 78 | jp 79 | jp 80 | .dephase 81 | 82 | L3: ld a,b 83 | jr L3 84 | jr L2 85 | jr L1 86 | ld a, 87 | ld a, 88 | ld a, 89 | jr $+8 90 | jp $+8 91 | jp 92 | jp 93 | jp 94 | 95 | end 96 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Path to Linux utilities 2 | ZXCC = zxcc 3 | 4 | # Path to CP/M utilities 5 | ZSM4 = ../../Tools/cpm/zsm4.com 6 | DRLINK = ../../Tools/cpm/drlink.com 7 | TKB = ../../Tools/cpm/tkb.com 8 | 9 | .PREFIX: 10 | .PREFIX: .mac .rel 11 | 12 | SRCS = zsm.mac \ 13 | symbols.mac \ 14 | listing.mac \ 15 | alloc.mac \ 16 | eval.mac \ 17 | macros.mac \ 18 | genrel.mac \ 19 | cpmio.mac \ 20 | rsxio.mac 21 | 22 | OBJS = $(SRCS:.mac=.rel) 23 | 24 | all: _zsm4.com mac.tsk 25 | 26 | $(OBJS): %.rel: %.mac *.inc 27 | $(ZXCC) $(ZSM4) -"=$ build.cmd 34 | @echo -e "fcslib/lb,syslib/lb/task=...MAC/ext=8000/asg=TI:5,SY:1-4:6-11\r" >> build.cmd 35 | $(ZXCC) $(TKB) -"@build" 36 | @rm build.cmd 37 | 38 | selftest: _zsm4.com 39 | $(ZXCC) _zsm4 -"_z=zsm/l/s7" 40 | $(ZXCC) _zsm4 -"_s=symbols/l/s7" 41 | $(ZXCC) _zsm4 -"_l=listing/l/s7" 42 | $(ZXCC) _zsm4 -"_a=alloc/l/s7" 43 | $(ZXCC) _zsm4 -"_e=eval/l/s7" 44 | $(ZXCC) _zsm4 -"_m=macros/l/s7" 45 | $(ZXCC) _zsm4 -"_r=genrel/l/s7" 46 | $(ZXCC) _zsm4 -"_c=cpmio/l/s7" 47 | $(ZXCC) $(DRLINK) -"_z=_z,_s,_l,_a,_e,_m,_r,_c" 48 | rm -f _*.rel 49 | comp _z.com _zsm4.com > comp_z_zsm4 50 | ls -l comp_z_zsm4 51 | 52 | clean: 53 | rm -f _zsm4.com mac.tsk *.rel *.sym *.prn *.crf *.map *.dmp core *~ *.\$$\$$\$$ 54 | rm -f _z.com comp_z_zsm4 55 | -------------------------------------------------------------------------------- /test/test2.mac: -------------------------------------------------------------------------------- 1 | ld a,(b) 2 | jr $+1 3 | offs equ -5 4 | ld a,(ix+offs) 5 | ld a,(ix-offs) 6 | extrn rec 7 | call rec 8 | cseg 9 | public idx 10 | ld hl,idx 11 | aaa: ld hl,aaa 12 | bbb: ld hl,1 13 | idx: ds 1 14 | ld hl,'SY' 15 | ld hl,"SY" 16 | 17 | .z80 18 | .z180 19 | .z280 20 | ld a,-1 21 | org 83h 22 | a1234 equ 1234h 23 | a1234 equ 1234h 24 | ;a1234 equ 1234 25 | a234 equ xxx 26 | 27 | jp $ 28 | 29 | dw L1 30 | dw L2 31 | dw L3 32 | dw L4 33 | dw L5 34 | L1 equ L2 ; should be undefined! 35 | db 0 36 | L2 equ L1 ; should be undefined! 37 | db 0 38 | L3 equ L5 39 | db 0 40 | L4 equ 5 41 | db 0 42 | L5: db 0 43 | 44 | a: 45 | b equ 5 46 | ld hl,a1234 47 | org 100h 48 | add a, b 49 | add a,b 50 | add a,a 51 | ld a,'a' 52 | ld a,"A" 53 | ld a,'"' 54 | ld a,'''' 55 | ld a,"'" 56 | ld a,"""" 57 | ld a,';' 58 | ld a," ; " 59 | db 'ABCDEF' 60 | db "ABCDEF" 61 | db 'ABC"DE' 62 | db "ABC'DE" 63 | db 'ABC''DE' 64 | db "ABC""DE" 65 | db 'ABC''' 66 | db '''ABC' 67 | db '''' 68 | db 'a' 69 | db '' 70 | db ' ;' ; embedded tab 71 | ds 100 72 | db 'abc 73 | jp z,a1234 74 | db a,b,c,z 75 | ld c, ( hl ) ; opcode = 4Eh 76 | ld a , i 77 | ld a,i 78 | ld i , a 79 | ld i,a 80 | ld i,1 81 | ld a,(ix+5) 82 | ld a,(ix + 5) 83 | ld a, ( ix + 5 ) 84 | ex af , af' 85 | ex af,af ' 86 | ld c,(de) 87 | ld a,(sp) 88 | ld (de),c 89 | ld (sp),a 90 | dc 91 | dc '' 92 | dc ''' 93 | dc '''' 94 | dc 'a' 95 | dc 'abc' 96 | dc 'abc','def' 97 | dc '''abc' 98 | dc 'abc''' 99 | end a1234 100 |  -------------------------------------------------------------------------------- /test/symtest.mac: -------------------------------------------------------------------------------- 1 | .z80 2 | 3 | cseg 4 | 5 | ;M80ZSM 6 | lm0: ; M M lbl redef diff seg - error 7 | lm1: 8 | lm1: ; lbl redef same addr+seg - no error 9 | 10 | public ep1 ; PUBLIC EQU + no error 11 | public p1 ; PUBLIC defined + no error 12 | public up1 ; U U PUBLIC undef - error 13 | public xp1 ; U U PUBLIC EXTRN - error 14 | public lm0 ; PUBLIC multiple def - error 15 | 16 | extrn x1 ; EXTRN undef ? error 17 | extrn xp1 ; M M PUBLIC EXTRN - error 18 | extrn x2 ; EXTRN referenced + no error 19 | extrn ex1 ; M M EXTRN EQU - error 20 | 21 | e1 equ 1 ; EQU symbol + no error 22 | ep1 equ 1 ; PUBLIC EQU + no error 23 | ex1 equ 1 ; M M EXTRN EQU - error 24 | ed1 equ 1 ; M M EQU DEFL - error 25 | e2 equ 1 ; M M EQU + no error 26 | e2 equ 2 ; M M EQU redefined - error 27 | e3 equ 1 ; EQU + no error 28 | e3 equ 1 ; EQU redefined as same + no error 29 | de1 equ 2 ; M M DEFL EQU - error 30 | el1 equ 1 ; M M EQU redef as label - error 31 | 32 | d1 defl 1 ; DEFL symbol + no error 33 | d1 defl 2 ; DEFL redefined + no error 34 | ed1 defl 2 ; M M EQU DEFL - error 35 | de1 defl 1 ; M M DEFL EQU - error 36 | 37 | dw x2 ; EXTRN referenced + no error 38 | dw x3## ; EXTRN referenced + no error 39 | p1: dw 1 ; PUBLIC defined + no error 40 | 41 | el1: dw 1 ; M M EQU redef as label - error 42 | 43 | le1: dw 1 ; M M label redef as EQU - error 44 | le1 equ 1 ; M M label redef as EQU - error 45 | ld1: dw 2 ; M M label redef as DEFL - error 46 | ld1 defl 2 ; M M label redef as DEFL - error 47 | 48 | dw up1 ; U U label undef - error, unless /U 49 | 50 | dw zz1 ; - no error 51 | dw zz1## ; - no error 52 | 53 | dw zz2## ; - no error 54 | dw zz2 ; - no error 55 | 56 | dseg 57 | 58 | lm0: ; M M label redef as diff seg - error 59 | 60 | end 61 | -------------------------------------------------------------------------------- /test/test816.280: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | v8 equ 55h 4 | v16 equ 5555h 5 | 6 | reloc equ $ 7 | 8 | extrn ext 9 | 10 | .z80 11 | 12 | adc a,(ix+v8) ; OK 13 | adc a,(ix+v16) ; error 14 | adc a,(ix+reloc) ; error 15 | adc a,(ix+ext) ; error 16 | 17 | inc (ix+v8) ; OK 18 | inc (ix+v16) ; error 19 | inc (ix+reloc) ; error 20 | inc (ix+ext) ; error 21 | 22 | ld a,(ix+v8) ; OK 23 | ld a,(ix+v16) ; error 24 | ld a,(ix+reloc) ; error 25 | ld a,(ix+ext) ; error 26 | 27 | ld (ix+v8),a ; OK 28 | ld (ix+v16),a ; error 29 | ld (ix+reloc),a ; error 30 | ld (ix+ext),a ; error 31 | 32 | ld (ix+v8),v8 ; OK 33 | ld (ix+v16),v8 ; error 34 | ld (ix+reloc),v8 ; error 35 | ld (ix+ext),v8 ; error 36 | 37 | ld (ix+v8),v8 ; OK 38 | ld (ix+v8),v16 ; error 39 | ld (ix+v8),reloc ; error 40 | ld (ix+v8),ext ; error 41 | 42 | jr $ ; OK 43 | jr v8 ; error unless in ASEG or PHASE and in range 44 | jr v16 ; error 45 | jr reloc ; OK if in range 46 | jr ext ; error 47 | 48 | .z280 49 | 50 | adc a,(ix+v8) ; short 51 | adc a,(ix+v16) ; long 52 | adc a,(ix+reloc) ; long 53 | adc a,(ix+ext) ; long 54 | 55 | inc (ix+v8) ; short 56 | inc (ix+v16) ; long 57 | inc (ix+reloc) ; long 58 | inc (ix+ext) ; long 59 | 60 | ld a,(ix+v8) ; short 61 | ld a,(ix+v16) ; long 62 | ld a,(ix+reloc) ; long 63 | ld a,(ix+ext) ; long 64 | 65 | ld (ix+v8),a ; short 66 | ld (ix+v16),a ; long 67 | ld (ix+reloc),a ; long 68 | ld (ix+ext),a ; long 69 | 70 | ld (ix+v8),v8 ; short 71 | ld (ix+v16),v8 ; long 72 | ld (ix+reloc),v8 ; long 73 | ld (ix+ext),v8 ; long 74 | 75 | ld (ix+v8),v8 ; short 76 | ld (ix+v8),v16 ; error 77 | ld (ix+v8),reloc ; error 78 | ld (ix+v8),ext ; error 79 | 80 | ld (hl),v8 ; short 81 | ld (hl),v16 ; long 82 | ld (hl),reloc ; long 83 | ld (hl),ext ; long 84 | 85 | jr $ ; OK 86 | jr v8 ; error unless in ASEG or PHASE and in range 87 | jr v16 ; error 88 | jr reloc ; OK if in range 89 | jr ext ; error 90 | 91 | end 92 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | .PREFIX: 2 | .PREFIX: .mac .rel .prn 3 | 4 | SRCS = 128.mac \ 5 | asegtst.mac \ 6 | cconst.mac \ 7 | comment.mac \ 8 | common1.mac \ 9 | common2.mac \ 10 | common3.mac \ 11 | common.mac \ 12 | defz.mac \ 13 | dseg0.mac \ 14 | dszero.mac \ 15 | even.mac \ 16 | expr2.mac \ 17 | expr.mac \ 18 | exttest1.mac \ 19 | exttest2.mac \ 20 | exttest3.mac \ 21 | exttest4.mac \ 22 | exttest.mac \ 23 | ident.mac \ 24 | iext.mac \ 25 | ifbnb.mac \ 26 | ifdef.mac \ 27 | ifidndif.mac \ 28 | iftest.mac \ 29 | incl01.mac \ 30 | incl02.mac \ 31 | incl0.mac \ 32 | irp1.mac \ 33 | irpc.mac \ 34 | irp.mac \ 35 | ldwtest.mac \ 36 | lesstest.mac \ 37 | local1.mac \ 38 | local2.mac \ 39 | local.mac \ 40 | macro0.mac \ 41 | macro10a.mac \ 42 | macro10.mac \ 43 | macro11.mac \ 44 | macro12.mac \ 45 | macro13.mac \ 46 | macro14.mac \ 47 | macro16.mac \ 48 | macro17.mac \ 49 | macro1a.mac \ 50 | macro1.mac \ 51 | macro20.mac \ 52 | macro21.mac \ 53 | macro22.mac \ 54 | macro24.mac \ 55 | macro25.mac \ 56 | macro26.mac \ 57 | macro27.mac \ 58 | macro28.mac \ 59 | macro2.mac \ 60 | macro3a.mac \ 61 | macro3.mac \ 62 | macro4.mac \ 63 | macro5.mac \ 64 | macro6.mac \ 65 | macro7.mac \ 66 | macro8.mac \ 67 | macro9.mac \ 68 | nultest.mac \ 69 | phase.mac \ 70 | pp.mac \ 71 | ra280.mac \ 72 | radix.mac \ 73 | reltest.mac \ 74 | rept1.mac \ 75 | rept.mac \ 76 | rqst.mac \ 77 | segtest.mac \ 78 | symtest.mac \ 79 | test1.mac \ 80 | test2a.mac \ 81 | test2.mac \ 82 | test3.mac \ 83 | test4.mac \ 84 | test5.mac \ 85 | test816.mac \ 86 | testz80.mac \ 87 | xx1.mac \ 88 | xx2.mac \ 89 | xx.mac \ 90 | z180test.mac \ 91 | z280test.mac \ 92 | z80test2.mac \ 93 | z80test.mac \ 94 | zsmtest.mac 95 | 96 | PRNS = $(SRCS:.mac=.prn) 97 | 98 | all: $(PRNS) 99 | 100 | $(PRNS): %.prn: %.mac *.inc 101 | zxcc ../_zsm4 -"=$ must be zero for all 4 | ; the instructions below. 5 | 6 | adc a, 7 | x1: 8 | adc 9 | x2: 10 | add a, 11 | x3: 12 | add 13 | x4: 14 | addw hl, 15 | x5: 16 | addw 17 | x6: 18 | and a, 19 | x7: 20 | and 21 | x8: 22 | call z, 23 | x9: 24 | call 25 | x10: 26 | cp a, 27 | x11: 28 | cp 29 | x12: 30 | cpw hl, 31 | x13: 32 | cpw 33 | x14: 34 | dec 35 | x15: 36 | decw 37 | x16: 38 | div hl, 39 | x17: 40 | div 41 | x18: 42 | divu hl, 43 | x19: 44 | divu 45 | x20: 46 | divuw dehl, 47 | x21: 48 | divuw 49 | x22: 50 | divw dehl, 51 | x23: 52 | divw 53 | x24: 54 | ex a, 55 | x25: 56 | in ,(c) 57 | x26: 58 | inc 59 | x27: 60 | incw 61 | x28: 62 | jp nz, 63 | x29: 64 | jp 65 | x30: 66 | ld a, 67 | x31: 68 | ld ,a 69 | x32: 70 | ld ,5 71 | x33: 72 | lda hl, 73 | x34: 74 | lda ix, 75 | x35: 76 | ldw hl, 77 | x36: 78 | ldw ix, 79 | x37: 80 | ldw ,hl 81 | x38: 82 | ldw ,ix 83 | x39: 84 | ldw ,5 85 | x40: 86 | ld hl, 87 | x41: 88 | ld ix, 89 | x42: 90 | ld ,hl 91 | x43: 92 | ld ,ix 93 | x44: 94 | ld ,12345 95 | x45: 96 | mult a, 97 | x46: 98 | mult 99 | x47: 100 | multu a, 101 | x48: 102 | multu 103 | x49: 104 | multuw hl, 105 | x50: 106 | multuw 107 | x51: 108 | multw hl, 109 | x52: 110 | multw 111 | x53: 112 | or a, 113 | x54: 114 | or 115 | x55: 116 | out (c), 117 | x56: 118 | pop 119 | x57: 120 | push 121 | x58: 122 | sbc a, 123 | x59: 124 | sbc 125 | x60: 126 | sub a, 127 | x61: 128 | sub 129 | x62: 130 | subw hl, 131 | x63: 132 | subw 133 | x64: 134 | xor a, 135 | x65: 136 | xor 137 | x66: 138 | epum 139 | x67: 140 | mepu 141 | x68: 142 | 143 | end 144 | -------------------------------------------------------------------------------- /zsm.inc: -------------------------------------------------------------------------------- 1 | FALSE equ 0 ; fiction 2 | TRUE equ NOT FALSE ; stranger than fiction 3 | 4 | VER equ 47 ; version number 5 | 6 | VER1 equ VER/10+'0' ; most significant version digit 7 | VER2 equ VER MOD 10+'0' ; least significant version digit 8 | 9 | CR equ 13 10 | LF equ 10 11 | TAB equ 9 12 | EOF equ 1Ah 13 | 14 | DEFLNP equ 60 ; default lines per page, including 15 | ; header, title and subtitle lines 16 | 17 | RECMAX equ 160 ; size of the input line buffer 18 | IDMAX equ 15 ; max identifier length, must be < 16 19 | 20 | LNGERR equ FALSE ; long error messages 21 | 22 | ;HDRSZ equ 24 23 | HDRSZ equ 32 ; min 24, must be a multiple of 8 24 | 25 | OSTKSZ equ 16 ; size of operand and operator stacks 26 | CSTKSZ equ 10 ; size of conditionals stack 27 | 28 | ; Symbol types (upper nibble of length field) 29 | 30 | RNAME equ 10h ; register name 31 | RPNAME equ 20h ; register pair name 32 | RSNAME equ 30h ; special register name 33 | COND equ 40h ; jump/return conditional name 34 | EQUNAME equ 50h ; EQUate label name 35 | DFLNAME equ 60h ; DEFL label name 36 | COMNAME equ 70h ; COMMON name 37 | MULTDEF equ 80h ; multiple-defined label or equate 38 | 39 | ; Symbol modes (bit masks) 40 | 41 | DSGSYM equ 080h ; symbol in data segment 42 | CSGSYM equ 040h ; symbol in code segment 43 | CMNSYM equ 0C0h ; symbol in COMMON segment 44 | EXTSYM equ 010h ; external reference 45 | GBLSYM equ 020h ; public symbol 46 | UNDEF equ 001h ; undefined symbol 47 | 48 | ; List options (bit numbers) 49 | 50 | LISTFL equ 0 ; set if we want a listing 51 | CONDFL equ 1 ; set if we want false conditionals 52 | SYMBLS equ 2 ; set if we want a symbol table 53 | SORTFL equ 3 ; set if we want sorted symbol table 54 | MACRFL equ 4 ; set if we want full macro expansions 55 | XMACFL equ 5 ; set if we want to list only macro lines 56 | ; that generate object code 57 | 58 | ; Opcode flags - CPU type 59 | 60 | Z80 equ 00h 61 | Z180 equ 10h 62 | Z280 equ 20h 63 | 64 | ; Type of structures pushed on the dynamic storage stack 65 | 66 | STINPF equ 1 ; include/input file state 67 | STMDEF equ 2 ; macro definition 68 | STMEXP equ 3 ; macro expansion/execution 69 | STMBLD equ 4 ; macro build context (for nested macros) 70 | STDEL equ 0FFh ; deleted entry, awaiting garbage collection 71 | 72 | -------------------------------------------------------------------------------- /gcml.inc: -------------------------------------------------------------------------------- 1 | ; Note: include FCB.INC before this file. 2 | 3 | ; GCML structure 4 | 5 | G.BUF equ 0 ; address of command buffer (2 bytes) 6 | G.SIZE equ G.BUF + 2 ; size of buffer (1 byte) 7 | G.LEN equ G.SIZE + 1 ; number of valid chars in buffer (1 byte) 8 | G.PRM equ G.LEN + 1 ; pointer to prompt string (2 bytes) 9 | G.LUN equ G.PRM + 2 ; LUN used for terminal and file I/O (1 byte) 10 | G.MAXD equ G.LUN + 1 ; max nesting depth (1 byte) 11 | G.MODE equ G.MAXD + 1 ; mode bits (1 byte) 12 | G.ST equ G.MODE + 1 ; status, used internally (1 byte) 13 | G.ERR equ G.ST + 1 ; error code (1 byte) 14 | G.LVL equ G.ERR + 1 ; current nesting level (1 byte) 15 | G.IFN equ G.LVL + 1 ; name of current indirect file (FNSZ bytes) 16 | G.DEVC equ G.IFN + FNSZ ; device capabilities (1 byte) 17 | G.LN equ G.DEVC + 1 ; current line # in indirect file (2 bytes) 18 | G.PDL equ G.LN + 2 ; address of push-down list area (2 bytes) 19 | 20 | ; GCML push-down list item size 21 | 22 | PDLSZ equ FNSZ + 6 23 | 24 | ; GCML mode bits 25 | 26 | GM.ELN equ 0 ; if set, return empty lines 27 | GM.CMT equ 1 ; if set, do not return comment lines 28 | GM.ICF equ 2 ; if set, disable recognition of @cmdfiles 29 | 30 | ; GCML status bits 31 | 32 | GS.EOF equ 0 ; if set, no more commands are available 33 | GS.MCR equ 1 ; set once the MCR command line is processed 34 | GS.INT equ 2 ; set if in interactive (prompt) mode 35 | GS.FIL equ 3 ; set if last command came from a file 36 | 37 | ; GCML-specific error codes 38 | 39 | GE.OK equ 0 ; success 40 | GE.SN equ 1 ; syntax error in command file specification 41 | GE.LEN equ 2 ; line too long in command file 42 | GE.NLV equ 3 ; command nesting level too deep 43 | 44 | ; Macro to generate a GCML structure 45 | 46 | GCML$ MACRO buf,siz,prm,lun,maxd,pdl 47 | local lbuf,lprm,lpdl 48 | ifnb 49 | dw buf ;; G.BUF 50 | else 51 | dw lbuf 52 | endif 53 | db siz ;; G.SIZ 54 | ds 1 ;; G.LEN 55 | dw lprm ;; G.PRM 56 | db lun ;; G.LUN 57 | db maxd ;; G.MAXD 58 | db 0,0,0,0 ;; G.MODE, G.STAT, G.ERR, G.LVL 59 | ds FNSZ ;; G.IFN 60 | ds 1 ;; G.DEVC 61 | ds 2 ;; G.LN 62 | ifnb 63 | dw pdl ;; G.PDL 64 | else 65 | dw lpdl 66 | endif 67 | ifb 68 | lbuf: ds siz+2 69 | endif 70 | lprm: db 0Dh,0Ah,prm,'>',0 71 | ifb 72 | lpdl: ds maxd*PDLSZ 73 | endif 74 | ENDM 75 | 76 | -------------------------------------------------------------------------------- /errors.inc: -------------------------------------------------------------------------------- 1 | ; System error codes 2 | 3 | E.OK equ 0 ; No error 4 | E.EOF equ -1 ; End of file 5 | E.FNF equ -2 ; File not found 6 | E.DNF equ -3 ; Directory not found 7 | E.NODIR equ -4 ; Not a directory 8 | E.BADF equ -5 ; Bad file specification 9 | E.DSKF equ -6 ; Disk full 10 | E.IDXF equ -7 ; Index file full 11 | E.IDXE equ -8 ; Index file error 12 | E.BADOP equ -9 ; Invalid operation 13 | E.CHOPN equ -10 ; Channel already in use 14 | E.IO equ -11 ; Channel I/O error 15 | E.PERM equ -12 ; Access denied 16 | E.INV equ -13 ; Invalid value 17 | E.LUN equ -14 ; Invalid LUN 18 | E.NOBUF equ -15 ; Out of disk buffers 19 | E.DEVNM equ -16 ; Device not mounted 20 | E.DEVAM equ -17 ; Device already mounted 21 | E.DMOP equ -18 ; Dismount in progress 22 | E.OFL equ -19 ; Unit offline 23 | E.BADVT equ -20 ; Invalid volume type 24 | E.UNA equ -21 ; Reading unallocated block (unwritten data) 25 | E.FLCK equ -22 ; File access is locked 26 | E.NODEV equ -23 ; No such device 27 | E.EXIST equ -24 ; File exists 28 | E.DNE equ -25 ; Directory not empty 29 | E.VLIM equ -26 ; File version limit reached 30 | E.BADFN equ -27 ; Invalid system call 31 | E.BADTH equ -28 ; Invalid task header 32 | E.TCKS equ -29 ; Task image checksum error 33 | E.BADTF equ -30 ; Invalid or corrupt task image file 34 | E.TNF equ -31 ; Task not found 35 | E.TNU equ -32 ; Task name in use 36 | E.FNC equ -33 ; File not contiguous 37 | E.NCSPC equ -34 ; No contiguous space on device 38 | E.NOMEM equ -35 ; Not enough room 39 | E.PEND equ -36 ; I/O request pending 40 | E.TRUN equ -37 ; Task already running 41 | E.TSTP equ -38 ; Task already stopped 42 | E.TDLY equ -39 ; Task already delayed 43 | E.TFIX equ -40 ; Task already fixed 44 | E.TNFIX equ -41 ; Task not fixed 45 | E.TACT equ -42 ; Task active 46 | E.TNAC equ -43 ; Task not active 47 | E.TNIU equ -44 ; Task name in use 48 | E.TABO equ -45 ; Task abort in progress 49 | E.FAIL equ -46 ; Operation failed 50 | E.ABOP equ -47 ; Operation aborted 51 | E.TMO equ -48 ; Operation timed out 52 | E.PRIV equ -49 ; Privileged command 53 | E.PBIG equ -50 ; Program too big 54 | E.QEMP equ -51 ; Queue empty 55 | E.BADFL equ -52 ; Invalid flag number 56 | E.PBSY equ -53 ; Partition busy 57 | E.PNF equ -54 ; Partition not found 58 | E.SSNF equ -55 ; Session not found 59 | E.SSNA equ -56 ; Session not active 60 | E.CLNF equ -57 ;- CLI not found 61 | E.DMOI equ -58 ;- Dismount initiated 62 | E.NLI equ -59 ;- Not logged in 63 | E.ULI equ -60 ;- Already (Other user) logged in 64 | 65 | ; Task exit status codes (lo-byte, hi-byte is reserved for user codes) 66 | 67 | EX.WRN equ 0 ; Warning 68 | EX.SUC equ 1 ; Success 69 | EX.ERR equ 2 ; Error 70 | EX.SEV equ 4 ; Severe 71 | 72 | -------------------------------------------------------------------------------- /sysfn.inc: -------------------------------------------------------------------------------- 1 | ; System function equates 2 | 3 | .EXIT equ 0 ; exit program 4 | .EXIF equ 1 ; exit program if event flag not set 5 | .EMTST equ 2 ; emit status 6 | .QIO equ 3 ; queue I/O packet 7 | .CONN equ 4 ; connect to task 8 | .GTCMD equ 5 ; get command line arguments 9 | .SEND equ 6 ; send data 10 | .RECV equ 7 ; receive data 11 | .WTDAT equ 8 ; wait for data 12 | .ASTDF equ 9 ; declare AST service routine 13 | .ASTCT equ 10 ; AST control (enable/disable AST types) 14 | .ASTX equ 11 ; exit AST service routine 15 | .ALUN equ 12 ; assign LUN to device 16 | .GTLUN equ 13 ; get LUN information 17 | .GDIR equ 14 ; get current dir name 18 | .SDIR equ 15 ; set current dir 19 | .GDAT equ 16 ; get date and time 20 | .SDAT equ 17 ; set date and time 21 | .RQST equ 18 ; request installed task 22 | .RPOI equ 19 ; request and pass offspring information 23 | .ABORT equ 20 ; abort a task 24 | .STOP equ 21 ; stop task 25 | .RESUM equ 22 ; resume task 26 | .CLEF equ 23 ; clear event flag 27 | .SETF equ 24 ; set single event flag 28 | .RDEF equ 25 ; read event flag 29 | .WTSE equ 26 ; wait for single event flag 30 | .STSE equ 27 ; stop for single event flag 31 | .WTLO equ 28 ; wait for logical OR of event flags 32 | .STLO equ 29 ; stop for logical OR of event flags 33 | .RUN equ 30 ; request installed task at specified time 34 | .CSRQ equ 31 ; cancel scheduled task request 35 | .MRKT equ 32 ; mark time request 36 | .CMKT equ 33 ; cancel mark time request 37 | .EXTSK equ 34 ; extend task size 38 | .ALTPR equ 35 ; change task priority 39 | .SUPER equ 36 ; enter/exit supervisor mode 40 | .GTSK equ 37 ; get task info 41 | .GTPAR equ 38 ; get partition info 42 | .GCII equ 39 ; get command interpreter info 43 | .GIN equ 40 ; get general info 44 | .SVTBL equ 41 ; specify SST vector table 45 | 46 | MAXFN equ 41 47 | 48 | SYSRST equ 20h ; system call RST is RST 4 49 | DBGRST equ 30h ; debug breakpoint RST is RST 6 50 | 51 | ; .GDIR subfunction codes 52 | 53 | GD.TSK equ 0 ; get task's current directory 54 | GD.TI equ 1 ; get terminal's current directory 55 | GD.LOG equ 2 ; get terminal's login directory 56 | 57 | ; .SDIR subfunction codes 58 | 59 | SD.TSK equ 0 ; set task's current directory 60 | SD.TI equ 1 ; set terminal's current directory 61 | 62 | ; .GIN subfunction codes 63 | 64 | I.VERS equ 0 ; get system version 65 | I.SMEM equ 1 ; get system memory info 66 | I.USCB equ 2 ; get user's SCB 67 | I.TSCB equ 3 ; get SCB of terminal device 68 | I.HOST equ 4 ; get host name 69 | I.TCKS equ 5 ; get ticks per second 70 | I.FEAT equ 6 ; get feature bits 71 | 72 | ; Macro to call system services 73 | 74 | IFZ280 75 | ELSE 76 | SC MACRO func 77 | IF 0 78 | rst SYSRST 79 | db func 80 | ELSE 81 | dw 71EDh,func 82 | ENDIF 83 | ENDM 84 | ENDIF 85 | -------------------------------------------------------------------------------- /test/test816.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | v8 equ 55h 4 | v16 equ 5555h 5 | 6 | reloc equ $ 7 | 8 | extrn ext 9 | 10 | .z80 11 | 12 | add a,v8 ; OK 13 | add a,v16 ; error 14 | add a,reloc ; error 15 | add a,ext ; error 16 | 17 | adc a,(ix+v8) ; OK 18 | adc a,(ix+v16) ; error 19 | adc a,(ix+reloc) ; error 20 | adc a,(ix+ext) ; error 21 | 22 | inc (ix+v8) ; OK 23 | inc (ix+v16) ; error 24 | inc (ix+reloc) ; error 25 | inc (ix+ext) ; error 26 | 27 | ld a,v8 ; OK 28 | ld a,v16 ; error 29 | ld a,reloc ; error 30 | ld a,ext ; error 31 | 32 | ld c,v8 ; OK 33 | ld c,v16 ; error 34 | ld c,reloc ; error 35 | ld c,ext ; error 36 | 37 | ld hl,v8 ; OK 38 | ld hl,v16 ; OK 39 | ld hl,reloc ; OK 40 | ld hl,ext ; OK 41 | 42 | ld a,(ix+v8) ; OK 43 | ld a,(ix+v16) ; error 44 | ld a,(ix+reloc) ; error 45 | ld a,(ix+ext) ; error 46 | 47 | ld (ix+v8),a ; OK 48 | ld (ix+v16),a ; error 49 | ld (ix+reloc),a ; error 50 | ld (ix+ext),a ; error 51 | 52 | ld (ix+v8),v8 ; OK 53 | ld (ix+v16),v8 ; error 54 | ld (ix+reloc),v8 ; error 55 | ld (ix+ext),v8 ; error 56 | 57 | ld (ix+v8),v8 ; OK 58 | ld (ix+v8),v16 ; error 59 | ld (ix+v8),reloc ; error 60 | ld (ix+v8),ext ; error 61 | 62 | ld (hl),v8 ; OK 63 | ld (hl),-v8 ; OK 64 | ld (hl),v16 ; error 65 | ld (hl),reloc ; error 66 | ld (hl),ext ; error 67 | 68 | in a,(v8) ; OK 69 | in a,(v16) ; error 70 | in a,(reloc) ; error 71 | in a,(ext) ; error 72 | 73 | jr $ ; OK 74 | jr v8 ; error unless in ASEG or PHASE and in range 75 | jr v16 ; error 76 | jr reloc ; OK if in range 77 | jr ext ; error 78 | 79 | .z280 80 | 81 | add a,v8 ; OK 82 | add a,v16 ; error 83 | add a,reloc ; error 84 | add a,ext ; error 85 | 86 | adc a,(ix+v8) ; short 87 | adc a,(ix+v16) ; long 88 | adc a,(ix+reloc) ; long 89 | adc a,(ix+ext) ; long 90 | 91 | inc (ix+v8) ; short 92 | inc (ix+v16) ; long 93 | inc (ix+reloc) ; long 94 | inc (ix+ext) ; long 95 | 96 | ld a,v8 ; OK 97 | ld a,v16 ; error 98 | ld a,reloc ; error 99 | ld a,ext ; error 100 | 101 | ld c,v8 ; OK 102 | ld c,v16 ; error 103 | ld c,reloc ; error 104 | ld c,ext ; error 105 | 106 | ld hl,v8 ; OK 107 | ld hl,v16 ; OK 108 | ld hl,reloc ; OK 109 | ld hl,ext ; OK 110 | 111 | ld a,(ix+v8) ; short 112 | ld a,(ix+v16) ; long 113 | ld a,(ix+reloc) ; long 114 | ld a,(ix+ext) ; long 115 | 116 | ld (ix+v8),a ; short 117 | ld (ix+v16),a ; long 118 | ld (ix+reloc),a ; long 119 | ld (ix+ext),a ; long 120 | 121 | ld (ix+v8),v8 ; short 122 | ld (ix+v8),-v8 ; short 123 | ld (ix+v16),v8 ; long 124 | ld (ix+reloc),v8 ; long 125 | ld (ix+ext),v8 ; long 126 | 127 | ld (ix+v8),v8 ; short 128 | ld (ix+v8),-v8 ; short 129 | ld (ix+v8),v16 ; error 130 | ld (ix+v8),reloc ; error 131 | ld (ix+v8),ext ; error 132 | 133 | ld (hl),v8 ; short 134 | ld (hl),-v8 ; short 135 | ld (hl),v16 ; long 136 | ld (hl),reloc ; long 137 | ld (hl),ext ; long 138 | 139 | ld (reloc),v8 ; short 140 | ld (reloc),-v8 ; short 141 | ld (reloc),v16 ; long 142 | ld (reloc),reloc ; long 143 | ld (reloc),ext ; long 144 | 145 | ld ,v8 ; short 146 | ld ,-v8 ; short 147 | ld ,v16 ; long 148 | ld ,reloc ; long 149 | ld ,ext ; long 150 | 151 | in a,(v8) ; OK 152 | in a,(v16) ; error 153 | in a,(reloc) ; error 154 | in a,(ext) ; error 155 | 156 | di v8 ; OK 157 | di v16 ; error 158 | di reloc ; error 159 | di ext ; error 160 | 161 | jr $ ; OK 162 | jr v8 ; error unless in ASEG or PHASE and in range 163 | jr v16 ; error 164 | jr reloc ; OK if in range 165 | jr ext ; error 166 | 167 | end 168 | -------------------------------------------------------------------------------- /fcb.inc: -------------------------------------------------------------------------------- 1 | ; FCB structure offsets 2 | 3 | F.LNK equ 0 ; link to next FCB in list (2 bytes) 4 | F.ATTR equ F.LNK + 2 ; file attributes and flags (1 byte) 5 | F.DEV equ F.ATTR + 1 ; device name (2 characters) 6 | F.UNIT equ F.DEV + 2 ; device unit (1 byte) 7 | F.DIR equ F.UNIT + 1 ; directory name (9 characters) 8 | F.NAME equ F.DIR + 9 ; file name (9 characters) 9 | F.EXT equ F.NAME + 9 ; file ext (3 characters) 10 | F.VER equ F.EXT + 3 ; file version (2 bytes) 11 | F.USER equ F.VER + 2 ; user code (1 byte) 12 | F.GROUP equ F.USER + 1 ; group code (1 byte) 13 | F.PROT equ F.GROUP + 1 ; protection bits (2 bytes) 14 | F.LCNT equ F.PROT + 2 ; link count (2 bytes) 15 | F.SEQNO equ F.LCNT + 2 ; sequence number (2 bytes) 16 | F.INODE equ F.SEQNO + 2 ; index file entry number (2 bytes) 17 | F.NALOC equ F.INODE + 2 ; total data blocks allocated (3 bytes) 18 | F.NUSED equ F.NALOC + 3 ; data blocks actually used (3 bytes) 19 | F.LBCNT equ F.NUSED + 3 ; last block byte count (2 bytes) 20 | F.BMAP equ F.LBCNT + 2 ; block map (6*3 bytes) 21 | F.CALBN equ F.BMAP + 6*3 ; cached logical alloc block number (3 bytes) 22 | F.CAVBN equ F.CALBN + 3 ; cached virtual alloc block number (2 bytes) 23 | F.REFS equ F.CAVBN + 2 ; reference count (2 bytes) 24 | 25 | ; Fields present in fileinfo and FDB structures, but not in FCB 26 | 27 | F.WAT equ F.LNK + 0 ; field bit for IO.WAT function (1 byte) 28 | F.WLDC equ F.WAT + 1 ; wildcards in filespec (1 byte) 29 | F.TCRE equ F.CALBN + 0 ; created timestamp (7 bytes) 30 | F.TMOD equ F.TCRE + 7 ; last modified timestamp (7 bytes) 31 | 32 | ; F.ATTR flag bits (for both FCB and index file entries unless otherwise noted) 33 | 34 | FA.DIR equ 80h ; file is a directory 35 | FA.FILE equ 01h ; file is a regular file 36 | FA.CTG equ 08h ; file is contiguous 37 | FA.LCK equ 10h ; file is locked 38 | FA.RD equ 02h ; file is open for read (FCB only) 39 | FA.WR equ 04h ; file is open for write (FCB only) 40 | FA.SHR equ 20h ; file is open in shared mode (FCB only) 41 | FA.MODF equ 40h ; file has been modified (FCB only) 42 | 43 | ; F.WAT field bit masks 44 | 45 | FA.USER equ 01h ; set F.USER 46 | FA.GRP equ 02h ; set F.GROUP 47 | FA.PROT equ 04h ; set F.PROT 48 | FA.TCRE equ 10h ; set IE.TCRE 49 | FA.TMOD equ 20h ; set IE.TMOD 50 | 51 | ; PFN filespec parsing result bits 52 | 53 | FN.DEV equ 01h ; device name specified 54 | FN.DIR equ 02h ; directory specified 55 | FN.NAME equ 04h ; file name specified 56 | FN.EXT equ 08h ; extension specified 57 | FN.VER equ 10h ; version specified 58 | 59 | ; File protection bit masks 60 | 61 | FP.R equ 08h ; read 62 | FP.W equ 04h ; write 63 | FP.E equ 02h ; execute (not used) 64 | FP.D equ 01h ; delete 65 | 66 | ; Structure sizes 67 | 68 | FCBSZ equ F.REFS + 2 ; FCB size 69 | FDBSZ equ F.PROT + 2 ; size of descriptor used by file open/create, etc. 70 | FNSZ equ F.VER + 2 ; size of filespec part, used by parsefn 71 | FINFSZ equ F.TMOD + 7 ; size of fileinfo structure 72 | 73 | ; Directory entry layout 74 | 75 | DE.INDX equ 0 ; index file entry (inode) number (2 bytes) 76 | DE.NAME equ DE.INDX + 2 ; file name (9 characters) 77 | DE.EXT equ DE.NAME + 9 ; file externsion (3 characters) 78 | DE.VER equ DE.EXT + 3 ; file version (2 bytes) 79 | 80 | DESZ equ DE.VER + 2 ; directory entry size 81 | 82 | ; Index file entry (inode) layout 83 | 84 | IE.LCNT equ 0 ; link count (2 bytes) 85 | IE.ATTR equ IE.LCNT + 2 ; file attributes (1 byte) 86 | IE.CLF equ IE.ATTR + 1 ; cluster factor (1 byte) 87 | IE.SEQN equ IE.CLF + 1 ; file sequence number (2 bytes) 88 | IE.USER equ IE.SEQN + 2 ; user code (1 byte) 89 | IE.GRP equ IE.USER + 1 ; group code (1 byte) 90 | IE.ALOC equ IE.GRP + 1 ; total data blocks allocated (3 bytes) 91 | IE.USED equ IE.ALOC + 3 ; total data blocks used (3 bytes) 92 | IE.LBCN equ IE.USED + 3 ; last block byte count (2 bytes) 93 | IE.TCRE equ IE.LBCN + 2 ; created timestamp (7 bytes) 94 | IE.TMOD equ IE.TCRE + 7 ; last modified timestamp (7 bytes) 95 | IE.PROT equ IE.TMOD + 7 ; protection bits (2 bytes) 96 | IE.BMAP equ IE.PROT + 2 ; block map (6*3 bytes) 97 | IE.NAME equ IE.BMAP + 6*3 ; original file name (9 characters) 98 | IE.EXT equ IE.NAME + 9 ; original file extension (3 characters) 99 | IE.VERS equ IE.EXT + 3 ; original file version (2 bytes) 100 | 101 | IESZ equ IE.VERS + 2 ; index file entry (inode) size (64 bytes) 102 | 103 | -------------------------------------------------------------------------------- /alloc.mac: -------------------------------------------------------------------------------- 1 | ;**********************************************************************; 2 | ; ; 3 | ; This file is part of ZSM4, a Z80/Z180/Z280 relocatable macro- ; 4 | ; assembler written in Z80 assembly. ; 5 | ; Copyright (C) 2017-2020, Hector Peraza. ; 6 | ; ; 7 | ; This program is free software; you can redistribute it and/or ; 8 | ; modify it under the terms of the GNU General Public License as ; 9 | ; published by the Free Software Foundation; either version 2 of ; 10 | ; the License, or (at your option) any later version. ; 11 | ; ; 12 | ; This program is distributed in the hope that it will be useful, ; 13 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; 14 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; 15 | ; GNU General Public License for more details. ; 16 | ; ; 17 | ; You should have received a copy of the GNU General Public License ; 18 | ; along with this program; if not, write to the Free Software ; 19 | ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; 20 | ; ; 21 | ;**********************************************************************; 22 | 23 | TITLE Z80/Z180/Z280 Macro-Assembler 24 | SUBTTL Dynamic memory management routines 25 | 26 | .Z80 27 | 28 | include ZSM.INC 29 | 30 | public MCHECK,MACCHK,MALLOC,MFREE,CMPHD,FNDREC,FNDNXT,GBCOL 31 | 32 | extrn INCMEM,MAXMEM,DSPTR,SYMPTR,MACPTR,ERRFLG 33 | 34 | cseg 35 | 36 | ; MCHECK - Check for available memory 37 | ; BC = size in bytes 38 | ; Returns CY flag set if not enough memory 39 | 40 | MCHECK: push hl 41 | ld hl,(SYMPTR) 42 | MCHK1: add hl,bc 43 | push de 44 | ex de,hl 45 | ld hl,(DSPTR) 46 | call CMPHD 47 | ccf 48 | call c,INCMEM 49 | pop de 50 | pop hl 51 | ret 52 | 53 | ; MACCHK - Check for available memory, this one is used when 54 | ; building a MACRO. 55 | ; BC = size in bytes 56 | ; Returns CY flag set if not enough memory 57 | 58 | MACCHK: push hl 59 | ld hl,(MACPTR) 60 | jr MCHK1 ; continue via common code 61 | 62 | ; MALLOC - Allocate a block of memory 63 | ; BC = size in bytes, not including overhead 64 | ; E = record type 65 | ; Returns HL pointing to data area of allocated block 66 | ; CY flag set if not enough memory 67 | 68 | MALLOC: inc bc 69 | inc bc 70 | inc bc ; overhead = 3 bytes (type + size) 71 | call MCHECK 72 | jr nc,M1 ; branch if OK 73 | ld a,'W' ; else error 74 | ld (ERRFLG),a 75 | ret 76 | 77 | M1: ld hl,(DSPTR) ; get updated top of available memory 78 | or a 79 | sbc hl,bc ; alloc block 80 | ld (DSPTR),hl ; set new top of available memory 81 | ld (hl),e ; store record type 82 | inc hl 83 | dec bc 84 | dec bc 85 | dec bc 86 | ld (hl),c ; store size, not including overhead 87 | inc hl 88 | ld (hl),b 89 | inc hl 90 | ret 91 | 92 | ; MFREE - Release allocated memory 93 | ; HL = start of block to free 94 | 95 | MFREE: push hl 96 | ld de,(DSPTR) 97 | or a 98 | sbc hl,de ; get length of storage under current block 99 | ld c,l ; BC = len 100 | ld b,h 101 | pop hl 102 | push hl 103 | inc hl 104 | ld e,(hl) ; get record length 105 | inc hl 106 | ld d,(hl) 107 | add hl,de ; point to last byte 108 | ex de,hl ; DE = dst 109 | pop hl 110 | dec hl ; HL = src 111 | ld a,b 112 | or c 113 | jr z,M2 ; branch if nothing to move 114 | lddr ; move lower blocks to free space 115 | M2: ex de,hl 116 | inc hl 117 | ld (DSPTR),hl ; set new top of memory 118 | ret 119 | 120 | ; CMPHD - Compare HL:DE 121 | ; Returns Z flag set if HL == DE, CY flag set if HL > DE 122 | 123 | CMPHD: ld a,d 124 | cp h 125 | ret nz 126 | ld a,e 127 | cp l 128 | ret 129 | 130 | ; FNDREC - Find record of specified type in high memory storage 131 | ; C has record type 132 | 133 | FNDREC: ld hl,(DSPTR) 134 | FNDR1: ld a,(hl) ; get type 135 | or a ; null? 136 | scf 137 | ret z ; return error - not found 138 | cp c ; found? 139 | ret z ; return success 140 | FNDNXT: inc hl 141 | ld e,(hl) ; else get length 142 | inc hl 143 | ld d,(hl) 144 | inc hl 145 | add hl,de ; point to next record 146 | jr FNDR1 147 | 148 | ; GBCOL - Perform garbage collection, remove all deleted entries. 149 | 150 | GBCOL: ld c,STDEL 151 | call FNDREC 152 | ret c 153 | call MFREE 154 | jr GBCOL 155 | 156 | end 157 | -------------------------------------------------------------------------------- /test/qio.inc: -------------------------------------------------------------------------------- 1 | ; QDB structure offsets 2 | 3 | Q.FUNC equ 0 ; function code (1 byte) 4 | Q.SUBF equ Q.FUNC + 1 ; subfunction (1 byte) 5 | Q.LUN equ Q.SUBF + 1 ; logical unit number (1 byte) 6 | Q.EFN equ Q.LUN + 1 ; event flag number (1 byte) 7 | Q.WAIT equ Q.EFN + 1 ; wait flag (1 byte) 8 | Q.IOSB equ Q.WAIT + 1 ; I/O Status Block address (2 bytes) 9 | Q.AST equ Q.IOSB + 2 ; AST routine address (2 bytes) 10 | Q.P1 equ Q.AST + 2 ; function-dependent param 1 (2 bytes) 11 | Q.P2 equ Q.P1 + 2 ; function-dependent param 2 (2 bytes) 12 | Q.P3 equ Q.P2 + 2 ; function-dependent param 3 (2 bytes) 13 | Q.P4 equ Q.P3 + 2 ; function-dependent param 4 (2 bytes) 14 | Q.P5 equ Q.P4 + 2 ; function-dependent param 5 (2 bytes) 15 | Q.P6 equ Q.P5 + 2 ; function-dependent param 6 (2 bytes) 16 | 17 | QDBSZ equ Q.P6 + 2 ; QDB size 18 | 19 | ; Standard parameter mapping 20 | 21 | Q.BUF equ Q.P1 ; buffer address in user space (2 bytes) 22 | Q.LEN equ Q.P2 ; byte count (2 bytes) 23 | Q.BLK equ Q.P3 ; block number (4 bytes) 24 | Q.OFS equ Q.P5 ; offset within block (2 bytes) 25 | 26 | ; QIO function codes 27 | 28 | ; Standard functions 29 | 30 | IO.KIL equ 0 ; cancel I/O requests 31 | IO.ATT equ 1 ; attach device 32 | IO.DET equ 2 ; detach device 33 | IO.RLB equ 3 ; read logical block 34 | IO.WLB equ 4 ; write logical block 35 | IO.SEC equ 5 ; sense characteristics 36 | 37 | ; Additional disk driver functions 38 | 39 | IO.RPB equ 6 ; read physical block 40 | IO.WPB equ 7 ; write physical block 41 | IO.FMT equ 8 ; format track 42 | 43 | ; Additional terminal functions 44 | 45 | IO.RPR equ 9 ; read with prompt 46 | IO.HNG equ 10 ; hangup remote line 47 | SF.GMC equ 11 ; get multiple characteristics 48 | SF.SMC equ 12 ; set multiple characteristics 49 | 50 | ; Terminal sub-functions (some can be ORed) 51 | 52 | TF.AST equ 01h ; attach with AST 53 | TF.RNE equ 01h ; read with no echo 54 | TF.RAL equ 02h ; read all bits (unfiltered) 55 | TF.WAL equ 02h ; write all bits 56 | TF.TMO equ 04h ; read with timeout 57 | TF.WBT equ 08h ; break-through write 58 | TF.CCO equ 10h ; cancel ^O 59 | TF.XOF equ 20h ; send XOFF 60 | 61 | ; Filesystem requests 62 | 63 | IO.CRE equ 20 ; create file 64 | IO.ACC equ 21 ; access (open) file 65 | IO.DEA equ 22 ; deaccess (close) file 66 | IO.RVB equ 23 ; read virtual block 67 | IO.WVB equ 24 ; write virtual block 68 | IO.RAT equ 25 ; read attributes 69 | IO.WAT equ 26 ; write attributes 70 | IO.UNL equ 27 ; unlock file 71 | IO.DEL equ 28 ; delete file 72 | IO.REN equ 29 ; rename file 73 | IO.CLN equ 30 ; cleanup file 74 | IO.EXT equ 31 ; extend file 75 | IO.TRN equ 32 ; truncate file 76 | IO.MNT equ 33 ; mount device 77 | IO.DSM equ 34 ; dismount device 78 | IO.FFS equ 35 ; flush all disk buffers 79 | 80 | ; File I/O subfunctions (can be ORed) 81 | 82 | SF.ACR equ 01h ; access (open) for read 83 | SF.ACW equ 02h ; access (open) for write 84 | SF.SHR equ 08h ; open in shared mode 85 | SF.FID equ 10h ; access (open) by file ID 86 | SF.TMP equ 20h ; create temporary file (delete on close) 87 | SF.DIR equ 40h ; create directory 88 | SF.CTG equ 80h ; create contiguous file 89 | 90 | SF.TRU equ 20h ; truncate unused blocks 91 | 92 | ; RSX-11M style QIO macros 93 | 94 | QIO$ macro func,lun,efn,wait,iosb,ast,args 95 | dw func ;; note: 16-bit Q.FUNC + Q.SUBF 96 | db lun,efn ;; Q.LUN, Q.EFN 97 | ifb 98 | db 0 ;; Q.WAIT = 0 99 | else 100 | db wait ;; Q.WAIT 101 | endif 102 | dw iosb ;; Q.IOSB 103 | ifb 104 | dw 0 ;; Q.AST = 0 105 | else 106 | dw ast ;; Q.AST 107 | endif 108 | irp arg, 109 | ifb 110 | dw 0 111 | else 112 | dw arg ;; Q.P1..P6 113 | endif 114 | endm 115 | endm 116 | 117 | QIO$S macro func,lun,efn,wait,iosb,ast,args 118 | local n 119 | push ix 120 | ld ix,-QDBSZ 121 | add ix,sp 122 | ld sp,ix 123 | ld (ix+Q.FUNC),low func 124 | ld (ix+Q.SUBF),high func 125 | ld (ix+Q.LUN),lun 126 | ld (ix+Q.EFN),efn 127 | ifb 128 | ld (ix+Q.WAIT),0 129 | else 130 | ld (ix+Q.WAIT),wait 131 | endif 132 | ld hl,iosb 133 | ld (ix+Q.IOSB),l 134 | ld (ix+Q.IOSB+1),h 135 | ifb 136 | ld hl,0 137 | else 138 | ld hl,ast 139 | endif 140 | ld (ix+Q.AST),l 141 | ld (ix+Q.AST+1),h 142 | n defl 0 143 | irp arg, 144 | ifb 145 | ld hl,0 146 | else 147 | ld hl,arg 148 | endif 149 | ld (ix+Q.P1+n),l 150 | ld (ix+Q.P1+n+1),h 151 | n defl n+2 152 | endm 153 | push ix 154 | pop hl 155 | SC .QIO 156 | ld hl,QDBSZ 157 | add hl,sp 158 | ld sp,hl 159 | pop ix 160 | rlca ;; restore carry bit from error code sign 161 | rra ;; (works since all errors are negative) 162 | endm 163 | 164 | QIOW$ macro func,lun,efn,iosb,ast,args 165 | QIO$ func,lun,efn,1,iosb,ast, 166 | endm 167 | 168 | QIOW$S macro func,lun,efn,iosb,ast,args 169 | QIO$S func,lun,efn,1,iosb,ast, 170 | endm 171 | 172 | -------------------------------------------------------------------------------- /tcb.inc: -------------------------------------------------------------------------------- 1 | ; Task Control Block structure 2 | 3 | T.LNK equ 0 ; utility link field (2 bytes) 4 | T.TCBL equ T.LNK + 2 ; link to next TCB in directory list (2 bytes) 5 | T.ACTL equ T.TCBL + 2 ; link to next TCB in active task list (2 bytes) 6 | T.ATTR equ T.ACTL + 2 ; attributes (1 byte) 7 | T.ST equ T.ATTR + 1 ; status (2 bytes) 8 | T.DPRI equ T.ST + 2 ; default priority (1 byte) 9 | T.PRI equ T.DPRI + 1 ; current priority (1 byte) 10 | T.SPRI equ T.PRI + 1 ; current swap priority (1 byte) 11 | T.NAME equ T.SPRI + 1 ; task name (6 characters) 12 | T.VID equ T.NAME + 6 ; task version identification (6 characters) 13 | T.CMD equ T.VID + 6 ; pointer to command line block (2 bytes) 14 | T.IOC equ T.CMD + 2 ; outstanding I/O count (1 byte) 15 | T.RCVL equ T.IOC + 1 ; pointer to receive queue (2 bytes) 16 | T.OCBL equ T.RCVL + 2 ; pointer to list of OCBs (2 bytes) 17 | T.SAST equ T.OCBL + 2 ; pointer to list of specified ASTs (2 bytes) 18 | T.ASTL equ T.SAST + 2 ; pointer to list of AST events (2 bytes) 19 | T.SVST equ T.ASTL + 2 ; saved task status during AST (2 bytes) 20 | T.FLGS equ T.SVST + 2 ; task event flags (4 bytes = 32 flags) 21 | T.WAIT equ T.FLGS + 4 ; flag wait mask (4 bytes) 22 | T.CTX equ T.WAIT + 4 ; pointer to Context Block (2 bytes) 23 | T.TI equ T.CTX + 2 ; UCB of terminal device (2 bytes) 24 | T.LDEV equ T.TI + 2 ; UCB of load device (2 bytes) 25 | T.SBLK equ T.LDEV + 2 ; task starting disk block number (4 bytes) 26 | T.NBLK equ T.SBLK + 4 ; task size in disk blocks (2 bytes) 27 | T.PCB equ T.NBLK + 2 ; pointer to PCB (2 bytes) 28 | T.CPCB equ T.PCB + 2 ; pointer to checkpoint PCB (2 bytes) 29 | T.STRT equ T.CPCB + 2 ; start address (2 bytes) 30 | T.DEND equ T.STRT + 2 ; default end address (2 bytes) 31 | T.END equ T.DEND + 2 ; current end address (2 bytes) 32 | T.EPT equ T.END + 2 ; entry point (2 bytes) 33 | T.SP equ T.EPT + 2 ; task SP (2 bytes) 34 | 35 | ; TCB size 36 | 37 | TCBSZ equ T.SP + 2 38 | 39 | ; Attribute bit numbers 40 | 41 | TA.PRV equ 0 ; task is privileged 42 | TA.REM equ 1 ; remove on exit 43 | TA.AST equ 2 ; AST recognition enabled 44 | TA.FIX equ 3 ; task fixed in memory 45 | TA.MCR equ 4 ; task is external MCR function 46 | TA.CLI equ 5 ; task is a CLI 47 | TA.ACP equ 6 ; task is an ACP 48 | TA.CKD equ 7 ; checkpointing disabled 49 | 50 | ; Status bit numbers 51 | 52 | TS.ACT equ 0 ; task active 53 | TS.AST equ 1 ; task is executing an AST 54 | TS.SUP equ 2 ; task is in supervisor mode 55 | TS.CKR equ 3 ; checkpoint requested 56 | 57 | T2.STP equ 0 ; stopped \ 58 | T2.SEF equ 1 ; stopped for event flag | 59 | T2.EFW equ 2 ; event flag waiting | "blocking" bits: 60 | T2.WTD equ 3 ; waiting for data | all zero means 61 | T2.OUT equ 4 ; task is out of memory | task is executing 62 | T2.CKP equ 5 ; task is checkpointed | 63 | T2.LDR equ 6 ; task is being loaded | 64 | T2.ABO equ 7 ; task is being aborted / 65 | 66 | ; Task Context Block structure 67 | 68 | TX.UID equ 0 ; protection user ID (1 byte) 69 | TX.GID equ TX.UID + 1 ; protection group ID (1 byte) 70 | TX.DIR equ TX.GID + 1 ; task's current directory (9 bytes) 71 | TX.SWM equ TX.DIR + 9 ; saved flag wait mask during AST (4 bytes) 72 | TX.LUT equ TX.SWM + 4 ; LUN translation table (64 bytes) 73 | TX.SST equ TX.LUT + 64 ; user SST vector table (2 bytes) 74 | TX.REGS equ TX.SST + 2 ; saved registers (28 bytes) 75 | 76 | ; Context Block size 77 | 78 | CTXSZ equ TX.REGS + 28 79 | 80 | ; Task Descriptor Block 81 | 82 | TD.NAME equ 0 ; task name (6 characters) 83 | TD.CMD equ TD.NAME + 6 ; address of command line block (2 bytes) 84 | TD.CML equ TD.CMD + 2 ; length of command (2 bytes) 85 | TD.ATTR equ TD.CML + 2 ; initial attributes (1 byte) 86 | TD.USR equ TD.ATTR + 1 ; user number (1 byte) 87 | TD.GRP equ TD.USR + 1 ; group number (1 byte) 88 | TD.TI equ TD.GRP + 1 ; console device and unit (3 bytes) 89 | TD.SDAT equ TD.TI + 3 ; address of data block to send (2 bytes) 90 | TD.SLEN equ TD.SDAT + 2 ; size of data block to send (2 bytes) 91 | 92 | ; TDB size 93 | 94 | TDBSZ equ TD.SLEN + 2 95 | 96 | ; Offspring Control Block 97 | 98 | O.LNK equ 0 ; link to next OCB in list (2 bytes) 99 | O.PTCB equ O.LNK + 2 ; address of parent's TCB (2 bytes) 100 | O.EFN equ O.PTCB + 2 ; event flag number (1 byte) 101 | O.ESB equ O.EFN + 1 ; addr of parent's exit status block (2 bytes) 102 | O.ST equ O.ESB + 2 ; status (2 bytes) 103 | 104 | ; OCB size 105 | 106 | OCBSZ equ O.ST + 2 107 | 108 | ; Structure returned by the .GTSK Get Task Info system call 109 | 110 | GT.ATTR equ 0 ; task attributes (1 byte) 111 | GT.ST equ GT.ATTR + 1 ; task status (2 bytes) 112 | GT.DPRI equ GT.ST + 2 ; default priority (1 byte) 113 | GT.PRI equ GT.DPRI + 1 ; current priority (1 byte) 114 | GT.NAME equ GT.PRI + 1 ; task name (6 characters) 115 | GT.VID equ GT.NAME + 6 ; task version identification (6 characters) 116 | GT.TI equ GT.VID + 6 ; console device and unit (3 bytes) 117 | GT.LDEV equ GT.TI + 3 ; load device and unit (3 bytes) 118 | GT.SBLK equ GT.LDEV + 3 ; task starting disk block number (4 bytes) 119 | GT.NBLK equ GT.SBLK + 4 ; task size in disk blocks (2 bytes) 120 | GT.PAR equ GT.NBLK + 2 ; partition name (6 bytes) 121 | GT.STRT equ GT.PAR + 6 ; start address (2 bytes) 122 | GT.DEND equ GT.STRT + 2 ; default end address (2 bytes) 123 | GT.END equ GT.DEND + 2 ; end address (2 bytes) 124 | GT.EPT equ GT.END + 2 ; entry point (2 bytes) 125 | 126 | ; GTIB size 127 | 128 | GTKSZ equ GT.EPT + 2 129 | 130 | -------------------------------------------------------------------------------- /test/error_check/dudops.mac: -------------------------------------------------------------------------------- 1 | ORG 2 | ORG 0100H 3 | ; 4 | nnnn: EQU 1234H 5 | DE: EQU 6789H 6 | INDEX EQU 10 7 | LABEL EQU 1234H 8 | ; 9 | EQU 10 | ; 11 | LBL1, EQU 1234H 12 | LBL2+ EQU 1234H 13 | ; 14 | RLC Z 15 | ; 16 | CALL 17 | CALL 18 | CALL ;NOTHING 19 | CALL Z, 20 | CALL Z, 21 | CALL Z, ;LABEL 22 | CALL (HL) 23 | ; 24 | LABEL2 EQU $ 25 | ; 26 | JR 27 | JR 28 | JR ;NOTHING 29 | JR Z, 30 | JR Z, 31 | JR Z, ;LABEL2 32 | JR Z,(HL) 33 | ; 34 | JP Z,(HL) 35 | JP (XL) ;HP 36 | JP (QX) ;HP 37 | JP (5Y) ;HP 38 | ; 39 | RST 40 | RST ;NOTHING 41 | ; 42 | RET EQU 1234H 43 | ; 44 | ADD 45 | ADD ;A 46 | ADD ;(IX+INDEX) 47 | ; 48 | ADD A, 49 | ADD A, ; 50 | ADD A:B ;HP 51 | ADD A@B ;HP 52 | ; 53 | ADD HL, 54 | ADD HL, 55 | ADD HL:BC ;HP 56 | ADD HL@BC ;HP 57 | ; 58 | ADD BC,DE ;HP 59 | ADD BC,HL ;HP 60 | ADD BC,IX ;HP 61 | ADD BC,IY ;HP 62 | ADD BC,SP ;HP 63 | 64 | ADD DE,BC ;HP 65 | ADD DE,HL ;HP 66 | ADD DE,IX ;HP 67 | ADD DE,IY ;HP 68 | ADD DE,SP ;HP 69 | 70 | ADD SP,BC ;HP 71 | ADD SP,DE ;HP 72 | ADD SP,HL ;HP 73 | ADD SP,IX ;HP 74 | ADD SP,IY ;HP 75 | 76 | ADD HL,IX ;HP 77 | ADD HL,IY ;HP 78 | 79 | ADD IX,BC ;OK 80 | ADD IX,DE ;OK 81 | ADD IX,HL ;HP 82 | ADD IX,IY ;HP 83 | ADD IX,SP ;OK 84 | 85 | ADD IY,BC ;OK 86 | ADD IY,DE ;OK 87 | ADD IY,HL ;HP 88 | ADD IY,IX ;HP 89 | ADD IY,SP ;OK 90 | ; 91 | ADC BC,DE ;HP 92 | ADC BC,HL ;HP 93 | ADC BC,IX ;HP 94 | ADC BC,IY ;HP 95 | ADC BC,SP ;HP 96 | 97 | ADC DE,BC ;HP 98 | ADC DE,HL ;HP 99 | ADC DE,IX ;HP 100 | ADC DE,IY ;HP 101 | ADC DE,SP ;HP 102 | 103 | ADC SP,BC ;HP 104 | ADC SP,DE ;HP 105 | ADC SP,HL ;HP 106 | ADC SP,IX ;HP 107 | ADC SP,IY ;HP 108 | 109 | ADC HL,IX ;HP 110 | ADC HL,IY ;HP 111 | 112 | ADC IX,BC ;Z280 113 | ADC IX,DE ;Z280 114 | ADC IX,HL ;HP 115 | ADC IX,IY ;HP 116 | ADC IX,SP ;Z280 117 | 118 | ADC IY,BC ;Z280 119 | ADC IY,DE ;Z280 120 | ADC IY,HL ;HP 121 | ADC IY,IX ;HP 122 | ADC IY,SP ;Z280 123 | ; 124 | ADD B,C 125 | ADD Z,A 126 | ADD A,Z 127 | ADD Z,(HL) 128 | ADD Z,(IX+INDEX) 129 | ADD Z,Z 130 | ADD IX,NZ 131 | ADD HL,NZ 132 | ; 133 | ADC C,B 134 | SBC H,A 135 | ; 136 | AND A,(HL) 137 | AND A,B 138 | AND B,A 139 | AND HL,BC 140 | ; 141 | ADC IX,BC 142 | SBC IX,SP 143 | ; 144 | ADD A,BC 145 | ADD BC,A 146 | ADC BC,A 147 | ; 148 | ADD BC,RET 149 | ; 150 | IN Z,(C) 151 | ; 152 | CP ;Should generate a syntax error (*** but 153 | CP ; 154 | CP 155 | CP 156 | ; 157 | EX AF,BC 158 | EX AF,DE 159 | EX AF,HL 160 | EX IX,IY 161 | EX DE,HL 162 | EX DE,IX 163 | EX DE,IY 164 | EX IX,HL 165 | EX (SP),DE 166 | ; 167 | LD A;B ;HP 168 | LD A:B ;HP 169 | ; 170 | LD (nnnn),B 171 | LD (nnnn),C 172 | LD (nnnn),D 173 | LD (nnnn),E 174 | ; 175 | LD B,(nnnn) 176 | LD C,(nnnn) 177 | LD D,(nnnn) 178 | LD E,(nnnn) 179 | ; 180 | LD A 181 | Should generate a 182 | ; 183 | LD A ;Should generate a 184 | LD B ;Should 185 | ; 186 | LD A ;Should generate a syntax error (*** but doesn't ***) 187 | ;HP 188 | LD A,' 189 | LD A,'a 190 | LD A,'aa' 191 | LD A,'aaa' 192 | LD A,(DE% 193 | ;HP 194 | LD HL,' 195 | LD HL,'a 196 | LD HL,'aa 197 | LD HL,'aaa 198 | ; 199 | LD A,DE 200 | LD B,DE 201 | LD C,DE 202 | LD D,DE 203 | LD E,DE 204 | ; 205 | LD A,BC 206 | LD B,BC 207 | LD C,BC 208 | LD D,BC 209 | LD E,BC 210 | ; 211 | LD A,HL 212 | LD B,HL 213 | LD C,HL 214 | LD D,HL 215 | LD E,HL 216 | ; 217 | LD A,AF 218 | LD B,AF 219 | LD C,AF 220 | LD D,AF 221 | LD E,AF 222 | ; 223 | LD BC,AF 224 | LD AF,1234H 225 | ; 226 | NN: EQU 0AAH 227 | ; 228 | LD HL ;nnnn 229 | LD DE ;nnnn 230 | LD SP ;HL 231 | LD SP ;(nnnn) 232 | LD (nnnn) 233 | LD (nnnn), 234 | LD (nnnn) ;DE 235 | LD (nnnn), ;DE 236 | LD (HL) 237 | LD (HL), 238 | LD (HL),;DE NN 239 | LD (HL) ;NN 240 | LD (HL),DE 241 | LD (HL),HL 242 | LD (IX+INDEX),HL 243 | LD (IX+HL),C 244 | LD IX,NZ 245 | LD BC,DEFB 246 | LD HL,(HL) 247 | LD HL,(DE) 248 | ; 249 | LD A,(B) 250 | LD A,(C) 251 | ; 252 | LD 2,2 253 | LD 7,2 254 | LD 7,7 255 | ; 256 | ; 257 | LD (NZ),Z 258 | LD (NZ),P 259 | LD (NZ),C 260 | LD (NZ),D 261 | LD (NZ),E 262 | LD (NZ),H 263 | LD (NZ),L 264 | LD (NZ),NN 265 | ; 266 | LD (IX),Z 267 | LD (IX+INDEX),Z 268 | LD (IX-INDEX),Z 269 | LD (IX),P 270 | LD (IX+INDEX),P 271 | LD (IX-INDEX),P 272 | ; 273 | LD (IY),Z 274 | LD (IY+INDEX),Z 275 | LD (IY-INDEX),Z 276 | LD (IY),P 277 | LD (IY+INDEX),P 278 | LD (IY-INDEX),P 279 | ; 280 | LD (NNNN),Z 281 | LD (NNNN),NZ 282 | ; 283 | LD Z,(DE) 284 | LD Z,(NZ) 285 | LD Z,(IX) 286 | LD Z,(IX+INDEX) 287 | LD Z,(IX-INDEX) 288 | LD Z,(IY) 289 | LD Z,(IY+INDEX) 290 | LD Z,(IY-INDEX) 291 | LD Z,(NNNN) 292 | LD Z,Z 293 | LD Z,P 294 | LD Z,C 295 | LD Z,D 296 | LD Z,E 297 | LD Z,H 298 | LD Z,L 299 | LD Z,NN 300 | ; 301 | LD P,(NZ) 302 | LD P,(IX) 303 | LD P,(IX+INDEX) 304 | LD P,(IX-INDEX) 305 | LD P,(IY) 306 | LD P,(IY+INDEX) 307 | LD P,(IY-INDEX) 308 | LD P,Z 309 | LD P,P 310 | LD P,C 311 | LD P,D 312 | LD P,E 313 | LD P,H 314 | LD P,L 315 | LD P,NN 316 | ; 317 | IF 318 | ENDIF 319 | ; 320 | LD C,(NZ) 321 | LD C,Z 322 | LD C,P 323 | ; 324 | LD D,(NZ) 325 | LD D,Z 326 | LD D,P 327 | ; 328 | LD E,(NZ) 329 | LD E,Z 330 | LD E,P 331 | ; 332 | LD H,(NZ) 333 | LD H,Z 334 | LD H,P 335 | ; 336 | LD NZ,(NNNN) 337 | LD NZ,NNNN 338 | ; 339 | LD L,(NZ) 340 | LD L,Z 341 | LD L,P 342 | ; 343 | LD SP,NZ 344 | ; 345 | IN 5 ;HP 346 | IN (5) ;HP 347 | IN A%(C) ;HP 348 | IN A, ( C ) ;HP 349 | OUT (C)%A ;HP 350 | ; 351 | POP 352 | POP 353 | POP ; 354 | POP 3 355 | POP A 356 | POP H 357 | POP L 358 | POP SP 359 | POP $ 360 | ; 361 | POP NZ 362 | POP Z 363 | ; 364 | BIT 365 | BIT ; 366 | BIT 8,B 367 | BIT 9,A 368 | BIT 2,2 369 | ; 370 | BIT 2,Z 371 | ; 372 | INC NZ 373 | INC Z 374 | ; 375 | DEFS 376 | DEFS 377 | DEFS ; 378 | ; 379 | DEFB 380 | DEFB ; 381 | DEFB 2,2, 382 | DEFB ,2,2, 383 | DEFB 2,2, 384 | DEFB 'ABC ;HP 385 | ; 386 | DEFW 387 | DEFW ; 388 | DEFW 1234, 389 | DEFW ,1234 390 | DEFW 1234,4567, 391 | DEFW 1234,4567, 392 | DEFW 'ABCDE' 393 | DEFW 'ABC ;HP 394 | ; 395 | LABEL3 EQU 1234H 396 | ; 397 | LABEL3: LD A,B 398 | LABEL3 LD A,B 399 | ; 400 | BELAB: EQU 4567H 401 | ; 402 | BELAB LD A,B 403 | BELAB: LD A,B 404 | ; 405 | BEBLAB: EQU 0AABBH 406 | BEBLAB: EQU 0CCDDH 407 | ; 408 | ABLAB EQU 8899H 409 | ABLAB EQU 0EEFFH 410 | ; 411 | ; 412 | LABEL4 EQU 0AABBH 413 | ; 414 | LD A,LABEL4 . HIGH . 415 | LD A,.HIGH. LABEL4 416 | LD A,LABEL4 HIGH 417 | LD A,HIGH LABEL4 418 | ; 419 | LD A,LOW LABEL4 420 | LD A,LABEL4 LOW 421 | ; 422 | DEFB HIGH LABEL4 423 | DEFB LABEL4 HIGH 424 | DEFW LABEL4 HIGH 425 | ; 426 | DEFB LOW LABEL4 427 | DEFB LABEL4 LOW 428 | DEFW LABEL4 LOW 429 | ; 430 | LABEL: DB 0 ;Define once.... 431 | LABEL: DB 0 ;Twice for an error (Actualy this three times...!!!) 432 | ; 433 | DEFW 1234H * -1 434 | ; 435 | LIST 436 | ;The next four lines are junk to see if it is listed. 437 | LD A,B 438 | LD B,A 439 | NOP 440 | NOP 441 | ; 442 | END 443 |  -------------------------------------------------------------------------------- /genrel.mac: -------------------------------------------------------------------------------- 1 | ;**********************************************************************; 2 | ; ; 3 | ; This file is part of ZSM4, a Z80/Z180/Z280 relocatable macro- ; 4 | ; assembler written in Z80 assembly. ; 5 | ; Copyright (C) 2017-2020, Hector Peraza. ; 6 | ; ; 7 | ; This program is free software; you can redistribute it and/or ; 8 | ; modify it under the terms of the GNU General Public License as ; 9 | ; published by the Free Software Foundation; either version 2 of ; 10 | ; the License, or (at your option) any later version. ; 11 | ; ; 12 | ; This program is distributed in the hope that it will be useful, ; 13 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; 14 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; 15 | ; GNU General Public License for more details. ; 16 | ; ; 17 | ; You should have received a copy of the GNU General Public License ; 18 | ; along with this program; if not, write to the Free Software ; 19 | ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; 20 | ; ; 21 | ;**********************************************************************; 22 | 23 | TITLE Z80/Z180/Z280 Macro-Assembler 24 | SUBTTL REL file generation 25 | 26 | .Z80 27 | 28 | include ZSM.INC 29 | 30 | cseg 31 | 32 | public WMNAME,WIDENT,WCSIZE,WDSIZE,WLOC,WOBJ,WOBJ16 33 | public WENTRY,WDFENT,WDFEXT,WCMSIZ,WSELCM,WEOFFS,WRQST 34 | public INIOBJ,CLSOBJ 35 | 36 | extrn OFLAG,CLOSE2,WNB2,NAMLEN 37 | ; 38 | ; WMNAME - Write module name, HL = name, E = length 39 | ; This is normally the first item in a REL file 40 | ; 41 | WMNAME: ld c,84h ; 1 00 0010 - special item: program name 42 | ld b,7 43 | call WRBITS 44 | jp WRNAME 45 | ; 46 | ; WRQST - Write request library search, HL = name, E = length 47 | ; 48 | WRQST: ld c,86h ; 1 00 0011 - special item: request library 49 | ld b,7 50 | call WRBITS 51 | jp WRNAME 52 | ; 53 | ; WIDENT - Write ident, HL = name, E = length 54 | ; Used by RSX180 55 | ; 56 | WIDENT: ld c,88h ; 1 00 0100 - special item: extension link 57 | ld b,7 58 | call WRBITS 59 | ld a,e 60 | inc a 61 | rrca 62 | rrca 63 | rrca 64 | ld c,a 65 | ld b,3 66 | call WRBITS ; write length 67 | ld c,'I' 68 | call WR8B ; write type 69 | jp WRN1 ; output name 70 | 71 | IF 0 72 | ; 73 | ; WALIGN - Write segment alignment information, C = seg type, 74 | ; B = align bits [Not yet implemented] 75 | ; 76 | WALIGN: push bc 77 | ld c,88h ; 1 00 0100 - special item: extension link 78 | ld b,7 79 | call WRBITS 80 | ld c,40h ; 010 - len = 2 81 | ld b,3 82 | call WRBITS ; write length 83 | ld c,'L' 84 | call WR8B ; write type 85 | pop bc 86 | ld a,b 87 | and 0Fh 88 | or c 89 | ld c,a 90 | jp WR8B ; write segment and alignment 91 | 92 | ENDIF 93 | ; 94 | ; WOBJ - Write absolute byte in A 95 | ; 96 | WOBJ: push af 97 | ld c,0 98 | call WRBIT ; 0 - load next 8 bits 99 | pop af 100 | ld c,a 101 | jp WR8B 102 | ; 103 | ; WBOJ16 - Write relative word in HL, C = seg type. 104 | ; 105 | WOBJ16: ld a,c 106 | or a 107 | jr z,W2X8 108 | scf 109 | rr c ; push '1' bit - reloc item 110 | ld b,3 111 | call WRBITS ; output bit and seg type 112 | ld c,l 113 | ld b,h 114 | call WR16B ; output word value 115 | ret 116 | W2X8: ld a,l 117 | call WOBJ 118 | ld a,h 119 | jp WOBJ 120 | ; 121 | ; WCSIZE - Write CSEG size: HL = size 122 | ; 123 | WCSIZE: ld c,9Ah ; 1 00 1101 - special item: define cseg size 124 | ld b,7 125 | call WRBITS 126 | ld c,40h ; program relative value follows 127 | ld b,2 128 | call WRBITS 129 | ld c,l 130 | ld b,h 131 | jp WR16B ; output size 132 | ; 133 | ; WDSIZE - Write DSEG size: HL = size 134 | ; Note: L80 wants an 'absolute' argument and not a 'data-relative' one 135 | ; as one would expect. DR LINK does not care. 136 | ; 137 | WDSIZE: ld c,94h ; 1 00 1010 - special item: define dseg size 138 | ld b,7 139 | call WRBITS 140 | ;-- ld c,80h ; data relative value follows 141 | ld c,00h ; absolute value follows (L80 wants it that way) 142 | ld b,2 143 | call WRBITS 144 | ld c,l 145 | ld b,h 146 | jp WR16B ; output size 147 | ; 148 | ; WLOC - Write loc counter: HL = address, E = seg type (40h = CSEG, 149 | ; 80h = DSEG, 0C0h = COMMON) 150 | ; 151 | WLOC: ld c,96h 152 | WLC1: ld b,7 153 | call WRBITS ; 1 00 1011 - special item: set loc counter 154 | ld c,e 155 | ld b,2 156 | call WRBITS ; segment-relative value follows 157 | ld c,l 158 | ld b,h 159 | jp WR16B ; output address 160 | ; 161 | ; WENTRY - Write entry symbol record: HL = name, E = length 162 | ; 163 | WENTRY: ld c,80h ; 1 00 0000 - special item: entry symbol 164 | ld b,7 165 | call WRBITS 166 | jp WRNAME 167 | ; 168 | ; WDFENT - Write entry point record: DE = address, C = seg type, 169 | ; HL = name, B = length 170 | ; 171 | WDFENT: push bc 172 | ld c,8Eh ; 1 00 0111 - special item: define entry point 173 | WRENT1: ld b,7 174 | call WRBITS 175 | pop bc 176 | push bc 177 | ld b,2 178 | call WRBITS ; segment-relative value follows 179 | ld c,e 180 | ld b,d 181 | call WR16B ; output address 182 | pop bc 183 | ld e,b 184 | jp WRNAME 185 | ; 186 | ; WDFEXT - Write External chain head: DE = address, C = seg type, 187 | ; HL = name, B = length 188 | ; 189 | WDFEXT: push bc 190 | ld c,8Ch ; 1 00 0110 - special item: chain external 191 | jr WRENT1 192 | ; 193 | ; WSELCM - Write Select COMMON block: HL = name, B = length 194 | ; 195 | WSELCM: ld c,82h ; 1 00 0001 - special item: program name 196 | ld b,7 197 | call WRBITS 198 | jp WRNAME 199 | ; 200 | ; WCMSIZ - Write COMMON size record: DE = size, C = seg type, 201 | ; HL = name, B = length 202 | ; 203 | WCMSIZ: push bc 204 | ld c,8Ah ; 1 00 0101 - special item: define COMMON size 205 | jr WRENT1 206 | ; 207 | ; WEOFFS - Write External + Offset entry: HL = offset, E = seg type 208 | ; 209 | WEOFFS: ld c,92h ; 1 00 1001 210 | jr WLC1 211 | ; 212 | ; BPAD - Pad to byte boundary (end of module) 213 | ; 214 | BPAD: ld a,(BITCNT) 215 | cp 8 216 | ret z 217 | ld c,0 218 | call WRBIT ; pad to byte boundary 219 | jr BPAD 220 | ; 221 | ; WRNAME - Write name field (len + chars), HL points to string, 222 | ; E = length 223 | ; 224 | WRNAME: ld a,(NAMLEN) 225 | cp e 226 | jr nc,WRN0 227 | ld e,a ; truncate to max REL symbol length 228 | WRN0: ld a,e ; length 229 | rrca ; shift left 5 (same as shift right 3) 230 | rrca 231 | rrca 232 | ld c,a 233 | ld b,3 234 | call WRBITS 235 | WRN1: ld c,(hl) 236 | inc hl 237 | call WR8B 238 | dec e 239 | jr nz,WRN1 240 | ret 241 | ; 242 | ; WR16B - Write 16 bits, word in BC 243 | ; 244 | WR16B: push bc 245 | call WR8B 246 | pop bc 247 | ld c,b 248 | ; fall thru 249 | ; 250 | ; WR8B - Write 8 bits, byte in C 251 | ; 252 | WR8B: ld b,8 253 | ; fall thru 254 | ; 255 | ; WRBITS - Write up to 8 bits, bits in reg C, num of bits in B 256 | ; 257 | WRBITS: call WRBIT 258 | djnz WRBITS 259 | ret 260 | ; 261 | ; WRBIT - Write a single bit, bit is in MSB of C 262 | ; 263 | WRBIT: ld a,(BITCNT) 264 | cp 8 265 | jr nz,WB1 266 | ld a,(OFLAG) 267 | cp 'O' ; check if REL file specified 268 | ld a,(BYTE) 269 | push bc 270 | call c,WNB2 ; write byte to REL file 271 | pop bc 272 | xor a 273 | WB1: inc a 274 | ld (BITCNT),a 275 | rl c 276 | ld a,(BYTE) 277 | rla 278 | ld (BYTE),a 279 | ret 280 | 281 | INIOBJ: xor a 282 | ld (BYTE),a 283 | ld (BITCNT),a 284 | ret 285 | ; 286 | ; CLSOBJ - Write end of module record, end of file record, and 287 | ; close object file. 288 | ; 289 | CLSOBJ: ld a,(OFLAG) 290 | cp 'O' 291 | ret nc ; return if no REL file output 292 | push hl 293 | push bc 294 | ld c,9Ch 295 | ld b,7 296 | call WRBITS ; 1 00 1110 - special item: end of module 297 | pop bc 298 | ld b,2 299 | call WRBITS ; segment relative value follows 300 | pop bc 301 | call WR16B ; 0000' 302 | call BPAD ; pad to byte boundary 303 | ld c,9Eh 304 | ld b,7 305 | call WRBITS ; 1 00 1111 - special item: end of file 306 | call BPAD ; pad to byte boundary 307 | ld a,(BYTE) 308 | call WNB2 309 | jp CLOSE2 ; close REL file 310 | 311 | DSEG 312 | 313 | BITCNT: ds 1 ; bit counter 314 | BYTE: ds 1 ; bit accumulator 315 | 316 | END 317 | -------------------------------------------------------------------------------- /symbols.mac: -------------------------------------------------------------------------------- 1 | ;**********************************************************************; 2 | ; ; 3 | ; This file is part of ZSM4, a Z80/Z180/Z280 relocatable macro- ; 4 | ; assembler written in Z80 assembly. ; 5 | ; Copyright (C) 2017-2020, Hector Peraza. ; 6 | ; ; 7 | ; This work is derived from Z80ASM, originally written by Michael ; 8 | ; G. Lehman (1977) and with modifications by Ray Halls (1992) and ; 9 | ; Neil Harrison (1983). ; 10 | ; ; 11 | ; This program is free software; you can redistribute it and/or ; 12 | ; modify it under the terms of the GNU General Public License as ; 13 | ; published by the Free Software Foundation; either version 2 of ; 14 | ; the License, or (at your option) any later version. ; 15 | ; ; 16 | ; This program is distributed in the hope that it will be useful, ; 17 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; 18 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; 19 | ; GNU General Public License for more details. ; 20 | ; ; 21 | ; You should have received a copy of the GNU General Public License ; 22 | ; along with this program; if not, write to the Free Software ; 23 | ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; 24 | ; ; 25 | ;**********************************************************************; 26 | 27 | TITLE Z80/Z180/Z280 Macro-Assembler 28 | SUBTTL Symbol table routines 29 | 30 | .Z80 31 | 32 | include ZSM.INC 33 | 34 | public ID,ADDSYM,SYMLUK,FNDOPC,VALID,VALID1,WERROR 35 | 36 | extrn GNC,PTR1,UCASE,IDBUF,IDLEN,MCHECK,ERRFLG 37 | extrn NEWSYM,SYMTBL,SYMADR,IDADR,VAL,CMNPTR 38 | extrn SYMPTR,SYMMOD,OPCODES,OPLEN,EVFLGS 39 | ; 40 | ; ID - Collect ID and place in IDBUF 41 | ; Returns delimiter character in A, symbol length in IDLEN 42 | ; 43 | ID: push hl 44 | push de 45 | push bc ; save regs 46 | ld de,IDBUF 47 | ld b,IDMAX 48 | call GNC ; skip blanks, get char, convert to uppercase 49 | call VALID1 50 | jr c,LERROR ; error if not a valid starting char 51 | ld hl,(PTR1) 52 | jr ID3 53 | ; 54 | ID2: ld a,(hl) 55 | call UCASE ; convert to uppercase 56 | call VALID 57 | jr c,ID4 58 | inc hl 59 | ID3: ld (de),a 60 | inc de 61 | djnz ID2 62 | ID7: ld a,(hl) 63 | call UCASE 64 | call VALID 65 | jr c,ID4 66 | inc hl 67 | jr ID7 68 | ; 69 | ID4: ld (PTR1),hl 70 | ID6: cp ';' 71 | jr nz,ID9 72 | ID8: xor a 73 | ID9: ld c,a 74 | ld a,IDMAX 75 | sub b 76 | ld (IDLEN),a ; store symbol length 77 | ld a,c 78 | pop bc 79 | pop de 80 | pop hl 81 | ret 82 | ; 83 | LERROR: ld a,'L' 84 | ld (ERRFLG),a 85 | jr ID8 86 | ; 87 | VALID: call ISDIG 88 | ret nc 89 | VALID1: call ISLETR 90 | ret nc 91 | cp '_' 92 | ret z 93 | cp '$' 94 | ret z 95 | cp '?' 96 | ret z 97 | cp '.' 98 | ret z 99 | cp '@' 100 | ret z 101 | scf 102 | ret 103 | ; 104 | ISDIG: cp '0' 105 | ret c 106 | cp '9'+1 107 | ccf 108 | ret 109 | ; 110 | ISLETR: cp 'A' 111 | ret c 112 | cp 'Z'+1 113 | ccf 114 | ret 115 | ; 116 | ; ADDSYM - Add symbol to symbol table, if not already there 117 | ; 118 | ; Upon entry, IDBUF contains the symbol name and IDLEN its length. 119 | ; 120 | ; On return, HL and SYMADR point to value low byte in new entry for 121 | ; possible further update, and IDADR is set to the address of the 122 | ; length+flags field. 123 | ; 124 | ; Z=1 if symbol already there, Z=0 otherwise. 125 | ; 126 | ; Initial flags field is cleared. 127 | ; Initial value is set to (VAL) and mode to (SYMMOD). 128 | ; 129 | ADDSYM: xor a 130 | ld (NEWSYM),a 131 | ld de,(SYMTBL) ; no conflict with reg names 132 | ld c,5 133 | call SYMLUK ; lookup symbol 134 | push hl ; save table ptr 135 | ld (SYMADR),hl ; save address for EQU 136 | ld (IDADR),de 137 | pop hl ; restore symbol table ptr 138 | ret nc ; return if already there, else continue below 139 | ; 140 | ; SYMENT - Enter a symbol into the symbol table 141 | ; Upon entry IDBUF is assumed to contain the name of the symbol 142 | ; to enter, name length in IDLEN. 143 | ; 144 | ; Entry format: flags/length (each 4 bits) 145 | ; n a m e ... (up to 16 bytes) 146 | ; value (2 bytes) 147 | ; address mode (1 byte) 148 | ; pointer to COMMON def (2 bytes) 149 | ; 150 | ; On return HL points to value low byte in new entry for possible 151 | ; further update (used by EQU pseudo operator) 152 | ; 153 | SYMENT: ld bc,IDMAX+6+1 ; max entry length + end marker 154 | call MCHECK ; check for available memory 155 | jr nc,SYMEN1 ; jump if enough 156 | WERROR: ld a,'W' 157 | ld (ERRFLG),a 158 | ret 159 | ; 160 | SYMEN1: ld a,(IDLEN) 161 | or a 162 | jr nz,SYMEN2 163 | ld a,'L' 164 | ld (ERRFLG),a 165 | scf 166 | ret ; else label error 167 | ; 168 | SYMEN2: ld hl,(SYMPTR) 169 | ld (IDADR),hl ; HL = dest ptr 170 | ld c,a 171 | ld b,0 172 | ld (hl),a ; set up length, clear flags 173 | inc hl 174 | ex de,hl ; DE = dst 175 | ld hl,IDBUF ; HL = src 176 | ldir ; copy name 177 | ld hl,(VAL) 178 | ex de,hl ; switch registers 179 | push hl 180 | ld (hl),e ; set value 181 | inc hl 182 | ld (hl),d 183 | inc hl 184 | ld a,(SYMMOD) 185 | ld (hl),a ; set mode 186 | inc hl 187 | ld de,(CMNPTR) 188 | ld (hl),e 189 | inc hl 190 | ld (hl),d 191 | inc hl 192 | ld (SYMPTR),hl 193 | ld (hl),0 ; set up new pointer and new end marker 194 | pop hl 195 | ld (SYMADR),hl ; save address for EQU 196 | or 0FFh ; set Z=0 197 | ld (NEWSYM),a 198 | ret 199 | ; 200 | ; SYMLUK - Look up symbols in table 201 | ; 202 | ; On entry, DE points to table to search and C contains data field 203 | ; length. Symbol name in IDBUF and length in IDLEN. 204 | ; 205 | ; On return, CY set means symbol not found. 206 | ; Else DE points to start of table entry and HL to value low byte 207 | ; in table entry. 208 | ; 209 | SYMLUK: ld a,(IDLEN) 210 | ld b,a 211 | inc c ; include flags+length field 212 | SYML1: ld a,(de) 213 | or a 214 | scf 215 | ret z ; return if end of table 216 | and 0Fh ; get length of symbol 217 | cp b 218 | jr nz,SYML4 219 | push de 220 | push bc 221 | inc de ; skip length 222 | ld hl,IDBUF 223 | SYML2: ld a,(de) 224 | cp (hl) 225 | jr nz,SYML3 226 | inc hl 227 | inc de 228 | djnz SYML2 229 | SYML3: pop bc 230 | pop de 231 | jr z,SYML5 ; branch if match 232 | ld a,b 233 | SYML4: add a,c ; get full entry length 234 | ld l,a 235 | ld h,0 236 | add hl,de 237 | ex de,hl 238 | jr SYML1 ; advance pointer and continue to loop 239 | ; 240 | SYML5: ld a,(de) 241 | ld b,a 242 | and 0F0h 243 | ld (EVFLGS),a ; save for main processor 244 | ld a,b 245 | and 0Fh 246 | ld l,a 247 | ld h,0 248 | add hl,de 249 | inc hl 250 | xor a 251 | ret ; point to value low and exit 252 | ; 253 | ; Search opcode table using a binary search 254 | ; 255 | FNDOPC: ld a,(IDLEN) 256 | sub 2 257 | ret c 258 | cp 8+1-2 259 | ccf 260 | ret c 261 | ld c,a 262 | ld b,0 263 | ld hl,OPLEN 264 | add hl,bc 265 | ex de,hl 266 | ld hl,OPCODES 267 | add hl,bc 268 | add hl,bc 269 | add a,4+2 270 | ld c,a ; save item size 271 | ld a,(hl) 272 | inc hl 273 | ld h,(hl) 274 | ld l,a ; get table base address into HL 275 | ld a,(de) 276 | ld b,a ; get number of table items into B 277 | ld d,c ; get item size into D 278 | 279 | ; binary search 280 | 281 | ld e,0FFh ; mark M <> old M 282 | ld c,0 ; lower bound = 0 283 | BNEXT: ld a,b 284 | add a,c 285 | rra ; middle point = (upper+lower)/2 286 | cp e ; same as last time? 287 | scf 288 | ret z ; return error - not found 289 | 290 | ld e,a ; new middle value 291 | push hl ; table base addr 292 | push de 293 | push bc 294 | ld b,d ; get item size into B and C 295 | ld c,b ; for loop counting below 296 | 297 | ld d,0 ; DE = middle point 298 | BADD: add hl,de ; index into table (HL += DE times B) 299 | djnz BADD ; count and loop 300 | 301 | push hl 302 | inc hl ; address of byte to compare 303 | ld de,IDBUF 304 | ld a,c 305 | sub 4 306 | ld b,a ; B = string length 307 | BCMP: ld a,(de) 308 | cp (hl) 309 | inc de 310 | inc hl 311 | jr nz,DIFF ; branch if no match 312 | djnz BCMP 313 | pop hl ; match found 314 | pop bc 315 | pop de 316 | pop bc 317 | ld a,e ; return index in A 318 | ex de,hl 319 | jp SYML5 320 | 321 | DIFF: pop hl 322 | pop bc ; restore bounds 323 | pop de ; restore item size and middle point 324 | pop hl ; restore table base address 325 | jr c,LOWER ; IDBUF is lower 326 | ld c,e ; lower = middle 327 | jr BNEXT ; IDBUF is higher 328 | 329 | LOWER: ld b,e ; upper = middle 330 | jr BNEXT ; IDBUF is lower 331 | 332 | end 333 | -------------------------------------------------------------------------------- /test/testz80.mac: -------------------------------------------------------------------------------- 1 | ; 2 | ; Z-80 Opcodes in Alphabetical Order 3 | ; 4 | ; This file is used to test the Z-80 cross-assembler. The opcodes are in 5 | ; alphabetical order rather than the usual numerical order so that I can 6 | ; compare the output to my Z-80 assembly-language reference card. 7 | ; 8 | DD EQU 05H 9 | EE EQU 30H 10 | NN EQU 0584H 11 | N EQU 20H 12 | 13 | ;------------------------------------------------------------------------------ 14 | ADC A, (HL) 15 | ADC A, (IX + DD) 16 | ADC A, (IY + DD) 17 | ADC A, A 18 | ADC A, B 19 | ADC A, C 20 | ADC A, D 21 | ADC A, E 22 | ADC A, H 23 | ADC A, L 24 | ADC A, N 25 | ;------------------------------------------------------------------------------ 26 | ADC HL, BC 27 | ADC HL, DE 28 | ADC HL, HL 29 | ADC HL, SP 30 | ;------------------------------------------------------------------------------ 31 | ADD A, (HL) 32 | ADD A, (IX + DD) 33 | ADD A, (IY + DD) 34 | ADD A, A 35 | ADD A, B 36 | ADD A, C 37 | ADD A, D 38 | ADD A, E 39 | ADD A, H 40 | ADD A, L 41 | ADD A, N 42 | ;------------------------------------------------------------------------------ 43 | ADD HL, BC 44 | ADD HL, DE 45 | ADD HL, HL 46 | ADD HL, SP 47 | ;------------------------------------------------------------------------------ 48 | ADD IX, BC 49 | ADD IX, DE 50 | ADD IX, IX 51 | ADD IX, SP 52 | ;------------------------------------------------------------------------------ 53 | ADD IY, BC 54 | ADD IY, DE 55 | ADD IY, IY 56 | ADD IY, SP 57 | ;------------------------------------------------------------------------------ 58 | AND (HL) 59 | AND (IX + DD) 60 | AND (IY + DD) 61 | AND A 62 | AND B 63 | AND C 64 | AND D 65 | AND E 66 | AND H 67 | AND L 68 | AND N 69 | ;------------------------------------------------------------------------------ 70 | BIT 0, (HL) 71 | BIT 0, (IX + DD) 72 | BIT 0, (IY + DD) 73 | BIT 0, A 74 | BIT 0, B 75 | BIT 0, C 76 | BIT 0, D 77 | BIT 0, E 78 | BIT 0, H 79 | BIT 0, L 80 | BIT 1, (HL) 81 | BIT 1, (IX + DD) 82 | BIT 1, (IY + DD) 83 | BIT 1, A 84 | BIT 1, B 85 | BIT 1, C 86 | BIT 1, D 87 | BIT 1, E 88 | BIT 1, H 89 | BIT 1, L 90 | BIT 2, (HL) 91 | BIT 2, (IX + DD) 92 | BIT 2, (IY + DD) 93 | BIT 2, A 94 | BIT 2, B 95 | BIT 2, C 96 | BIT 2, D 97 | BIT 2, E 98 | BIT 2, H 99 | BIT 2, L 100 | BIT 3, (HL) 101 | BIT 3, (IX + DD) 102 | BIT 3, (IY + DD) 103 | BIT 3, A 104 | BIT 3, B 105 | BIT 3, C 106 | BIT 3, D 107 | BIT 3, E 108 | BIT 3, H 109 | BIT 3, L 110 | BIT 4, (HL) 111 | BIT 4, (IX + DD) 112 | BIT 4, (IY + DD) 113 | BIT 4, A 114 | BIT 4, B 115 | BIT 4, C 116 | BIT 4, D 117 | BIT 4, E 118 | BIT 4, H 119 | BIT 4, L 120 | BIT 5, (HL) 121 | BIT 5, (IX + DD) 122 | BIT 5, (IY + DD) 123 | BIT 5, A 124 | BIT 5, B 125 | BIT 5, C 126 | BIT 5, D 127 | BIT 5, E 128 | BIT 5, H 129 | BIT 5, L 130 | BIT 6, (HL) 131 | BIT 6, (IX + DD) 132 | BIT 6, (IY + DD) 133 | BIT 6, A 134 | BIT 6, B 135 | BIT 6, C 136 | BIT 6, D 137 | BIT 6, E 138 | BIT 6, H 139 | BIT 6, L 140 | BIT 7, (HL) 141 | BIT 7, (IX + DD) 142 | BIT 7, (IY + DD) 143 | BIT 7, A 144 | BIT 7, B 145 | BIT 7, C 146 | BIT 7, D 147 | BIT 7, E 148 | BIT 7, H 149 | BIT 7, L 150 | ;------------------------------------------------------------------------------ 151 | CALL C, NN 152 | CALL M, NN 153 | CALL NC, NN 154 | CALL NZ, NN 155 | CALL P, NN 156 | CALL PE, NN 157 | CALL PO, NN 158 | CALL Z, NN 159 | ;------------------------------------------------------------------------------ 160 | CALL NN 161 | ;------------------------------------------------------------------------------ 162 | CCF 163 | ;------------------------------------------------------------------------------ 164 | CP (HL) 165 | CP (IX + DD) 166 | CP (IY + DD) 167 | CP A 168 | CP B 169 | CP C 170 | CP D 171 | CP E 172 | CP H 173 | CP L 174 | CP N 175 | ;------------------------------------------------------------------------------ 176 | CPD 177 | ;------------------------------------------------------------------------------ 178 | CPDR 179 | ;------------------------------------------------------------------------------ 180 | CPI 181 | ;------------------------------------------------------------------------------ 182 | CPIR 183 | ;------------------------------------------------------------------------------ 184 | CPL 185 | ;------------------------------------------------------------------------------ 186 | DAA 187 | ;------------------------------------------------------------------------------ 188 | DEC (HL) 189 | DEC (IX + DD) 190 | DEC (IY + DD) 191 | DEC A 192 | DEC B 193 | DEC BC 194 | DEC C 195 | DEC D 196 | DEC DE 197 | DEC E 198 | DEC H 199 | DEC HL 200 | DEC IX 201 | DEC IY 202 | DEC L 203 | DEC SP 204 | ;------------------------------------------------------------------------------ 205 | DI 206 | ;------------------------------------------------------------------------------ 207 | DJNZ $ + EE 208 | ;------------------------------------------------------------------------------ 209 | EI 210 | ;------------------------------------------------------------------------------ 211 | EX (SP), HL 212 | EX (SP), IX 213 | EX (SP), IY 214 | ;------------------------------------------------------------------------------ 215 | EX AF, AF' 216 | ;------------------------------------------------------------------------------ 217 | EX DE, HL 218 | ;------------------------------------------------------------------------------ 219 | EXX 220 | ;------------------------------------------------------------------------------ 221 | HALT 222 | ;------------------------------------------------------------------------------ 223 | IM 0 224 | IM 1 225 | IM 2 226 | ;------------------------------------------------------------------------------ 227 | IN A, (C) 228 | IN B, (C) 229 | IN C, (C) 230 | IN D, (C) 231 | IN E, (C) 232 | IN H, (C) 233 | IN L, (C) 234 | ;------------------------------------------------------------------------------ 235 | INC (HL) 236 | INC (IX + DD) 237 | INC (IY + DD) 238 | INC A 239 | INC B 240 | INC BC 241 | INC C 242 | INC D 243 | INC DE 244 | INC E 245 | INC H 246 | INC HL 247 | INC IX 248 | INC IY 249 | INC L 250 | INC SP 251 | ;------------------------------------------------------------------------------ 252 | IN A, (N) 253 | ;------------------------------------------------------------------------------ 254 | IND 255 | ;------------------------------------------------------------------------------ 256 | INDR 257 | ;------------------------------------------------------------------------------ 258 | INI 259 | ;------------------------------------------------------------------------------ 260 | INIR 261 | ;------------------------------------------------------------------------------ 262 | JP NN 263 | JP (HL) 264 | JP (IX) 265 | JP (IY) 266 | ;------------------------------------------------------------------------------ 267 | JP C, NN 268 | JP M, NN 269 | JP NC, NN 270 | JP NZ, NN 271 | JP P, NN 272 | JP PE, NN 273 | JP PO, NN 274 | JP Z, NN 275 | ;------------------------------------------------------------------------------ 276 | JR C, $ + EE 277 | JR NC, $ + EE 278 | JR NZ, $ + EE 279 | JR Z, $ + EE 280 | ;------------------------------------------------------------------------------ 281 | JR $ + EE 282 | ;------------------------------------------------------------------------------ 283 | LD (BC), A 284 | LD (DE), A 285 | LD (HL), A 286 | LD (HL), B 287 | LD (HL), C 288 | LD (HL), D 289 | LD (HL), E 290 | LD (HL), H 291 | LD (HL), L 292 | LD (HL), N 293 | LD (IX + DD), A 294 | LD (IX + DD), B 295 | LD (IX + DD), C 296 | LD (IX + DD), D 297 | LD (IX + DD), E 298 | LD (IX + DD), H 299 | LD (IX + DD), L 300 | LD (IX + DD), N 301 | LD (IY + DD), A 302 | LD (IY + DD), B 303 | LD (IY + DD), C 304 | LD (IY + DD), D 305 | LD (IY + DD), E 306 | LD (IY + DD), H 307 | LD (IY + DD), L 308 | LD (IY + DD), N 309 | LD (NN), A 310 | LD (NN), BC 311 | LD (NN), DE 312 | LD (NN), HL 313 | LD (NN), IX 314 | LD (NN), IY 315 | LD (NN), SP 316 | LD A, (BC) 317 | LD A, (DE) 318 | LD A, (HL) 319 | LD A, (IX + DD) 320 | LD A, (IY + DD) 321 | LD A, (NN) 322 | LD A, A 323 | LD A, B 324 | LD A, C 325 | LD A, D 326 | LD A, E 327 | LD A, H 328 | LD A, I 329 | LD A, L 330 | LD A, N 331 | LD A, R 332 | LD B, (HL) 333 | LD B, (IX + DD) 334 | LD B, (IY + DD) 335 | LD B, A 336 | LD B, B 337 | LD B, C 338 | LD B, D 339 | LD B, E 340 | LD B, H 341 | LD B, L 342 | LD B, N 343 | LD BC, (NN) 344 | LD BC, NN 345 | LD C, (HL) 346 | LD C, (IX + DD) 347 | LD C, (IY + DD) 348 | LD C, A 349 | LD C, B 350 | LD C, C 351 | LD C, D 352 | LD C, E 353 | LD C, H 354 | LD C, L 355 | LD C, N 356 | LD D, (HL) 357 | LD D, (IX + DD) 358 | LD D, (IY + DD) 359 | LD D, A 360 | LD D, B 361 | LD D, C 362 | LD D, D 363 | LD D, E 364 | LD D, H 365 | LD D, L 366 | LD D, N 367 | LD DE, (NN) 368 | LD DE, NN 369 | LD E, (HL) 370 | LD E, (IX + DD) 371 | LD E, (IY + DD) 372 | LD E, A 373 | LD E, B 374 | LD E, C 375 | LD E, D 376 | LD E, E 377 | LD E, H 378 | LD E, L 379 | LD E, N 380 | LD H, (HL) 381 | LD H, (IX + DD) 382 | LD H, (IY + DD) 383 | LD H, A 384 | LD H, B 385 | LD H, C 386 | LD H, D 387 | LD H, E 388 | LD H, H 389 | LD H, L 390 | LD H, N 391 | LD HL, (NN) 392 | LD HL, NN 393 | LD I, A 394 | LD IX, (NN) 395 | LD IX, NN 396 | LD IY, (NN) 397 | LD IY, NN 398 | LD L, (HL) 399 | LD L, (IX + DD) 400 | LD L, (IY + DD) 401 | LD L, A 402 | LD L, B 403 | LD L, C 404 | LD L, D 405 | LD L, E 406 | LD L, H 407 | LD L, L 408 | LD L, N 409 | LD R, A 410 | LD SP, (NN) 411 | LD SP, HL 412 | LD SP, IX 413 | LD SP, IY 414 | LD SP, NN 415 | ;------------------------------------------------------------------------------ 416 | LDD 417 | ;------------------------------------------------------------------------------ 418 | LDDR 419 | ;------------------------------------------------------------------------------ 420 | LDI 421 | ;------------------------------------------------------------------------------ 422 | LDIR 423 | ;------------------------------------------------------------------------------ 424 | NEG 425 | ;------------------------------------------------------------------------------ 426 | NOP 427 | ;------------------------------------------------------------------------------ 428 | OR (HL) 429 | OR (IX + DD) 430 | OR (IY + DD) 431 | OR A 432 | OR B 433 | OR C 434 | OR D 435 | OR E 436 | OR H 437 | OR L 438 | OR N 439 | ;------------------------------------------------------------------------------ 440 | OTDR 441 | ;------------------------------------------------------------------------------ 442 | OTIR 443 | ;------------------------------------------------------------------------------ 444 | OUT (C), A 445 | OUT (C), B 446 | OUT (C), C 447 | OUT (C), D 448 | OUT (C), E 449 | OUT (C), H 450 | OUT (C), L 451 | ;------------------------------------------------------------------------------ 452 | OUT (N), A 453 | ;------------------------------------------------------------------------------ 454 | OUTD 455 | ;------------------------------------------------------------------------------ 456 | OUTI 457 | ;------------------------------------------------------------------------------ 458 | POP AF 459 | POP BC 460 | POP DE 461 | POP HL 462 | POP IX 463 | POP IY 464 | ;------------------------------------------------------------------------------ 465 | PUSH AF 466 | PUSH BC 467 | PUSH DE 468 | PUSH HL 469 | PUSH IX 470 | PUSH IY 471 | ;------------------------------------------------------------------------------ 472 | RES 0, (HL) 473 | RES 0, (IX + DD) 474 | RES 0, (IY + DD) 475 | RES 0, A 476 | RES 0, B 477 | RES 0, C 478 | RES 0, D 479 | RES 0, E 480 | RES 0, H 481 | RES 0, L 482 | RES 1, (HL) 483 | RES 1, (IX + DD) 484 | RES 1, (IY + DD) 485 | RES 1, A 486 | RES 1, B 487 | RES 1, C 488 | RES 1, D 489 | RES 1, E 490 | RES 1, H 491 | RES 1, L 492 | RES 2, (HL) 493 | RES 2, (IX + DD) 494 | RES 2, (IY + DD) 495 | RES 2, A 496 | RES 2, B 497 | RES 2, C 498 | RES 2, D 499 | RES 2, E 500 | RES 2, H 501 | RES 2, L 502 | RES 3, (HL) 503 | RES 3, (IX + DD) 504 | RES 3, (IY + DD) 505 | RES 3, A 506 | RES 3, B 507 | RES 3, C 508 | RES 3, D 509 | RES 3, E 510 | RES 3, H 511 | RES 3, L 512 | RES 4, (HL) 513 | RES 4, (IX + DD) 514 | RES 4, (IY + DD) 515 | RES 4, A 516 | RES 4, B 517 | RES 4, C 518 | RES 4, D 519 | RES 4, E 520 | RES 4, H 521 | RES 4, L 522 | RES 5, (HL) 523 | RES 5, (IX + DD) 524 | RES 5, (IY + DD) 525 | RES 5, A 526 | RES 5, B 527 | RES 5, C 528 | RES 5, D 529 | RES 5, E 530 | RES 5, H 531 | RES 5, L 532 | RES 6, (HL) 533 | RES 6, (IX + DD) 534 | RES 6, (IY + DD) 535 | RES 6, A 536 | RES 6, B 537 | RES 6, C 538 | RES 6, D 539 | RES 6, E 540 | RES 6, H 541 | RES 6, L 542 | RES 7, (HL) 543 | RES 7, (IX + DD) 544 | RES 7, (IY + DD) 545 | RES 7, A 546 | RES 7, B 547 | RES 7, C 548 | RES 7, D 549 | RES 7, E 550 | RES 7, H 551 | RES 7, L 552 | ;------------------------------------------------------------------------------ 553 | RET 554 | ;------------------------------------------------------------------------------ 555 | RET C 556 | RET M 557 | RET NC 558 | RET NZ 559 | RET P 560 | RET PE 561 | RET PO 562 | RET Z 563 | ;------------------------------------------------------------------------------ 564 | RETI 565 | ;------------------------------------------------------------------------------ 566 | RETN 567 | ;------------------------------------------------------------------------------ 568 | RL (HL) 569 | RL (IX + DD) 570 | RL (IY + DD) 571 | RL A 572 | RL B 573 | RL C 574 | RL D 575 | RL E 576 | RL H 577 | RL L 578 | ;------------------------------------------------------------------------------ 579 | RLA 580 | ;------------------------------------------------------------------------------ 581 | RLC (HL) 582 | RLC (IX + DD) 583 | RLC (IY + DD) 584 | RLC A 585 | RLC B 586 | RLC C 587 | RLC D 588 | RLC E 589 | RLC H 590 | RLC L 591 | ;------------------------------------------------------------------------------ 592 | RLCA 593 | ;------------------------------------------------------------------------------ 594 | RLD 595 | ;------------------------------------------------------------------------------ 596 | RR (HL) 597 | RR (IX + DD) 598 | RR (IY + DD) 599 | RR A 600 | RR B 601 | RR C 602 | RR D 603 | RR E 604 | RR H 605 | RR L 606 | ;------------------------------------------------------------------------------ 607 | RRA 608 | ;------------------------------------------------------------------------------ 609 | RRC (HL) 610 | RRC (IX + DD) 611 | RRC (IY + DD) 612 | RRC A 613 | RRC B 614 | RRC C 615 | RRC D 616 | RRC E 617 | RRC H 618 | RRC L 619 | ;------------------------------------------------------------------------------ 620 | RRCA 621 | ;------------------------------------------------------------------------------ 622 | RRD 623 | ;------------------------------------------------------------------------------ 624 | RST 00H 625 | RST 08H 626 | RST 10H 627 | RST 18H 628 | RST 20H 629 | RST 28H 630 | RST 30H 631 | RST 38H 632 | ;------------------------------------------------------------------------------ 633 | SBC A, (HL) 634 | SBC A, (IX + DD) 635 | SBC A, (IY + DD) 636 | SBC A, A 637 | SBC A, B 638 | SBC A, C 639 | SBC A, D 640 | SBC A, E 641 | SBC A, H 642 | SBC A, L 643 | SBC A, N 644 | SBC HL, BC 645 | SBC HL, DE 646 | SBC HL, HL 647 | SBC HL, SP 648 | ;------------------------------------------------------------------------------ 649 | SCF 650 | ;------------------------------------------------------------------------------ 651 | SET 0, (HL) 652 | SET 0, (IX + DD) 653 | SET 0, (IY + DD) 654 | SET 0, A 655 | SET 0, B 656 | SET 0, C 657 | SET 0, D 658 | SET 0, E 659 | SET 0, H 660 | SET 0, L 661 | SET 1, (HL) 662 | SET 1, (IX + DD) 663 | SET 1, (IY + DD) 664 | SET 1, A 665 | SET 1, B 666 | SET 1, C 667 | SET 1, D 668 | SET 1, E 669 | SET 1, H 670 | SET 1, L 671 | SET 2, (HL) 672 | SET 2, (IX + DD) 673 | SET 2, (IY + DD) 674 | SET 2, A 675 | SET 2, B 676 | SET 2, C 677 | SET 2, D 678 | SET 2, E 679 | SET 2, H 680 | SET 2, L 681 | SET 3, (HL) 682 | SET 3, (IX + DD) 683 | SET 3, (IY + DD) 684 | SET 3, A 685 | SET 3, B 686 | SET 3, C 687 | SET 3, D 688 | SET 3, E 689 | SET 3, H 690 | SET 3, L 691 | SET 4, (HL) 692 | SET 4, (IX + DD) 693 | SET 4, (IY + DD) 694 | SET 4, A 695 | SET 4, B 696 | SET 4, C 697 | SET 4, D 698 | SET 4, E 699 | SET 4, H 700 | SET 4, L 701 | SET 5, (HL) 702 | SET 5, (IX + DD) 703 | SET 5, (IY + DD) 704 | SET 5, A 705 | SET 5, B 706 | SET 5, C 707 | SET 5, D 708 | SET 5, E 709 | SET 5, H 710 | SET 5, L 711 | SET 6, (HL) 712 | SET 6, (IX + DD) 713 | SET 6, (IY + DD) 714 | SET 6, A 715 | SET 6, B 716 | SET 6, C 717 | SET 6, D 718 | SET 6, E 719 | SET 6, H 720 | SET 6, L 721 | SET 7, (HL) 722 | SET 7, (IX + DD) 723 | SET 7, (IY + DD) 724 | SET 7, A 725 | SET 7, B 726 | SET 7, C 727 | SET 7, D 728 | SET 7, E 729 | SET 7, H 730 | SET 7, L 731 | ;------------------------------------------------------------------------------ 732 | SLA (HL) 733 | SLA (IX + DD) 734 | SLA (IY + DD) 735 | SLA A 736 | SLA B 737 | SLA C 738 | SLA D 739 | SLA E 740 | SLA H 741 | SLA L 742 | ;------------------------------------------------------------------------------ 743 | SRA (HL) 744 | SRA (IX + DD) 745 | SRA (IY + DD) 746 | SRA A 747 | SRA B 748 | SRA C 749 | SRA D 750 | SRA E 751 | SRA H 752 | SRA L 753 | ;------------------------------------------------------------------------------ 754 | SRL (HL) 755 | SRL (IX + DD) 756 | SRL (IY + DD) 757 | SRL A 758 | SRL B 759 | SRL C 760 | SRL D 761 | SRL E 762 | SRL H 763 | SRL L 764 | ;------------------------------------------------------------------------------ 765 | SUB (HL) 766 | SUB (IX + DD) 767 | SUB (IY + DD) 768 | SUB A 769 | SUB B 770 | SUB C 771 | SUB D 772 | SUB E 773 | SUB H 774 | SUB L 775 | SUB N 776 | ;------------------------------------------------------------------------------ 777 | XOR (HL) 778 | XOR (IX + DD) 779 | XOR (IY + DD) 780 | XOR A 781 | XOR B 782 | XOR C 783 | XOR D 784 | XOR E 785 | XOR H 786 | XOR L 787 | XOR N 788 | ;------------------------------------------------------------------------------ 789 | 790 | END 791 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /test/macro20.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | ext BDOS,UCASE,ISDIG,ALNUM,PUTCH 4 | 5 | MKFCB macro 6 | ; 7 | ; Create FCB from string. 8 | ; On input HL points to string, DE to dest FCB 9 | ; 10 | MKFCB: push bc ; save registers 11 | push de 12 | push hl 13 | call GETDU ; get current drive and user number 14 | ld (de),a ; store as default 15 | ld a,(hl) ; get char 16 | call UCASE 17 | sub 'A' ; check for possible drive name 18 | jr c,MK2 ; branch if not a letter 19 | cp 16 20 | jr nc,MK3 ; branch if not valid drive and not a number 21 | ld c,a ; C = possible drive number 22 | inc hl 23 | ld a,(hl) ; get next char 24 | cp ':' ; colon? 25 | jr z,MK1 ; branch if yes, drive specified 26 | call ISDIG ; number? 27 | dec hl 28 | jr nz,MK3 ; branch if not 29 | inc hl 30 | MK1: ld a,(de) ; get FCB drive/user 31 | and 0Fh ; mask user number 32 | ld b,a 33 | ld a,c ; get drive number 34 | rla 35 | rla 36 | rla 37 | rla 38 | and 0F0h ; into upper bits 39 | or b ; merge with user number 40 | ld (de),a ; back into the FCB 41 | MK2: ld a,(hl) ; get char 42 | call ISDIG ; number? 43 | jr nz,MK3 ; jump if not 44 | call getdec ; else convert to binary 45 | and 0Fh ; 0 to 15 46 | ld b,a 47 | ld a,(de) ; get FCB drive/user 48 | and 0F0h ; mask drive bits 49 | or b ; merge with user number 50 | ld (de),a ; back into the FCB 51 | MK3: inc de ; point to file name field 52 | ld a,(hl) 53 | cp ':' 54 | jr nz,MK4 55 | inc hl 56 | MK4: ld b,8 57 | MK5: ld a,(hl) ; get char 58 | call ucase 59 | call alnum ; alphanumeric? 60 | jr nz,MK6 ; jump if not 61 | ld (de),a ; set up file name 62 | inc hl 63 | inc de 64 | djnz MK5 65 | MK6: ld a,b 66 | or a 67 | jr z,MK8 68 | ld a,' ' ; pad with spaces 69 | MK7: ld (de),a 70 | inc de 71 | djnz MK7 72 | MK8: ld a,(hl) 73 | cp '.' ; test for extension separator 74 | jr z,MK9 75 | call alnum ; alphanumeric? 76 | jr nz,MK9 ; jump if not 77 | inc hl 78 | jr MK8 79 | MK9: ld a,(hl) 80 | ld b,3 81 | cp '.' 82 | jr nz,MK11 83 | inc hl 84 | MK10: ld a,(hl) 85 | call ucase 86 | call alnum ; alphanumeric? 87 | jr nz,MK11 ; jump if not 88 | ld (de),a 89 | inc hl 90 | inc de 91 | djnz MK10 92 | MK11: ld a,b 93 | or a 94 | jr z,MK13 95 | ld a,' ' 96 | MK12: ld (de),a 97 | inc de 98 | djnz MK12 99 | MK13: pop hl 100 | pop de 101 | pop bc 102 | ret 103 | 104 | ; Get current drive and user 105 | 106 | DFUSR: db 0 107 | DFDRV: db 0 ; !!unused 108 | 109 | GETDU: push bc 110 | push de 111 | push hl 112 | ld c,20h ; BDOS get current user 113 | ld e,0FFh 114 | call BDOS 115 | and 0Fh 116 | ld (DFUSR),a 117 | ld b,a 118 | push bc 119 | ld c,19h ; BDOS get current drive 120 | call BDOS 121 | ld (DFDRV),a ; !!unused 122 | rla 123 | rla 124 | rla 125 | rla 126 | and 0F0h ; drive on upper nibble 127 | pop bc 128 | or b ; user number on lower nibble 129 | pop hl 130 | pop de 131 | pop bc 132 | ret 133 | 134 | ; Set user from du: byte 135 | 136 | setusr: push bc 137 | push de 138 | push hl 139 | and 0Fh 140 | ld e,a 141 | ld a,(DFUSR) 142 | cp e 143 | ld a,e 144 | ld (DFUSR),a 145 | ld c,20h ; BDOS set user 146 | call nz,BDOS 147 | xor a 148 | pop hl 149 | pop de 150 | pop bc 151 | ret 152 | 153 | getdec: push bc 154 | ld bc,0 155 | L39B9: ld a,(hl) 156 | call ISDIG ; digit? 157 | jr nz,L39CD ; jump if not 158 | call mul10 159 | ld a,(hl) 160 | sub '0' 161 | add a,c 162 | ld c,a 163 | jr nc,L39CA 164 | inc b 165 | L39CA: inc hl 166 | jr L39B9 167 | L39CD: ld a,c 168 | pop bc 169 | ret 170 | 171 | mul10: push hl 172 | ld h,b 173 | ld l,c 174 | add hl,hl 175 | push hl 176 | add hl,hl 177 | add hl,hl 178 | pop bc 179 | add hl,bc 180 | ld b,h 181 | ld l,c 182 | pop hl 183 | ret 184 | 185 | adec: push hl 186 | ld h,0 187 | ld l,a 188 | call hldec 189 | pop hl 190 | ret 191 | 192 | ; Output HL as unsigned decimal number to console 193 | 194 | hldec: push bc 195 | push de 196 | push hl 197 | ld c,0 198 | ld de,10000 199 | call sbcnt 200 | ld de,1000 201 | call sbcnt 202 | ld de,100 203 | call sbcnt 204 | ld de,10 205 | call sbcnt 206 | ld a,l 207 | or '0' 208 | call putch 209 | pop hl 210 | pop de 211 | pop bc 212 | ret 213 | 214 | sbcnt: ld b,0FFh 215 | L3A0F: inc b 216 | or a 217 | sbc hl,de 218 | jr nc,L3A0F 219 | add hl,de 220 | ld a,b 221 | or a 222 | jr nz,L3A1D 223 | ld a,c 224 | or a 225 | ret z 226 | L3A1D: or '0' 227 | ld c,a 228 | call putch 229 | ret 230 | PRFCB 231 | endm 232 | 233 | PRFCB macro 234 | local L398B,L3996,L399D,L39A4,L39B1 235 | ;******************************************************** 236 | ;******************************************************** 237 | ;******************************************************** 238 | ;******************************************************** 239 | ;******************************************************** 240 | ;******************************************************** 241 | ;******************************************************** 242 | ;******************************************************** 243 | ;******************************************************** 244 | ;******************************************************** 245 | ;******************************************************** 246 | ;******************************************************** 247 | ;******************************************************** 248 | ;******************************************************** 249 | ;******************************************************** 250 | ;******************************************************** 251 | ;******************************************************** 252 | ;******************************************************** 253 | ;******************************************************** 254 | ;******************************************************** 255 | ;******************************************************** 256 | ;******************************************************** 257 | ;******************************************************** 258 | ;******************************************************** 259 | ;******************************************************** 260 | ;******************************************************** 261 | ;******************************************************** 262 | ;******************************************************** 263 | ;******************************************************** 264 | ;******************************************************** 265 | ;******************************************************** 266 | ;******************************************************** 267 | ;******************************************************** 268 | ;******************************************************** 269 | ;******************************************************** 270 | ;******************************************************** 271 | ;******************************************************** 272 | ;******************************************************** 273 | ;******************************************************** 274 | ;******************************************************** 275 | ;******************************************************** 276 | ;******************************************************** 277 | ;******************************************************** 278 | ;******************************************************** 279 | ;******************************************************** 280 | ;******************************************************** 281 | ;******************************************************** 282 | ;******************************************************** 283 | ;******************************************************** 284 | ;******************************************************** 285 | ;******************************************************** 286 | ;******************************************************** 287 | ;******************************************************** 288 | ;******************************************************** 289 | ;******************************************************** 290 | ;******************************************************** 291 | ;******************************************************** 292 | ;******************************************************** 293 | ;******************************************************** 294 | ;******************************************************** 295 | ;******************************************************** 296 | ;******************************************************** 297 | ;******************************************************** 298 | ;******************************************************** 299 | ;******************************************************** 300 | ;******************************************************** 301 | ;******************************************************** 302 | ;******************************************************** 303 | ;******************************************************** 304 | ;******************************************************** 305 | ;******************************************************** 306 | ;******************************************************** 307 | ;******************************************************** 308 | ;******************************************************** 309 | ;******************************************************** 310 | ;******************************************************** 311 | ;******************************************************** 312 | ;******************************************************** 313 | ;******************************************************** 314 | ;******************************************************** 315 | ;******************************************************** 316 | ;******************************************************** 317 | ;******************************************************** 318 | ;******************************************************** 319 | ;******************************************************** 320 | ;******************************************************** 321 | ;******************************************************** 322 | ;******************************************************** 323 | ;******************************************************** 324 | ;******************************************************** 325 | ;******************************************************** 326 | ;******************************************************** 327 | ;******************************************************** 328 | ;******************************************************** 329 | ;******************************************************** 330 | ;******************************************************** 331 | ;******************************************************** 332 | ;******************************************************** 333 | ;******************************************************** 334 | ;******************************************************** 335 | ;******************************************************** 336 | ;******************************************************** 337 | ;******************************************************** 338 | ;******************************************************** 339 | ;******************************************************** 340 | ;******************************************************** 341 | ;******************************************************** 342 | ;******************************************************** 343 | ;******************************************************** 344 | ;******************************************************** 345 | ;******************************************************** 346 | ;******************************************************** 347 | ;******************************************************** 348 | ;******************************************************** 349 | ;******************************************************** 350 | ;******************************************************** 351 | ;******************************************************** 352 | ;******************************************************** 353 | ;******************************************************** 354 | ;******************************************************** 355 | ;******************************************************** 356 | ;******************************************************** 357 | ;******************************************************** 358 | ;******************************************************** 359 | ;******************************************************** 360 | ;******************************************************** 361 | ;******************************************************** 362 | ;******************************************************** 363 | ;******************************************************** 364 | ;******************************************************** 365 | ;******************************************************** 366 | ;******************************************************** 367 | ;******************************************************** 368 | ;******************************************************** 369 | ;******************************************************** 370 | ;******************************************************** 371 | ;******************************************************** 372 | ;******************************************************** 373 | ;******************************************************** 374 | ;******************************************************** 375 | ;******************************************************** 376 | ;******************************************************** 377 | ;******************************************************** 378 | ;******************************************************** 379 | ;******************************************************** 380 | ;******************************************************** 381 | ;******************************************************** 382 | ;******************************************************** 383 | ;******************************************************** 384 | ;******************************************************** 385 | ;******************************************************** 386 | ;******************************************************** 387 | ;******************************************************** 388 | ;******************************************************** 389 | ;******************************************************** 390 | ;******************************************************** 391 | ;******************************************************** 392 | ;******************************************************** 393 | ;******************************************************** 394 | ;******************************************************** 395 | ;******************************************************** 396 | ;******************************************************** 397 | ;******************************************************** 398 | ;******************************************************** 399 | ;******************************************************** 400 | ;******************************************************** 401 | ;******************************************************** 402 | ;******************************************************** 403 | ;******************************************************** 404 | ;******************************************************** 405 | ;******************************************************** 406 | ;******************************************************** 407 | ;******************************************************** 408 | ;******************************************************** 409 | ;******************************************************** 410 | ;******************************************************** 411 | ;******************************************************** 412 | ;******************************************************** 413 | ;******************************************************** 414 | ;******************************************************** 415 | ;******************************************************** 416 | ;******************************************************** 417 | ;******************************************************** 418 | ;******************************************************** 419 | ;******************************************************** 420 | ;******************************************************** 421 | ;******************************************************** 422 | ;******************************************************** 423 | ;******************************************************** 424 | ;******************************************************** 425 | ;******************************************************** 426 | ;******************************************************** 427 | ;******************************************************** 428 | ;******************************************************** 429 | ;******************************************************** 430 | ;******************************************************** 431 | ;******************************************************** 432 | ;******************************************************** 433 | ;******************************************************** 434 | ;******************************************************** 435 | ;******************************************************** 436 | ;******************************************************** 437 | ;******************************************************** 438 | ;******************************************************** 439 | ;******************************************************** 440 | ;******************************************************** 441 | ;******************************************************** 442 | ;******************************************************** 443 | ;******************************************************** 444 | ;******************************************************** 445 | ;******************************************************** 446 | ;******************************************************** 447 | ;******************************************************** 448 | ;******************************************************** 449 | ;******************************************************** 450 | ;******************************************************** 451 | ;******************************************************** 452 | ;******************************************************** 453 | ;******************************************************** 454 | ;******************************************************** 455 | ;******************************************************** 456 | ;******************************************************** 457 | ;******************************************************** 458 | ;******************************************************** 459 | ;******************************************************** 460 | ;******************************************************** 461 | ;******************************************************** 462 | ;******************************************************** 463 | ;******************************************************** 464 | ;******************************************************** 465 | ;******************************************************** 466 | ;******************************************************** 467 | ;******************************************************** 468 | ;******************************************************** 469 | ;******************************************************** 470 | ;******************************************************** 471 | ;******************************************************** 472 | ;******************************************************** 473 | ;******************************************************** 474 | ;******************************************************** 475 | ld a,(hl) 476 | rra 477 | rra 478 | rra 479 | rra 480 | and 0Fh 481 | push bc 482 | push de 483 | push hl 484 | add a,'A' 485 | call putch 486 | ld a,(hl) 487 | and 0Fh 488 | call adec 489 | ld a,':' 490 | call putch 491 | inc hl 492 | ld b,8 493 | L398B: ld a,(hl) 494 | cp ' ' 495 | jr z,L3996 496 | call putch 497 | inc hl 498 | djnz L398B 499 | L3996: ld a,b 500 | or a 501 | jr z,L399D 502 | inc hl 503 | djnz L3996 504 | L399D: ld a,'.' 505 | call putch 506 | ld b,3 507 | L39A4: ld a,(hl) 508 | and 7Fh 509 | cp ' ' 510 | jr z,L39B1 511 | call putch 512 | inc hl 513 | djnz L39A4 514 | L39B1: pop hl 515 | pop de 516 | pop bc 517 | ret 518 | endm 519 | 520 | MKFCB 521 | PRFCB 522 | 523 | end 524 | -------------------------------------------------------------------------------- /test/macro21.mac: -------------------------------------------------------------------------------- 1 | cseg 2 | 3 | ext BDOS,UCASE,ISDIG,ALNUM,PUTCH 4 | 5 | #error 6 | 7 | MKFCB macro 8 | ; 9 | ; Create FCB from string. 10 | ; On input HL points to string, DE to dest FCB 11 | ; 12 | MKFCB: push bc ; save registers 13 | push de 14 | push hl 15 | call GETDU ; get current drive and user number 16 | ld (de),a ; store as default 17 | ld a,(hl) ; get char 18 | call UCASE 19 | sub 'A' ; check for possible drive name 20 | jr c,MK2 ; branch if not a letter 21 | cp 16 22 | jr nc,MK3 ; branch if not valid drive and not a number 23 | ld c,a ; C = possible drive number 24 | inc hl 25 | ld a,(hl) ; get next char 26 | cp ':' ; colon? 27 | jr z,MK1 ; branch if yes, drive specified 28 | call ISDIG ; number? 29 | dec hl 30 | jr nz,MK3 ; branch if not 31 | inc hl 32 | MK1: ld a,(de) ; get FCB drive/user 33 | and 0Fh ; mask user number 34 | ld b,a 35 | ld a,c ; get drive number 36 | rla 37 | rla 38 | rla 39 | rla 40 | and 0F0h ; into upper bits 41 | or b ; merge with user number 42 | ld (de),a ; back into the FCB 43 | MK2: ld a,(hl) ; get char 44 | call ISDIG ; number? 45 | jr nz,MK3 ; jump if not 46 | call getdec ; else convert to binary 47 | and 0Fh ; 0 to 15 48 | ld b,a 49 | ld a,(de) ; get FCB drive/user 50 | and 0F0h ; mask drive bits 51 | or b ; merge with user number 52 | ld (de),a ; back into the FCB 53 | MK3: inc de ; point to file name field 54 | ld a,(hl) 55 | cp ':' 56 | jr nz,MK4 57 | inc hl 58 | MK4: ld b,8 59 | MK5: ld a,(hl) ; get char 60 | call ucase 61 | call alnum ; alphanumeric? 62 | jr nz,MK6 ; jump if not 63 | ld (de),a ; set up file name 64 | inc hl 65 | inc de 66 | djnz MK5 67 | MK6: ld a,b 68 | or a 69 | jr z,MK8 70 | ld a,' ' ; pad with spaces 71 | MK7: ld (de),a 72 | inc de 73 | djnz MK7 74 | MK8: ld a,(hl) 75 | cp '.' ; test for extension separator 76 | jr z,MK9 77 | call alnum ; alphanumeric? 78 | jr nz,MK9 ; jump if not 79 | inc hl 80 | jr MK8 81 | MK9: ld a,(hl) 82 | ld b,3 83 | cp '.' 84 | jr nz,MK11 85 | inc hl 86 | MK10: ld a,(hl) 87 | call ucase 88 | call alnum ; alphanumeric? 89 | jr nz,MK11 ; jump if not 90 | ld (de),a 91 | inc hl 92 | inc de 93 | djnz MK10 94 | MK11: ld a,b 95 | or a 96 | jr z,MK13 97 | ld a,' ' 98 | MK12: ld (de),a 99 | inc de 100 | djnz MK12 101 | MK13: pop hl 102 | pop de 103 | pop bc 104 | ret 105 | 106 | ; Get current drive and user 107 | 108 | DFUSR: db 0 109 | DFDRV: db 0 ; !!unused 110 | 111 | GETDU: push bc 112 | push de 113 | push hl 114 | ld c,20h ; BDOS get current user 115 | ld e,0FFh 116 | call BDOS 117 | and 0Fh 118 | ld (DFUSR),a 119 | ld b,a 120 | push bc 121 | ld c,19h ; BDOS get current drive 122 | call BDOS 123 | ld (DFDRV),a ; !!unused 124 | rla 125 | rla 126 | rla 127 | rla 128 | and 0F0h ; drive on upper nibble 129 | pop bc 130 | or b ; user number on lower nibble 131 | pop hl 132 | pop de 133 | pop bc 134 | ret 135 | 136 | ; Set user from du: byte 137 | 138 | setusr: push bc 139 | push de 140 | push hl 141 | and 0Fh 142 | ld e,a 143 | ld a,(DFUSR) 144 | cp e 145 | ld a,e 146 | ld (DFUSR),a 147 | ld c,20h ; BDOS set user 148 | call nz,BDOS 149 | xor a 150 | pop hl 151 | pop de 152 | pop bc 153 | ret 154 | 155 | getdec: push bc 156 | ld bc,0 157 | L39B9: ld a,(hl) 158 | call ISDIG ; digit? 159 | jr nz,L39CD ; jump if not 160 | call mul10 161 | ld a,(hl) 162 | sub '0' 163 | add a,c 164 | ld c,a 165 | jr nc,L39CA 166 | inc b 167 | L39CA: inc hl 168 | jr L39B9 169 | L39CD: ld a,c 170 | pop bc 171 | ret 172 | 173 | mul10: push hl 174 | ld h,b 175 | ld l,c 176 | add hl,hl 177 | push hl 178 | add hl,hl 179 | add hl,hl 180 | pop bc 181 | add hl,bc 182 | ld b,h 183 | ld l,c 184 | pop hl 185 | ret 186 | 187 | adec: push hl 188 | ld h,0 189 | ld l,a 190 | call hldec 191 | pop hl 192 | ret 193 | 194 | ; Output HL as unsigned decimal number to console 195 | 196 | hldec: push bc 197 | push de 198 | push hl 199 | ld c,0 200 | ld de,10000 201 | call sbcnt 202 | ld de,1000 203 | call sbcnt 204 | ld de,100 205 | call sbcnt 206 | ld de,10 207 | call sbcnt 208 | ld a,l 209 | or '0' 210 | call putch 211 | pop hl 212 | pop de 213 | pop bc 214 | ret 215 | 216 | sbcnt: ld b,0FFh 217 | L3A0F: inc b 218 | or a 219 | sbc hl,de 220 | jr nc,L3A0F 221 | add hl,de 222 | ld a,b 223 | or a 224 | jr nz,L3A1D 225 | ld a,c 226 | or a 227 | ret z 228 | L3A1D: or '0' 229 | ld c,a 230 | call putch 231 | ret 232 | PRFCB 233 | endm 234 | 235 | PRFCB macro 236 | local L398B,L3996,L399D,L39A4,L39B1 237 | ;******************************************************** 238 | ;******************************************************** 239 | ;******************************************************** 240 | ;******************************************************** 241 | ;******************************************************** 242 | ;******************************************************** 243 | ;******************************************************** 244 | ;******************************************************** 245 | ;******************************************************** 246 | ;******************************************************** 247 | ;******************************************************** 248 | ;******************************************************** 249 | ;******************************************************** 250 | ;******************************************************** 251 | ;******************************************************** 252 | ;******************************************************** 253 | ;******************************************************** 254 | ;******************************************************** 255 | ;******************************************************** 256 | ;******************************************************** 257 | ;******************************************************** 258 | ;******************************************************** 259 | ;******************************************************** 260 | ;******************************************************** 261 | ;******************************************************** 262 | ;******************************************************** 263 | ;******************************************************** 264 | ;******************************************************** 265 | ;******************************************************** 266 | ;******************************************************** 267 | ;******************************************************** 268 | ;******************************************************** 269 | ;******************************************************** 270 | ;******************************************************** 271 | ;******************************************************** 272 | ;******************************************************** 273 | ;******************************************************** 274 | ;******************************************************** 275 | ;******************************************************** 276 | ;******************************************************** 277 | ;******************************************************** 278 | ;******************************************************** 279 | ;******************************************************** 280 | ;******************************************************** 281 | ;******************************************************** 282 | ;******************************************************** 283 | ;******************************************************** 284 | ;******************************************************** 285 | ;******************************************************** 286 | ;******************************************************** 287 | ;******************************************************** 288 | ;******************************************************** 289 | ;******************************************************** 290 | ;******************************************************** 291 | ;******************************************************** 292 | ;******************************************************** 293 | ;******************************************************** 294 | ;******************************************************** 295 | ;******************************************************** 296 | ;******************************************************** 297 | ;******************************************************** 298 | ;******************************************************** 299 | ;******************************************************** 300 | ;******************************************************** 301 | ;******************************************************** 302 | ;******************************************************** 303 | ;******************************************************** 304 | ;******************************************************** 305 | ;******************************************************** 306 | ;******************************************************** 307 | ;******************************************************** 308 | ;******************************************************** 309 | ;******************************************************** 310 | ;******************************************************** 311 | ;******************************************************** 312 | ;******************************************************** 313 | ;******************************************************** 314 | ;******************************************************** 315 | ;******************************************************** 316 | ;******************************************************** 317 | ;******************************************************** 318 | ;******************************************************** 319 | ;******************************************************** 320 | ;******************************************************** 321 | ;******************************************************** 322 | ;******************************************************** 323 | ;******************************************************** 324 | ;******************************************************** 325 | ;******************************************************** 326 | ;******************************************************** 327 | ;******************************************************** 328 | ;******************************************************** 329 | ;******************************************************** 330 | ;******************************************************** 331 | ;******************************************************** 332 | ;******************************************************** 333 | ;******************************************************** 334 | ;******************************************************** 335 | ;******************************************************** 336 | ;******************************************************** 337 | ;******************************************************** 338 | ;******************************************************** 339 | ;******************************************************** 340 | ;******************************************************** 341 | ;******************************************************** 342 | ;******************************************************** 343 | ;******************************************************** 344 | ;******************************************************** 345 | ;******************************************************** 346 | ;******************************************************** 347 | ;******************************************************** 348 | ;******************************************************** 349 | ;******************************************************** 350 | ;******************************************************** 351 | ;******************************************************** 352 | ;******************************************************** 353 | ;******************************************************** 354 | ;******************************************************** 355 | ;******************************************************** 356 | ;******************************************************** 357 | ;******************************************************** 358 | ;******************************************************** 359 | ;******************************************************** 360 | ;******************************************************** 361 | ;******************************************************** 362 | ;******************************************************** 363 | ;******************************************************** 364 | ;******************************************************** 365 | ;******************************************************** 366 | ;******************************************************** 367 | ;******************************************************** 368 | ;******************************************************** 369 | ;******************************************************** 370 | ;******************************************************** 371 | ;******************************************************** 372 | ;******************************************************** 373 | ;******************************************************** 374 | ;******************************************************** 375 | ;******************************************************** 376 | ;******************************************************** 377 | ;******************************************************** 378 | ;******************************************************** 379 | ;******************************************************** 380 | ;******************************************************** 381 | ;******************************************************** 382 | ;******************************************************** 383 | ;******************************************************** 384 | ;******************************************************** 385 | ;******************************************************** 386 | ;******************************************************** 387 | ;******************************************************** 388 | ;******************************************************** 389 | ;******************************************************** 390 | ;******************************************************** 391 | ;******************************************************** 392 | ;******************************************************** 393 | ;******************************************************** 394 | ;******************************************************** 395 | ;******************************************************** 396 | ;******************************************************** 397 | ;******************************************************** 398 | ;******************************************************** 399 | ;******************************************************** 400 | ;******************************************************** 401 | ;******************************************************** 402 | ;******************************************************** 403 | ;******************************************************** 404 | ;******************************************************** 405 | ;******************************************************** 406 | ;******************************************************** 407 | ;******************************************************** 408 | ;******************************************************** 409 | ;******************************************************** 410 | ;******************************************************** 411 | ;******************************************************** 412 | ;******************************************************** 413 | ;******************************************************** 414 | ;******************************************************** 415 | ;******************************************************** 416 | ;******************************************************** 417 | ;******************************************************** 418 | ;******************************************************** 419 | ;******************************************************** 420 | ;******************************************************** 421 | ;******************************************************** 422 | ;******************************************************** 423 | ;******************************************************** 424 | ;******************************************************** 425 | ;******************************************************** 426 | ;******************************************************** 427 | ;******************************************************** 428 | ;******************************************************** 429 | ;******************************************************** 430 | ;******************************************************** 431 | ;******************************************************** 432 | ;******************************************************** 433 | ;******************************************************** 434 | ;******************************************************** 435 | ;******************************************************** 436 | ;******************************************************** 437 | ;******************************************************** 438 | ;******************************************************** 439 | ;******************************************************** 440 | ;******************************************************** 441 | ;******************************************************** 442 | ;******************************************************** 443 | ;******************************************************** 444 | ;******************************************************** 445 | ;******************************************************** 446 | ;******************************************************** 447 | ;******************************************************** 448 | ;******************************************************** 449 | ;******************************************************** 450 | ;******************************************************** 451 | ;******************************************************** 452 | ;******************************************************** 453 | ;******************************************************** 454 | ;******************************************************** 455 | ;******************************************************** 456 | ;******************************************************** 457 | ;******************************************************** 458 | ;******************************************************** 459 | ;******************************************************** 460 | ;******************************************************** 461 | ;******************************************************** 462 | ;******************************************************** 463 | ;******************************************************** 464 | ;******************************************************** 465 | ;******************************************************** 466 | ;******************************************************** 467 | ;******************************************************** 468 | ;******************************************************** 469 | ;******************************************************** 470 | ;******************************************************** 471 | ;******************************************************** 472 | ;******************************************************** 473 | ;******************************************************** 474 | ;******************************************************** 475 | ;******************************************************** 476 | ;******************************************************** 477 | ld a,(hl) 478 | rra 479 | rra 480 | rra 481 | rra 482 | and 0Fh 483 | push bc 484 | push de 485 | push hl 486 | add a,'A' 487 | call putch 488 | ld a,(hl) 489 | and 0Fh 490 | call adec 491 | ld a,':' 492 | call putch 493 | inc hl 494 | ld b,8 495 | L398B: ld a,(hl) 496 | cp ' ' 497 | jr z,L3996 498 | call putch 499 | inc hl 500 | djnz L398B 501 | L3996: ld a,b 502 | or a 503 | jr z,L399D 504 | inc hl 505 | djnz L3996 506 | L399D: ld a,'.' 507 | call putch 508 | ld b,3 509 | L39A4: ld a,(hl) 510 | and 7Fh 511 | cp ' ' 512 | jr z,L39B1 513 | call putch 514 | inc hl 515 | djnz L39A4 516 | L39B1: pop hl 517 | pop de 518 | pop bc 519 | ret 520 | endm 521 | 522 | MKFCB 523 | PRFCB 524 | 525 | end 526 | -------------------------------------------------------------------------------- /test/error_check/zsmtst2.mac: -------------------------------------------------------------------------------- 1 | TITLE ZSM Test file 2 | ; 3 | ; PSEUDO OPS 4 | ; 5 | org 100H 6 | ; 7 | defb 0AAH 8 | NNNN: defs 2 ;SAMPLE ADDRESS 9 | defw 0AABBH 10 | L1 equ 0AABBH 11 | INDEX equ 5 ;SAMPLE INDEX 12 | NN equ 20H ;SAMPLE 8 BIT VALUE 13 | DIS equ 30H 14 | ; 15 | if 0 16 | ; SHOULD NOT BE ASSEMBLED 17 | ld a,b 18 | endif 19 | if 1 20 | ; SHOULD BE ASSEMBLED 21 | ld a,b 22 | endif 23 | ; TURN LISTING OFF 24 | list off 25 | ; LISTING SHOULD NOT BE ON 26 | ld a,b 27 | list on 28 | ; LISTING SHOULD BE ON 29 | ; 30 | ; KNOWN PREVIOUS ERRORS IN Z80ASMUK 31 | ; 32 | ld (hl),-1 33 | cp -1 34 | ld de,-6 35 | ld a,+6 36 | ld a,-6 37 | defb -1 38 | ; 39 | WACT: equ ATKLST 40 | ld hl,WACT 41 | ATKLST: db 0,0,0 42 | ; 43 | ; Z80 OPCODES 44 | ; 45 | adc a,(hl) 46 | adc (hl) 47 | adc a,(ix) 48 | adc (ix) 49 | adc a,(ix+INDEX) 50 | adc (ix+INDEX) 51 | adc a,(ix-INDEX) 52 | adc (ix-INDEX) 53 | adc a,(iy) 54 | adc (iy) 55 | adc a,(iy+INDEX) 56 | adc (iy+INDEX) 57 | adc a,(iy-INDEX) 58 | adc (iy-INDEX) 59 | adc a,a 60 | adc a 61 | adc a,b 62 | adc b 63 | adc a,c 64 | adc c 65 | adc a,d 66 | adc d 67 | adc a,e 68 | adc e 69 | adc a,h 70 | adc h 71 | adc a,l 72 | adc l 73 | adc a,NN 74 | adc NN 75 | adc hl,bc 76 | adc hl,de 77 | adc hl,hl 78 | adc hl,sp 79 | ; 80 | add (hl) 81 | add a,(ix) 82 | add (ix) 83 | add a,(ix+INDEX) 84 | add (ix+INDEX) 85 | add a,(ix-INDEX) 86 | add (ix-INDEX) 87 | add a,(iy) 88 | add (iy) 89 | add a,(iy+INDEX) 90 | add (iy+INDEX) 91 | add a,(iy-INDEX) 92 | add (iy-INDEX) 93 | add a,a 94 | add a 95 | add a,b 96 | add b 97 | add a,c 98 | add c 99 | add a,d 100 | add d 101 | add a,e 102 | add e 103 | add a,h 104 | add h 105 | add a,l 106 | add l 107 | add a,NN 108 | add NN 109 | add hl,bc 110 | add hl,de 111 | add hl,hl 112 | add hl,sp 113 | add ix,bc 114 | add ix,de 115 | add ix,ix 116 | add ix,sp 117 | add iy,bc 118 | add iy,de 119 | add iy,iy 120 | add iy,sp 121 | ; 122 | and (hl) 123 | and (ix) 124 | and (ix+INDEX) 125 | and (ix-INDEX) 126 | and (iy) 127 | and (iy+INDEX) 128 | and (iy-INDEX) 129 | and a 130 | and b 131 | and c 132 | and d 133 | and e 134 | and h 135 | and l 136 | and NN 137 | ; 138 | bit 0,(hl) 139 | bit 0,(ix) 140 | bit 0,(ix+INDEX) 141 | bit 0,(ix-INDEX) 142 | bit 0,(iy) 143 | bit 0,(iy+INDEX) 144 | bit 0,(iy-INDEX) 145 | bit 0,a 146 | bit 0,b 147 | bit 0,c 148 | bit 0,d 149 | bit 0,e 150 | bit 0,h 151 | bit 0,l 152 | ; 153 | bit 1,(hl) 154 | bit 1,(ix) 155 | bit 1,(ix+INDEX) 156 | bit 1,(ix-INDEX) 157 | bit 1,(iy) 158 | bit 1,(iy+INDEX) 159 | bit 1,(iy-INDEX) 160 | bit 1,a 161 | bit 1,b 162 | bit 1,c 163 | bit 1,d 164 | bit 1,e 165 | bit 1,h 166 | bit 1,l 167 | ; 168 | bit 2,(hl) 169 | bit 2,(ix) 170 | bit 2,(ix+INDEX) 171 | bit 2,(ix-INDEX) 172 | bit 2,(iy) 173 | bit 2,(iy+INDEX) 174 | bit 2,(iy-INDEX) 175 | bit 2,a 176 | bit 2,b 177 | bit 2,c 178 | bit 2,d 179 | bit 2,e 180 | bit 2,h 181 | bit 2,l 182 | ; 183 | bit 3,(hl) 184 | bit 3,(ix) 185 | bit 3,(ix+INDEX) 186 | bit 3,(ix-INDEX) 187 | bit 3,(iy) 188 | bit 3,(iy+INDEX) 189 | bit 3,(iy-INDEX) 190 | bit 3,a 191 | bit 3,b 192 | bit 3,c 193 | bit 3,d 194 | bit 3,e 195 | bit 3,h 196 | bit 3,l 197 | ; 198 | bit 4,(hl) 199 | bit 4,(ix) 200 | bit 4,(ix+INDEX) 201 | bit 4,(ix-INDEX) 202 | bit 4,(iy) 203 | bit 4,(iy+INDEX) 204 | bit 4,(iy-INDEX) 205 | bit 4,a 206 | bit 4,b 207 | bit 4,c 208 | bit 4,d 209 | bit 4,e 210 | bit 4,h 211 | bit 4,l 212 | ; 213 | bit 5,(hl) 214 | bit 5,(ix) 215 | bit 5,(ix+INDEX) 216 | bit 5,(ix-INDEX) 217 | bit 5,(iy) 218 | bit 5,(iy+INDEX) 219 | bit 5,(iy-INDEX) 220 | bit 5,a 221 | bit 5,b 222 | bit 5,c 223 | bit 5,d 224 | bit 5,e 225 | bit 5,h 226 | bit 5,l 227 | ; 228 | bit 6,(hl) 229 | bit 6,(ix) 230 | bit 6,(ix+INDEX) 231 | bit 6,(ix-INDEX) 232 | bit 6,(iy) 233 | bit 6,(iy+INDEX) 234 | bit 6,(iy-INDEX) 235 | bit 6,a 236 | bit 6,b 237 | bit 6,c 238 | bit 6,d 239 | bit 6,e 240 | bit 6,h 241 | bit 6,l 242 | ; 243 | bit 7,(hl) 244 | bit 7,(ix) 245 | bit 7,(ix+INDEX) 246 | bit 7,(ix-INDEX) 247 | bit 7,(iy+INDEX) 248 | bit 7,(iy-INDEX) 249 | bit 7,a 250 | bit 7,b 251 | bit 7,c 252 | bit 7,d 253 | bit 7,e 254 | bit 7,h 255 | bit 7,l 256 | ; 257 | call c,NNNN 258 | call m,NNNN 259 | call nc,NNNN 260 | call NNNN 261 | call nz,NNNN 262 | call p,NNNN 263 | call pe,NNNN 264 | call po,NNNN 265 | call z,NNNN 266 | ; 267 | ccf 268 | ; 269 | cp (hl) 270 | cp (ix) 271 | cp (ix+INDEX) 272 | cp (ix-INDEX) 273 | cp (iy) 274 | cp (iy+INDEX) 275 | cp (iy-INDEX) 276 | cp a 277 | cp b 278 | cp c 279 | cp d 280 | cp e 281 | cp h 282 | cp l 283 | cp NN 284 | ; 285 | cpd 286 | cpdr 287 | cpi 288 | cpir 289 | ; 290 | cpl 291 | ; 292 | daa 293 | ; 294 | dec (hl) 295 | dec (ix) 296 | dec (ix+INDEX) 297 | dec (ix-INDEX) 298 | dec (iy) 299 | dec (iy+INDEX) 300 | dec (iy-INDEX) 301 | dec a 302 | dec b 303 | dec bc 304 | dec c 305 | dec d 306 | dec de 307 | dec e 308 | dec h 309 | dec hl 310 | dec ix 311 | dec iy 312 | dec l 313 | dec sp 314 | ; 315 | di 316 | ; 317 | LAB1: djnz LAB1 318 | ; 319 | ei 320 | ; 321 | ex (sp),hl 322 | ex (sp),ix 323 | ex (sp),iy 324 | ex af,aF' 325 | ex de,hl 326 | exx 327 | ; 328 | halt 329 | ; 330 | im 0 331 | im 1 332 | im 2 333 | ; 334 | in a,(C) 335 | in a,(NN) 336 | in b,(C) 337 | in c,(C) 338 | in d,(C) 339 | in e,(C) 340 | ; in F,(C) 341 | in h,(C) 342 | in l,(C) 343 | ; 344 | inc (hl) 345 | inc (iy) 346 | inc (iy+INDEX) 347 | inc (iy-INDEX) 348 | inc (ix) 349 | inc (ix+INDEX) 350 | inc (ix-INDEX) 351 | inc a 352 | inc b 353 | inc bc 354 | inc c 355 | inc d 356 | inc de 357 | inc e 358 | inc h 359 | inc hl 360 | inc ix 361 | inc iy 362 | inc l 363 | inc sp 364 | ; 365 | ind 366 | indr 367 | ini 368 | inir 369 | ; 370 | jp (hl) 371 | jp (ix) 372 | jp (iy) 373 | jp c,NNNN 374 | jp m,NNNN 375 | jp nc,NNNN 376 | jp NNNN 377 | jp nz,NNNN 378 | jp p,NNNN 379 | jp pe,NNNN 380 | jp po,NNNN 381 | jp z,NNNN 382 | ; 383 | LAB2: jr LAB2 384 | jr c,LAB2 385 | jr nc,LAB2 386 | jr z,LAB2 387 | jr nz,LAB2 388 | ; 389 | ld (bc),a 390 | ld (de),a 391 | ld (hl),a 392 | ld (hl),b 393 | ld (hl),c 394 | ld (hl),d 395 | ld (hl),e 396 | ld (hl),h 397 | ld (hl),l 398 | ld (hl),NN 399 | ; 400 | ld (ix),a 401 | ld (ix+INDEX),a 402 | ld (ix-INDEX),a 403 | ld (ix),b 404 | ld (ix+INDEX),b 405 | ld (ix-INDEX),b 406 | ld (ix),e 407 | ld (ix+INDEX),e 408 | ld (ix-INDEX),e 409 | ld (ix),h 410 | ld (ix+INDEX),h 411 | ld (ix-INDEX),h 412 | ld (ix),l 413 | ld (ix+INDEX),l 414 | ld (ix-INDEX),l 415 | ld (ix),NN 416 | ld (ix+INDEX),NN 417 | ld (ix-INDEX),NN 418 | ; 419 | ld (iy),a 420 | ld (iy+INDEX),a 421 | ld (iy-INDEX),a 422 | ld (iy),b 423 | ld (iy+INDEX),b 424 | ld (iy-INDEX),b 425 | ld (iy),c 426 | ld (iy+INDEX),c 427 | ld (iy-INDEX),c 428 | ld (iy),d 429 | ld (iy+INDEX),d 430 | ld (iy-INDEX),d 431 | ld (iy),e 432 | ld (iy+INDEX),e 433 | ld (iy-INDEX),e 434 | ld (iy),h 435 | ld (iy+INDEX),h 436 | ld (iy-INDEX),h 437 | ld (iy),l 438 | ld (iy+INDEX),l 439 | ld (iy-INDEX),l 440 | ld (iy),NN 441 | ld (iy+INDEX),NN 442 | ld (iy-INDEX),NN 443 | ; 444 | ld (NNNN),a 445 | ld (NNNN),bc 446 | ld (NNNN),de 447 | ld (NNNN),hl 448 | ld (NNNN),ix 449 | ld (NNNN),iy 450 | ld (NNNN),sp 451 | ; 452 | ld a,(bc) 453 | ld a,(de) 454 | ld a,(hl) 455 | ld a,(ix) 456 | ld a,(ix+INDEX) 457 | ld a,(ix-INDEX) 458 | ld a,(iy) 459 | ld a,(iy+INDEX) 460 | ld a,(iy-INDEX) 461 | ld a,(NNNN) 462 | ld a,a 463 | ld a,b 464 | ld a,c 465 | ld a,d 466 | ld a,e 467 | ld a,h 468 | ld a,i 469 | ld a,l 470 | ld a,NN 471 | ld a,r 472 | ; 473 | ld b,(hl) 474 | ld b,(ix) 475 | ld b,(ix+INDEX) 476 | ld b,(ix-INDEX) 477 | ld b,(iy) 478 | ld b,(iy+INDEX) 479 | ld b,(iy-INDEX) 480 | ld b,a 481 | ld b,b 482 | ld b,c 483 | ld b,d 484 | ld b,e 485 | ld b,h 486 | ld b,l 487 | ld b,NN 488 | ; 489 | ld bc,(NNNN) 490 | ld bc,NNNN 491 | ; 492 | ld c,(hl) 493 | ld c,(ix) 494 | ld c,(ix+INDEX) 495 | ld c,(ix-INDEX) 496 | ld c,(iy) 497 | ld c,(iy+INDEX) 498 | ld c,(iy-INDEX) 499 | ld c,a 500 | ld c,b 501 | ld c,c 502 | ld c,d 503 | ld c,e 504 | ld c,h 505 | ld c,l 506 | ld c,NN 507 | ; 508 | ld d,(hl) 509 | ld d,(ix) 510 | ld d,(ix+INDEX) 511 | ld d,(ix-INDEX) 512 | ld d,(iy) 513 | ld d,(iy+INDEX) 514 | ld d,(iy-INDEX) 515 | ld d,a 516 | ld d,b 517 | ld d,c 518 | ld d,d 519 | ld d,e 520 | ld d,h 521 | ld d,l 522 | ld d,NN 523 | ; 524 | ld de,(NNNN) 525 | ld de,NNNN 526 | ; 527 | ld e,(hl) 528 | ld e,(ix) 529 | ld e,(ix+INDEX) 530 | ld e,(ix-INDEX) 531 | ld e,(iy) 532 | ld e,(iy+INDEX) 533 | ld e,(iy-INDEX) 534 | ld e,a 535 | ld e,b 536 | ld e,c 537 | ld e,d 538 | ld e,e 539 | ld e,h 540 | ld e,l 541 | ld e,NN 542 | ; 543 | ld h,(hl) 544 | ld h,(ix) 545 | ld h,(ix+INDEX) 546 | ld h,(ix-INDEX) 547 | ld h,(iy) 548 | ld h,(iy+INDEX) 549 | ld h,(iy-INDEX) 550 | ld h,a 551 | ld h,b 552 | ld h,c 553 | ld h,d 554 | ld h,e 555 | ld h,h 556 | ld h,l 557 | ld h,NN 558 | ; 559 | ld hl,(NNNN) 560 | ld hl,NNNN 561 | ; 562 | ld i,a 563 | ; 564 | ld ix,(NNNN) 565 | ld ix,NNNN 566 | ; 567 | ld iy,(NNNN) 568 | ld iy,NNNN 569 | ; 570 | ld l,(hl) 571 | ld l,(ix) 572 | ld l,(ix+INDEX) 573 | ld l,(ix-INDEX) 574 | ld l,(iy) 575 | ld l,(iy+INDEX) 576 | ld l,(iy-INDEX) 577 | ld l,a 578 | ld l,b 579 | ld l,c 580 | ld l,d 581 | ld l,e 582 | ld l,h 583 | ld l,l 584 | ld l,NN 585 | ; 586 | ld r,a 587 | ; 588 | ld sp,(NNNN) 589 | ld sp,hl 590 | ld sp,ix 591 | ld sp,iy 592 | ld sp,NNNN 593 | ; 594 | ldd 595 | lddr 596 | ldi 597 | ldir 598 | ; 599 | neg 600 | ; 601 | nop 602 | ; 603 | or (hl) 604 | or (ix) 605 | or (ix+INDEX) 606 | or (ix-INDEX) 607 | or (iy) 608 | or (iy+INDEX) 609 | or (iy-INDEX) 610 | or a 611 | or b 612 | or c 613 | or d 614 | or e 615 | or h 616 | or l 617 | or NN 618 | ; 619 | otdr 620 | otir 621 | ; 622 | out (c),a 623 | out (c),b 624 | out (c),c 625 | out (c),d 626 | out (c),e 627 | out (c),h 628 | out (c),l 629 | out (NN),a 630 | ; 631 | outd 632 | outi 633 | ; 634 | pop af 635 | pop bc 636 | pop de 637 | pop hl 638 | pop ix 639 | pop iy 640 | push af 641 | push bc 642 | push de 643 | push hl 644 | push ix 645 | push iy 646 | ; 647 | res 0,(hl) 648 | res 0,(ix) 649 | res 0,(ix+INDEX) 650 | res 0,(ix-INDEX) 651 | res 0,(iy) 652 | res 0,(iy+INDEX) 653 | res 0,(iy-INDEX) 654 | res 0,a 655 | res 0,b 656 | res 0,c 657 | res 0,d 658 | res 0,e 659 | res 0,h 660 | res 0,l 661 | ; 662 | res 1,(hl) 663 | res 1,(ix) 664 | res 1,(ix+INDEX) 665 | res 1,(ix-INDEX) 666 | res 1,(iy) 667 | res 1,(iy+INDEX) 668 | res 1,(iy-INDEX) 669 | res 1,a 670 | res 1,b 671 | res 1,c 672 | res 1,d 673 | res 1,e 674 | res 1,h 675 | res 1,l 676 | ; 677 | res 2,(hl) 678 | res 2,(ix) 679 | res 2,(ix+INDEX) 680 | res 2,(ix-INDEX) 681 | res 2,(iy) 682 | res 2,(iy+INDEX) 683 | res 2,(iy-INDEX) 684 | res 2,a 685 | res 2,b 686 | res 2,c 687 | res 2,d 688 | res 2,e 689 | res 2,h 690 | res 2,l 691 | ; 692 | res 3,(hl) 693 | res 3,(ix) 694 | res 3,(ix+INDEX) 695 | res 3,(ix-INDEX) 696 | res 3,(iy) 697 | res 3,(iy+INDEX) 698 | res 3,(iy-INDEX) 699 | res 3,a 700 | res 3,b 701 | res 3,c 702 | res 3,d 703 | res 3,e 704 | res 3,h 705 | res 3,l 706 | ; 707 | res 4,(hl) 708 | res 4,(ix) 709 | res 4,(ix+INDEX) 710 | res 4,(ix-INDEX) 711 | res 4,(iy) 712 | res 4,(iy+INDEX) 713 | res 4,(iy-INDEX) 714 | res 4,a 715 | res 4,b 716 | res 4,c 717 | res 4,d 718 | res 4,e 719 | res 4,h 720 | res 4,l 721 | ; 722 | res 5,(hl) 723 | res 5,(ix) 724 | res 5,(ix+INDEX) 725 | res 5,(ix-INDEX) 726 | res 5,(iy) 727 | res 5,(iy+INDEX) 728 | res 5,(iy-INDEX) 729 | res 5,a 730 | res 5,b 731 | res 5,c 732 | res 5,d 733 | res 5,e 734 | res 5,h 735 | res 5,l 736 | ; 737 | res 6,(hl) 738 | res 6,(ix) 739 | res 6,(ix+INDEX) 740 | res 6,(ix-INDEX) 741 | res 6,(iy) 742 | res 6,(iy+INDEX) 743 | res 6,(iy-INDEX) 744 | res 6,a 745 | res 6,b 746 | res 6,c 747 | res 6,d 748 | res 6,e 749 | res 6,h 750 | res 6,l 751 | ; 752 | res 7,(hl) 753 | res 7,(ix) 754 | res 7,(ix+INDEX) 755 | res 7,(ix-INDEX) 756 | res 7,(iy) 757 | res 7,(iy+INDEX) 758 | res 7,(iy-INDEX) 759 | res 7,a 760 | res 7,b 761 | res 7,c 762 | res 7,d 763 | res 7,e 764 | res 7,h 765 | res 7,l 766 | ; 767 | ret 768 | ret c 769 | ret m 770 | ret nc 771 | ret nz 772 | ret p 773 | ret pe 774 | ret po 775 | ret z 776 | ; 777 | reti 778 | retn 779 | ; 780 | rl (hl) 781 | rl (ix) 782 | rl (ix+INDEX) 783 | rl (ix-INDEX) 784 | rl (iy) 785 | rl (iy+INDEX) 786 | rl (iy-INDEX) 787 | rl a 788 | rl b 789 | rl c 790 | rl d 791 | rl e 792 | rl h 793 | rl l 794 | ; 795 | rla 796 | ; 797 | rlc (hl) 798 | rlc (ix) 799 | rlc (ix+INDEX) 800 | rlc (ix-INDEX) 801 | rlc (iy) 802 | rlc (iy+INDEX) 803 | rlc (iy-INDEX) 804 | rlc a 805 | rlc b 806 | rlc c 807 | rlc d 808 | rlc e 809 | rlc h 810 | rlc l 811 | ; 812 | rlca 813 | ; 814 | rld 815 | ; 816 | rr (hl) 817 | rr (ix) 818 | rr (ix+INDEX) 819 | rr (ix-INDEX) 820 | rr (iy) 821 | rr (iy+INDEX) 822 | rr (iy-INDEX) 823 | rr a 824 | rr b 825 | rr c 826 | rr d 827 | rr e 828 | rr h 829 | rr l 830 | ; 831 | rra 832 | ; 833 | rrc (hl) 834 | rrc (ix) 835 | rrc (ix+INDEX) 836 | rrc (ix-INDEX) 837 | rrc (iy) 838 | rrc (iy+INDEX) 839 | rrc (iy-INDEX) 840 | rrc a 841 | rrc b 842 | rrc c 843 | rrc d 844 | rrc e 845 | rrc h 846 | rrc l 847 | ; 848 | rrca 849 | ; 850 | rrd 851 | ; 852 | rst 0 853 | rst 08H 854 | rst 10H 855 | rst 18H 856 | rst 20H 857 | rst 28H 858 | rst 30H 859 | rst 38H 860 | ; 861 | sbc a,(hl) 862 | sbc (hl) 863 | sbc a,(ix) 864 | sbc (ix+INDEX) 865 | sbc a,(ix-INDEX) 866 | sbc (ix-INDEX) 867 | sbc a,(iy) 868 | sbc (iy+INDEX) 869 | sbc a,(iy-INDEX) 870 | sbc (iy-INDEX) 871 | sbc a,a 872 | sbc a 873 | sbc a,b 874 | sbc b 875 | sbc a,c 876 | sbc c 877 | sbc a,d 878 | sbc d 879 | sbc a,e 880 | sbc e 881 | sbc a,h 882 | sbc h 883 | sbc a,l 884 | sbc l 885 | sbc a,NN 886 | sbc NN 887 | ; 888 | sbc hl,bc 889 | sbc hl,de 890 | sbc hl,hl 891 | sbc hl,sp 892 | ; 893 | scf 894 | ; 895 | set 0,(hl) 896 | set 0,(ix) 897 | set 0,(ix+INDEX) 898 | set 0,(ix-INDEX) 899 | set 0,(iy) 900 | set 0,(iy+INDEX) 901 | set 0,(iy-INDEX) 902 | set 0,a 903 | set 0,b 904 | set 0,c 905 | set 0,d 906 | set 0,e 907 | set 0,h 908 | set 0,l 909 | ; 910 | set 1,(hl) 911 | set 1,(ix) 912 | set 1,(ix+INDEX) 913 | set 1,(ix-INDEX) 914 | set 1,(iy) 915 | set 1,(iy+INDEX) 916 | set 1,(iy-INDEX) 917 | set 1,a 918 | set 1,b 919 | set 1,c 920 | set 1,d 921 | set 1,e 922 | set 1,h 923 | set 1,l 924 | ; 925 | set 2,(hl) 926 | set 2,(ix) 927 | set 2,(ix+INDEX) 928 | set 2,(ix-INDEX) 929 | set 2,(iy) 930 | set 2,(iy+INDEX) 931 | set 2,(iy-INDEX) 932 | set 2,a 933 | set 2,b 934 | set 2,c 935 | set 2,d 936 | set 2,e 937 | set 2,h 938 | set 2,l 939 | ; 940 | set 3,(hl) 941 | set 3,(ix) 942 | set 3,(ix+INDEX) 943 | set 3,(ix-INDEX) 944 | set 3,(iy) 945 | set 3,(iy+INDEX) 946 | set 3,(iy-INDEX) 947 | set 3,a 948 | set 3,b 949 | set 3,c 950 | set 3,d 951 | set 3,e 952 | set 3,h 953 | set 3,l 954 | ; 955 | set 4,(hl) 956 | set 4,(ix) 957 | set 4,(ix+INDEX) 958 | set 4,(ix-INDEX) 959 | set 4,(iy) 960 | set 4,(iy+INDEX) 961 | set 4,(iy-INDEX) 962 | set 4,a 963 | set 4,b 964 | set 4,c 965 | set 4,d 966 | set 4,e 967 | set 4,h 968 | set 4,l 969 | ; 970 | set 5,(hl) 971 | set 5,(ix) 972 | set 5,(ix+INDEX) 973 | set 5,(ix-INDEX) 974 | set 5,(iy) 975 | set 5,(iy+INDEX) 976 | set 5,(iy-INDEX) 977 | set 5,a 978 | set 5,b 979 | set 5,c 980 | set 5,d 981 | set 5,e 982 | set 5,h 983 | set 5,l 984 | ; 985 | set 6,(hl) 986 | set 6,(ix) 987 | set 6,(ix+INDEX) 988 | set 6,(ix-INDEX) 989 | set 6,(iy) 990 | set 6,(iy+INDEX) 991 | set 6,(iy-INDEX) 992 | set 6,a 993 | set 6,b 994 | set 6,c 995 | set 6,d 996 | set 6,e 997 | set 6,h 998 | set 6,l 999 | ; 1000 | set 7,(hl) 1001 | set 7,(ix) 1002 | set 7,(ix+INDEX) 1003 | set 7,(ix-INDEX) 1004 | set 7,(iy) 1005 | set 7,(iy+INDEX) 1006 | set 7,(iy-INDEX) 1007 | set 7,a 1008 | set 7,b 1009 | set 7,c 1010 | set 7,d 1011 | set 7,e 1012 | set 7,h 1013 | set 7,l 1014 | ; 1015 | sla (hl) 1016 | sla (ix) 1017 | sla (ix+INDEX) 1018 | sla (ix-INDEX) 1019 | sla (iy) 1020 | sla (iy+INDEX) 1021 | sla (iy-INDEX) 1022 | sla a 1023 | sla b 1024 | sla c 1025 | sla d 1026 | sla e 1027 | sla h 1028 | sla l 1029 | ; 1030 | sra (hl) 1031 | sra (ix) 1032 | sra (ix+INDEX) 1033 | sra (ix-INDEX) 1034 | sra (iy) 1035 | sra (iy+INDEX) 1036 | sra (iy-INDEX) 1037 | sra a 1038 | sra b 1039 | sra c 1040 | sra d 1041 | sra e 1042 | sra h 1043 | sra l 1044 | ; 1045 | srl (hl) 1046 | srl (ix) 1047 | srl (ix+INDEX) 1048 | srl (ix-INDEX) 1049 | srl (iy) 1050 | srl (iy+INDEX) 1051 | srl (iy-INDEX) 1052 | srl a 1053 | srl b 1054 | srl c 1055 | srl d 1056 | srl e 1057 | srl h 1058 | srl l 1059 | ; 1060 | sub (hl) 1061 | sub (ix) 1062 | sub (ix+INDEX) 1063 | sub (ix-INDEX) 1064 | sub (iy) 1065 | sub (iy+INDEX) 1066 | sub (iy-INDEX) 1067 | sub a 1068 | sub b 1069 | sub c 1070 | sub d 1071 | sub e 1072 | sub h 1073 | sub l 1074 | sub NN 1075 | ; 1076 | xor (hl) 1077 | xor (ix) 1078 | xor (ix+INDEX) 1079 | xor (ix-INDEX) 1080 | xor (iy) 1081 | xor (iy+INDEX) 1082 | xor (iy-INDEX) 1083 | xor a 1084 | xor b 1085 | xor c 1086 | xor d 1087 | xor e 1088 | xor h 1089 | xor l 1090 | xor NN 1091 | ; 1092 | title 1093 | ; 1094 | ; EXPRESSION EVALUATION TEST 1095 | ; 1096 | ONE: equ 1 1097 | TWO: equ ONE+ONE 1098 | FOUR: equ ONE+TWO+ONE 1099 | EIGHT: equ FOUR+FOUR+FOUR+FOUR/2 ;STRICTLY LEFT TO RIGHT 1100 | ; 1101 | VALUE: equ 10010B .Shl. 8 +34H ;SHOULD BE 1234H 1102 | ; 1103 | dw .NOT. VALUE ;COMPLEMENT 1104 | dw VALUE .MOD. 16 ;MODULO 1105 | dw VALUE\16 ;ALTERNATIVE MODULO *** new version *** 1106 | ; 1107 | dw ONE .Shl. 1 ;SHIFT LEFT ONCE 1108 | dw ONE .Shl. 2 ;SHIFT LEFT TWICE 1109 | dw ONE .Shl. 3 ;SHIFT LEFT 3 TIMES 1110 | dw ONE .Shl. 4 ;SHIFT LEFT 4 TIMES 1111 | dw ONE .Shl. 5 ;SHIFT LEFT 5 TIMES 1112 | dw ONE .Shl. 6 ;SHIFT LEFT 6 TIMES 1113 | dw ONE .Shl. 7 ;SHIFT LEFT 7 TIMES 1114 | dw ONE .Shl. 8 ;SHIFT LEFT 8 TIMES 1115 | dw ONE .Shl. 9 ;SHIFT LEFT 9 TIMES 1116 | dw ONE .Shl. 10 ;SHIFT LEFT 10 TIMES 1117 | dw ONE .Shl. 11 ;SHIFT LEFT 11 TIMES 1118 | dw ONE .Shl. 12 ;SHIFT LEFT 12 TIMES 1119 | dw ONE .Shl. 13 ;SHIFT LEFT 13 TIMES 1120 | dw ONE .Shl. 14 ;SHIFT LEFT 14 TIMES 1121 | dw ONE .Shl. 15 ;SHIFT LEFT 15 TIMES 1122 | dw ONE .Shl. 16 ;SHIFT LEFT TOO MANY TIMES 1123 | ; 1124 | BIT15: equ 8000H 1125 | ; 1126 | dw bit15 .SHR. 1 ;SHIFT RIGHT ONCE 1127 | dw bit15 .SHR. 2 ;SHIFT RIGHT TWICE 1128 | dw bit15 .SHR. 3 ;SHIFT RIGHT 3 TIMES 1129 | dw bit15 .SHR. 4 ;SHIFT RIGHT 4 TIMES 1130 | dw bit15 .SHR. 5 ;SHIFT RIGHT 5 TIMES 1131 | dw bit15 .SHR. 6 ;SHIFT RIGHT 6 TIMES 1132 | dw bit15 .SHR. 7 ;SHIFT RIGHT 7 TIMES 1133 | dw bit15 .SHR. 8 ;SHIFT RIGHT 8 TIMES 1134 | dw bit15 .SHR. 9 ;SHIFT RIGHT 9 TIMES 1135 | dw bit15 .SHR. 10 ;SHIFT RIGHT 10 TIMES 1136 | dw bit15 .SHR. 11 ;SHIFT RIGHT 11 TIMES 1137 | dw bit15 .SHR. 12 ;SHIFT RIGHT 12 TIMES 1138 | dw bit15 .SHR. 13 ;SHIFT RIGHT 13 TIMES 1139 | dw bit15 .SHR. 14 ;SHIFT RIGHT 14 TIMES 1140 | dw bit15 .SHR. 15 ;SHIFT RIGHT 15 TIMES 1141 | dw bit15 .SHR. 16 ;SHIFT RIGHT TOO MANY TIMES 1142 | ; 1143 | ; LOGICAL OPERATORS 1144 | ; 1145 | dw VALUE .AND. 0FF00H 1146 | dw VALUE .OR. 0FF00H 1147 | dw VALUE .XOR. 0FF00H 1148 | ; 1149 | ; HIGH AND LOW BYTE 1150 | ; 1151 | dw .LOW. VALUE 1152 | dw .HIGH. VALUE 1153 | ; 1154 | ; COMPARISONS 1155 | ; 1156 | dw ONE.EQ.TWO 1157 | dw ONE.EQ.ONE 1158 | dw TWO.EQ.ONE 1159 | ; 1160 | dw ONE.NE.TWO 1161 | dw ONE.NE.ONE 1162 | dw TWO.NE.ONE 1163 | ; 1164 | dw ONE.LT.TWO 1165 | dw ONE.LT.ONE 1166 | dw TWO.LT.ONE 1167 | ; 1168 | dw ONE.LE.TWO 1169 | dw ONE.LE.ONE 1170 | dw TWO.LE.ONE 1171 | ; 1172 | dw ONE.GT.TWO 1173 | dw ONE.GT.ONE 1174 | dw TWO.GT.ONE 1175 | ; 1176 | dw ONE.GE.TWO 1177 | dw ONE.GE.ONE 1178 | dw TWO.GE.ONE 1179 | ; 1180 | ; 1181 | dw ONE=TWO 1182 | dw ONE=ONE 1183 | dw TWO=ONE 1184 | ; 1185 | dw ONE>TWO 1186 | dw ONE>ONE 1187 | dw TWO>ONE 1188 | ; 1189 | dw ONE