ORCA-Pascal/smac
2018-03-12 14:15:39 -04:00

258 lines
4.0 KiB
Plaintext

MACRO
&LAB ENUM &LIST,&START
&LAB ANOP
AIF C:&~ENUM,.A
GBLA &~ENUM
.A
AIF C:&START=0,.B
&~ENUM SETA &START
.B
LCLA &CNT
&CNT SETA 1
.C
&LIST(&CNT) EQU &~ENUM
&~ENUM SETA &~ENUM+1
&CNT SETA &CNT+1
AIF &CNT<=C:&LIST,^C
MEND
MACRO
&LAB SUBR &PARMS
&LAB PHD
LDA MY_DP
TCD
AIF C:&PARMS=0,.F
LCLC &PARM
LCLA &P
LCLA &LEN
LCLA &TOTALLEN
LCLC &C
&P SETA 1
.A
&PARM SETC &PARMS(&P)
&C AMID &PARM,1,1
&PARM AMID &PARM,3,L:&PARM-2
&LEN SETA &C
&PARM EQU &TOTALLEN
&TOTALLEN SETA &TOTALLEN+&C
&P SETA &P+1
AIF &P<=C:&PARMS,^A
AIF &TOTALLEN<>2,.B
LDA 6,S
STA 0
LDA 4,S
STA 6,S
LDA 2,S
STA 4,S
PLA
STA 1,S
MEXIT
.B
AIF &TOTALLEN<>4,.C
LDA 6,S
STA 0
LDA 8,S
STA 2
LDA 4,S
STA 8,S
LDA 2,S
STA 6,S
PLA
STA 3,S
PLA
MEXIT
.C
PHB
PLA
STA R0
PLA
STA R2
PLA
STA R4
AIF (&TOTALLEN/2*2)<>&TOTALLEN,.D
LDX #0
~&SYSCNT PLA
STA 0,X
INX
INX
CPX #&TOTALLEN
BNE ~&SYSCNT
AGO .E
.D
SEP #$20
LDX #0
~&SYSCNT PLA
STA 0,X
INX
CPX #&TOTALLEN
BNE ~&SYSCNT
REP #$20
.E
LDA R4
PHA
LDA R2
PHA
LDA R0
PHA
PLB
.F
MEND
MACRO
&LAB RETURN &VAL
AIF C:&VAL<>0,.A
&LAB PLD
RTL
MEXIT
.A
AIF "&VAL"<>"2",.B
&LAB PLD
TAX
RTL
MEXIT
.B
MNOTE 'Return values not implemented yet.',16
MEND
MACRO
&LAB PASCAL
&LAB TSC
PLD
PLB
TCS
MEND
MACRO
&LAB ASSEMBLY
&LAB PHK
PLB
LDA MY_DP
TCD
MEND
MACRO
&LAB MOVE4 &A,&B
&LAB LDA &A
STA &B
LDA 2+&A
STA 2+&B
MEND
MACRO
&LAB TERR &ERR
&LAB LDA &ERR
PHA
JSL TERMERROR
MEND
MACRO
&LAB LISTERROR &ERR
&LAB LDA 0
PHA
PH2 &ERR
JSL ERROR
PLA
STA 0
MEND
macro
&lab FastFile &DCB
&lab ~setm
jsl $E100A8
dc i2'$010E'
dc i4'&DCB'
~restm
mend
macro
&lab sub &p,&w
&lab anop
lcla &pc
lclc &n
lclc &s
lclc &pr
gbla &disp
gbla &ws
&ws seta &w
&pc seta 1
&disp seta 3+&w
.a
&pr setc &p(&pc)
&s amid &pr,1,1
&n amid &pr,3,l:&pr-2
&n equ &disp
&disp seta &disp+&s
&pc seta &pc+1
aif &pc<=c:&p,^a
tdc
tax
tsc
sec
sbc #&w-1
tcd
dec a
tcs
phx
mend
macro
&lab return
&lab lda &ws
sta &disp-3
lda &ws+1
sta &disp-2
clc
tdc
adc #&disp-4
plx
tcs
txa
tcd
rtl
mend
macro
&lab enum &list,&start
&lab anop
aif c:&~enum,.a
gbla &~enum
.a
aif c:&start=0,.b
&~enum seta &start
.b
lcla &cnt
&cnt seta 1
.c
&list(&cnt) equ &~enum
&~enum seta &~enum+1
&cnt seta &cnt+1
aif &cnt<=c:&list,^c
mend
macro
&lab terr &err
&lab lda &err
brl termerror
mend
macro
&lab move4 &a,&b
&lab lda &a
sta &b
lda 2+&a
sta 2+&b
mend