mirror of
https://github.com/antoinevignau/source.git
synced 2025-01-01 15:30:02 +00:00
1 line
14 KiB
Plaintext
Executable File
1 line
14 KiB
Plaintext
Executable File
;............................................................................;
|
||
;
|
||
; Compare long word for zero macro
|
||
;
|
||
; Cpzl addr Cpzl addr:#off
|
||
; Cpzl addr:x Cpzl [zp]
|
||
; Cpzl addr:y Cpzl [zp]:y
|
||
; Cpzl addr:s Cpzl [zp]:off
|
||
; Cpzl addr:off Cpzl [zp]:#off
|
||
;
|
||
;............................................................................;
|
||
MACRO
|
||
&lab Cpzl &loc
|
||
&lab ;
|
||
lclc &char
|
||
lcla &offset
|
||
lclc &rest
|
||
lclc &disp
|
||
&char setc &substr(&loc,1,1)
|
||
&offset seta &pos(':',&loc)
|
||
IF &offset GOTO .docmpoff
|
||
IF (&char='[') GOTO .docmpzp
|
||
lda &loc
|
||
ora &loc+2
|
||
mexit
|
||
.docmpzp
|
||
lda &loc
|
||
ldy #2
|
||
ora &loc,y
|
||
mexit
|
||
.docmpoff
|
||
&rest setc &substr(&loc,1,&offset-1)
|
||
&disp setc &substr(&loc,&offset+1,&len(&loc)-&offset)
|
||
IF &char='[' GOTO .docmpoffzp
|
||
IF (&disp='s') or (&disp='x') or (&disp='y') GOTO .docmpoffi
|
||
ldx &disp
|
||
&disp setc 'x'
|
||
.docmpoffi
|
||
lda &rest,&disp
|
||
ora &rest+2,&disp
|
||
mexit
|
||
.docmpoffzp
|
||
IF (&disp='y') GOTO .doy
|
||
ldy &disp
|
||
.doy
|
||
lda &rest,y
|
||
iny
|
||
iny
|
||
ora &rest,y
|
||
mexit
|
||
MEND
|
||
*=======================================================================*
|
||
|
||
macro
|
||
&lab CmpByte &from,&to
|
||
&lab cmpb &from,&to
|
||
mend
|
||
|
||
*=======================================================================*
|
||
|
||
macro
|
||
&lab CmpWord &from,&to
|
||
&lab cmpw &from,&to
|
||
mend
|
||
|
||
*=======================================================================*
|
||
|
||
macro
|
||
&lab CmpLong &from,&to
|
||
&lab cmpl &from,&to
|
||
mend
|
||
|
||
*=======================================================================*
|
||
|
||
MACRO
|
||
&lab Cmpl &from,&to
|
||
&lab ;
|
||
lcla &noy1
|
||
lcla &noy2
|
||
lcla &nox1
|
||
lcla &nox2
|
||
lcla &ypushed
|
||
lcla &yinced
|
||
lcla &xpushed
|
||
lcla &yhas2
|
||
lcla &const1
|
||
lcla &addr1
|
||
lcla &a1off
|
||
lcla &a2off
|
||
lcla &needbra
|
||
lcla &sameoff
|
||
lclc &cmpreg
|
||
lclc &fdisp
|
||
lclc &tdisp
|
||
lclc &floc
|
||
lclc &tloc
|
||
lclc &fchar
|
||
lclc &tchar
|
||
lcla &foffset
|
||
lcla &toffset
|
||
lclc &newfrom
|
||
lclc &newto
|
||
lcla &num
|
||
&newfrom setc &from
|
||
&newto setc &to
|
||
&fchar setc &substr(&from,1,1)
|
||
&tchar setc &substr(&to,1,1)
|
||
&foffset seta &pos(':',&from)
|
||
&toffset seta &pos(':',&to)
|
||
IF &foffset=0 GOTO .nofoff
|
||
&floc setc &substr(&from,1,&foffset-1)
|
||
&fdisp setc &substr(&from,&foffset+1,&len(&from)-&foffset)
|
||
.nofoff
|
||
IF &toffset GOTO .gettoff
|
||
GOTO .setnox2
|
||
|
||
.gettoff
|
||
&tloc setc &substr(&to,1,&toffset-1)
|
||
&tdisp setc &substr(&to,&toffset+1,&len(&to)-&toffset)
|
||
IF (&tdisp='s') or (&tdisp='y') or (&tchar='[') GOTO .setnox2
|
||
IF (&tdisp='x') GOTO .setnoy2
|
||
&a2off seta 1
|
||
GOTO .setnoy2
|
||
|
||
.setnox2
|
||
&nox2 seta 1
|
||
IF (&tdisp='y') GOTO .notoff
|
||
.setnoy2
|
||
&noy2 seta 1
|
||
.notoff
|
||
IF not (&foffset and &toffset) GOTO .notsame
|
||
&num seta &pos(&tdisp,&fdisp)
|
||
IF &num=0 GOTO .notsame
|
||
IF (&tchar='[') and (&fchar<61>'[') GOTO .notsame
|
||
IF (&fchar='[') and (&tchar<61>'[') GOTO .notsame
|
||
&sameoff seta 1
|
||
.notsame
|
||
&cmpreg setc 'a'
|
||
IF &foffset GOTO .fromoff
|
||
IF &fchar='[' GOTO .fromzp
|
||
IF &fchar='#' GOTO .fromimm
|
||
IF &from='ax' GOTO .fromxhigh
|
||
IF (&from='ay') or (&from='xy') GOTO .fromyhigh
|
||
&addr1 seta 1
|
||
lda &from+2
|
||
GOTO .doto
|
||
|
||
.fromyhigh
|
||
&cmpreg setc 'y'
|
||
GOTO .doto
|
||
|
||
.fromxhigh
|
||
&cmpreg setc 'x'
|
||
GOTO .doto
|
||
|
||
.fromimm
|
||
&newfrom setc &substr(&from,2,&len(&from)-1)
|
||
lda #^&newfrom
|
||
&const1 seta 1
|
||
GOTO .doto
|
||
|
||
.fromzp
|
||
IF &noy2 GOTO .fromzpnophy
|
||
phy
|
||
&ypushed seta 1
|
||
.fromzpnophy
|
||
ldy #2
|
||
lda &from,y
|
||
&yhas2 seta 1
|
||
&nox1 seta 1
|
||
GOTO .doto
|
||
|
||
.fromoff
|
||
IF &fdisp='y' GOTO .fromy
|
||
IF &fchar='[' GOTO .fromzpoff
|
||
&noy1 seta 1
|
||
IF &fdisp='x' GOTO .fromx
|
||
IF &fdisp='s' GOTO .froms
|
||
&a1off seta 1
|
||
IF &sameoff GOTO .fromoffonly1
|
||
IF &a2off GOTO .nofromphx
|
||
IF not (&nox2) GOTO .fromoffphx
|
||
&newfrom setc &concat(&floc,':x')
|
||
GOTO .nofromphx
|
||
|
||
.fromoffonly1
|
||
&newto setc &concat(&tloc,':x')
|
||
&newfrom setc &concat(&floc,':x')
|
||
GOTO .nofromphx
|
||
|
||
.fromoffphx
|
||
phx
|
||
&xpushed seta 1
|
||
.nofromphx
|
||
ldx &fdisp
|
||
lda &floc+2,x
|
||
GOTO .doto
|
||
|
||
.fromzpoff
|
||
&nox1 seta 1
|
||
IF &noy2 GOTO .fromzpoffldy
|
||
phy
|
||
&ypushed seta 1
|
||
.fromzpoffldy
|
||
ldy &fdisp+2
|
||
lda &floc,y
|
||
GOTO .doto
|
||
|
||
.froms
|
||
&nox1 seta 1
|
||
lda &floc+2,s
|
||
GOTO .doto
|
||
|
||
.fromy
|
||
&nox1 seta 1
|
||
IF &fchar='[' GOTO .fromyzp
|
||
lda &floc+2,y
|
||
GOTO .doto
|
||
|
||
.fromyzp
|
||
phy
|
||
iny
|
||
iny
|
||
&ypushed seta 1
|
||
&yinced seta 1
|
||
lda &floc,y
|
||
IF &tchar='[' GOTO .doto
|
||
IF not (&noy2) GOTO .doto
|
||
ply
|
||
&ypushed seta 0
|
||
&yinced seta 0
|
||
GOTO .doto
|
||
|
||
.fromx
|
||
lda &floc+2,x
|
||
GOTO .doto
|
||
|
||
.doto
|
||
IF &toffset GOTO .tooff
|
||
IF &tchar='[' GOTO .tozp
|
||
IF &tchar='#' GOTO .toimm
|
||
cp&cmpreg &to+2
|
||
GOTO .dolow
|
||
|
||
.toimm
|
||
&newto setc &substr(&to,2,&len(&to)-1)
|
||
cp&cmpreg #^&newto
|
||
GOTO .dolow
|
||
|
||
.tozp
|
||
IF &yhas2 GOTO .tozpnoload
|
||
IF &ypushed GOTO .tozpload
|
||
IF &noy1 or &const1 or &addr1 GOTO .tozpload
|
||
IF (&fdisp<73>'y') and (&fchar='[') GOTO .tozpload
|
||
phy
|
||
&ypushed seta 1
|
||
.tozpload
|
||
ldy #2
|
||
.tozpnoload
|
||
cp&cmpreg &to,y
|
||
GOTO .dolow
|
||
|
||
.tooff
|
||
IF &tdisp='x' GOTO .tox
|
||
IF &tdisp='y' GOTO .toy
|
||
IF &tdisp='s' GOTO .tos
|
||
IF &tchar='[' GOTO .tozpoff
|
||
IF &sameoff GOTO .noloadx
|
||
IF &xpushed or &a1off GOTO .loadx
|
||
IF not (&nox1 or &const1 or &addr1) GOTO .tooffphx
|
||
&newto setc &concat(&tloc,':x')
|
||
GOTO .loadx
|
||
|
||
.tooffphx
|
||
phx
|
||
&xpushed seta 1
|
||
.loadx
|
||
ldx &tdisp
|
||
.noloadx
|
||
cp&cmpreg &tloc+2,x
|
||
GOTO .dolow
|
||
|
||
.tozpoff
|
||
IF &sameoff GOTO .noloady
|
||
IF &ypushed GOTO .loady
|
||
IF &noy1 or &const1 or &addr1 GOTO .loady
|
||
IF (&fdisp<73>'y') and (&fchar='[') GOTO .loady
|
||
IF &foffset=0 GOTO .loady
|
||
phy
|
||
&ypushed seta 1
|
||
.loady
|
||
ldy &tdisp+2
|
||
.noloady
|
||
cp&cmpreg &tloc,y
|
||
GOTO .dolow
|
||
|
||
.tos
|
||
cp&cmpreg &tloc+2,s
|
||
GOTO .dolow
|
||
|
||
.toy
|
||
IF &tchar='[' GOTO .toyzp
|
||
IF not (&ypushed) GOTO .toydo
|
||
ply
|
||
&ypushed seta 0
|
||
.toydo
|
||
cp&cmpreg &tloc+2,y
|
||
GOTO .dolow
|
||
|
||
.toyzp
|
||
IF &yinced GOTO .toyzpdo
|
||
IF not (&ypushed) GOTO .toypush
|
||
ply
|
||
.toypush
|
||
phy
|
||
&ypushed seta 1
|
||
iny
|
||
iny
|
||
.toyzpdo
|
||
cp&cmpreg &tloc,y
|
||
GOTO .dolow
|
||
|
||
.tox
|
||
IF not (&xpushed) GOTO .toxdo
|
||
plx
|
||
&xpushed seta 0
|
||
.toxdo
|
||
cp&cmpreg &tloc+2,x
|
||
GOTO .dolow
|
||
|
||
.dolow
|
||
bne ~b&sysindex
|
||
IF not (&xpushed or &ypushed) GOTO .dolow2
|
||
IF not (&xpushed) GOTO .checky
|
||
plx
|
||
.checky
|
||
IF not (&ypushed) GOTO .dolow2
|
||
ply
|
||
.dolow2
|
||
&newfrom setc &from
|
||
IF (&from='ax') or (&from='ay') GOTO .setalow
|
||
IF not (&from='xy') GOTO .dolow3
|
||
&newfrom setc 'x'
|
||
GOTO .dolow3
|
||
|
||
.setalow
|
||
&newfrom setc 'a'
|
||
.dolow3
|
||
cmpw &newfrom,&to
|
||
IF not (&xpushed or &ypushed) GOTO .finish
|
||
bra ~a&sysindex
|
||
.finish
|
||
~b&sysindex ;
|
||
IF (&xpushed or &ypushed) GOTO .doend
|
||
mexit
|
||
.doend
|
||
IF not (&xpushed) GOTO .chky
|
||
plx
|
||
.chky
|
||
IF &ypushed GOTO .gety
|
||
~a&sysindex ;
|
||
mexit
|
||
.gety
|
||
ply
|
||
~a&sysindex ;
|
||
mend
|
||
|
||
********************************************************************
|
||
* This macro compares 2 bytes
|
||
*
|
||
* Wednesday, April 26, 1989 11:13:20 PM
|
||
********************************************************************
|
||
|
||
MACRO
|
||
&lab Cmpb &from,&to
|
||
&lab
|
||
short m
|
||
Cmpw &from,&to
|
||
long m
|
||
Mend
|
||
|
||
*=======================================================================*
|
||
|
||
MACRO
|
||
&lab Cmpw &from,&to
|
||
&lab ;
|
||
lcla &sameoff
|
||
lcla &nox2
|
||
lcla &noy2
|
||
lclc &cmpreg
|
||
lclc &fdisp
|
||
lclc &tdisp
|
||
lclc &floc
|
||
lclc &tloc
|
||
lcla &foffset
|
||
lcla &toffset
|
||
lclc &fchar
|
||
lclc &tchar
|
||
lcla &num
|
||
lclc &newfrom
|
||
&newfrom setc &from
|
||
lcla &ppos
|
||
&ppos seta &pos('.',&from)
|
||
IF &ppos=0 GOTO .noeval
|
||
eval &from
|
||
&newfrom setc 'a'
|
||
.noeval
|
||
&fchar setc &substr(&newfrom,1,1)
|
||
&tchar setc &substr(&to,1,1)
|
||
&foffset seta &pos(':',&newfrom)
|
||
&toffset seta &pos(':',&to)
|
||
IF &foffset=0 GOTO .nofoff
|
||
&floc setc &substr(&from,1,&foffset-1)
|
||
&fdisp setc &substr(&from,&foffset+1,&len(&newfrom)-&foffset)
|
||
.nofoff
|
||
IF &toffset GOTO .gettoff
|
||
GOTO .setnox2
|
||
|
||
.gettoff
|
||
&tloc setc &substr(&to,1,&toffset-1)
|
||
&tdisp setc &substr(&to,&toffset+1,&len(&to)-&toffset)
|
||
IF (&tdisp='s') or (&tdisp='y') or (&tchar='[') GOTO .setnox2
|
||
GOTO .setnoy2
|
||
|
||
.setnox2
|
||
&nox2 seta 1
|
||
IF (&tdisp='y') GOTO .notoff
|
||
.setnoy2
|
||
&noy2 seta 1
|
||
.notoff
|
||
IF not (&foffset and &toffset) GOTO .notsame
|
||
&num seta &pos(&tdisp,&fdisp)
|
||
IF &num=0 GOTO .notsame
|
||
IF (&tchar='[') and (&fchar<61>'[') GOTO .notsame
|
||
IF (&fchar='[') and (&tchar<61>'[') GOTO .notsame
|
||
&sameoff seta 1
|
||
.notsame
|
||
&cmpreg setc 'a'
|
||
IF &foffset GOTO .fromoff
|
||
IF (&newfrom='a') or (&newfrom='x') or (&newfrom='y') GOTO .fromreg
|
||
IF &fchar='#' AND &pos(&substr(&newfrom,2,1),'<^>')=0 THEN
|
||
lda #<&substr(&newfrom,2,&len(&newfrom)-1)
|
||
ELSE
|
||
lda &newfrom
|
||
ENDIF
|
||
GOTO .doto
|
||
|
||
.fromreg
|
||
&cmpreg setc &newfrom
|
||
GOTO .doto
|
||
|
||
.fromoff
|
||
IF (&fdisp='x') or (&fdisp='y') or (&fdisp='s') GOTO .foffreg
|
||
IF &fchar='[' GOTO .fromoffzp
|
||
IF (&nox2) GOTO .dofromoff
|
||
IF not (&tdisp='x') GOTO .dofromoff
|
||
phx
|
||
.dofromoff
|
||
ldx &fdisp
|
||
lda &concat(&floc,',x')
|
||
IF &nox2 GOTO .doto
|
||
IF not (&tdisp='x') GOTO .doto
|
||
plx
|
||
GOTO .doto
|
||
|
||
.fromoffzp
|
||
IF &noy2 GOTO .dofromoffzp
|
||
phy
|
||
.dofromoffzp
|
||
ldy &fdisp
|
||
lda &concat(&floc,',y')
|
||
IF &noy2 GOTO .doto
|
||
ply
|
||
GOTO .doto
|
||
|
||
.foffreg
|
||
lda &concat(&floc,',',&fdisp)
|
||
.doto
|
||
IF &toffset GOTO .tooff
|
||
IF &substr(&to,1,1)='#' THEN
|
||
cp&cmpreg #<&substr(&to,2,&len(&to)-1)
|
||
ELSE
|
||
cp&cmpreg &to
|
||
ENDIF
|
||
mexit
|
||
.tooff
|
||
IF (&tdisp='x') or (&tdisp='y') or (&tdisp='s') GOTO .dotooff
|
||
IF &tchar='[' GOTO .tooffzp
|
||
IF &sameoff GOTO .noloadx
|
||
ldx &tdisp
|
||
.noloadx
|
||
cp&cmpreg &concat(&tloc,',x')
|
||
mexit
|
||
.tooffzp
|
||
IF &sameoff GOTO .noloady
|
||
ldy &tdisp
|
||
.noloady
|
||
cp&cmpreg &concat(&tloc,',y')
|
||
mexit
|
||
.dotooff
|
||
cp&cmpreg &concat(&tloc,',',&tdisp)
|
||
mend
|
||
|
||
*=======================================================================*
|
||
|
||
MACRO
|
||
&lab Scmpw &from,&to
|
||
&lab ;
|
||
lcla &sameoff
|
||
lcla &nox2
|
||
lcla &noy2
|
||
lclc &cmpreg
|
||
lclc &fdisp
|
||
lclc &tdisp
|
||
lclc &floc
|
||
lclc &tloc
|
||
lcla &foffset
|
||
lcla &toffset
|
||
lclc &fchar
|
||
lclc &tchar
|
||
lcla &num
|
||
lclc &newfrom
|
||
lclc &newto
|
||
|
||
&newfrom setc &from
|
||
&newto setc &to
|
||
&fchar setc &substr(&newfrom,1,1)
|
||
&tchar setc &substr(&newto,1,1)
|
||
&foffset seta &pos(':',&newfrom)
|
||
&toffset seta &pos(':',&newto)
|
||
IF &foffset=0 GOTO .nofoff
|
||
&floc setc &substr(&newfrom,1,&foffset-1)
|
||
&fdisp setc &substr(&newfrom,&foffset+1,&len(&newfrom)-&foffset)
|
||
.nofoff
|
||
IF &toffset GOTO .gettoff
|
||
GOTO .setnox2
|
||
|
||
.gettoff
|
||
&tloc setc &substr(&newto,1,&toffset-1)
|
||
&tdisp setc &substr(&newto,&toffset+1,&len(&newto)-&toffset)
|
||
IF (&tdisp='s') or (&tdisp='y') or (&tchar='[') GOTO .setnox2
|
||
GOTO .setnoy2
|
||
|
||
.setnox2
|
||
&nox2 seta 1
|
||
IF (&tdisp='y') GOTO .notoff
|
||
.setnoy2
|
||
&noy2 seta 1
|
||
.notoff
|
||
IF not (&foffset and &toffset) GOTO .notsame
|
||
&num seta &pos(&tdisp,&fdisp)
|
||
IF &num=0 GOTO .notsame
|
||
IF (&tchar='[') and (&fchar<61>'[') GOTO .notsame
|
||
IF (&fchar='[') and (&tchar<61>'[') GOTO .notsame
|
||
&sameoff seta 1
|
||
.notsame
|
||
&cmpreg setc 'a'
|
||
IF &foffset GOTO .fromoff
|
||
IF (&newfrom='a') or (&newfrom='x') or (&newfrom='y') GOTO .fromreg
|
||
sec
|
||
lda &newfrom
|
||
GOTO .doto
|
||
|
||
.fromreg
|
||
&cmpreg setc &newfrom
|
||
sec
|
||
GOTO .doto
|
||
|
||
.fromoff
|
||
IF (&fdisp='x') or (&fdisp='y') or (&fdisp='s') GOTO .foffreg
|
||
IF &fchar='[' GOTO .fromoffzp
|
||
IF (&nox2) GOTO .dofromoff
|
||
IF not (&tdisp='x') GOTO .dofromoff
|
||
phx
|
||
.dofromoff
|
||
ldx &fdisp
|
||
&newfrom setc &concat(&floc,',x')
|
||
sec
|
||
lda &newfrom
|
||
IF &nox2 GOTO .doto
|
||
IF not (&tdisp='x') GOTO .doto
|
||
plx
|
||
GOTO .doto
|
||
|
||
.fromoffzp
|
||
IF &noy2 GOTO .dofromoffzp
|
||
phy
|
||
.dofromoffzp
|
||
ldy &fdisp
|
||
&newfrom setc &concat(&floc,',y')
|
||
sec
|
||
lda &newfrom
|
||
IF &noy2 GOTO .doto
|
||
ply
|
||
GOTO .doto
|
||
|
||
.foffreg
|
||
&newfrom setc &concat(&floc,',',&fdisp)
|
||
sec
|
||
lda &newfrom
|
||
.doto
|
||
IF &toffset=0 GOTO .enditall
|
||
.tooff
|
||
IF (&tdisp='x') or (&tdisp='y') or (&tdisp='s') GOTO .dotooff
|
||
IF &tchar='[' GOTO .tooffzp
|
||
IF &sameoff GOTO .noloadx
|
||
ldx &tdisp
|
||
.noloadx
|
||
&newto setc &concat(&tloc,',x')
|
||
GOTO .enditall
|
||
|
||
.tooffzp
|
||
IF &sameoff GOTO .noloady
|
||
ldy &tdisp
|
||
.noloady
|
||
&newto setc &concat(&tloc,',y')
|
||
GOTO .enditall
|
||
|
||
.dotooff
|
||
&newto setc &concat(&tloc,',',&tdisp')
|
||
.enditall
|
||
sbc &newto
|
||
beq ~done&sysindex
|
||
clc
|
||
bvs ~invert&sysindex
|
||
bmi ~done&sysindex
|
||
bra ~greater&sysindex
|
||
~invert&sysindex bpl ~done&sysindex
|
||
~greater&sysindex sec
|
||
~done&sysindex ;
|
||
MEND
|