-
Notifications
You must be signed in to change notification settings - Fork 84
/
umacro
129 lines (119 loc) · 1.86 KB
/
umacro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.PAGE 'UMACRO'
; MACRO DEFINITION HANDLING
; WRITTEN BY HAROLD S. STONE, THE INTERFACTOR, INC.
;
; THE STACK FRAME IS: + 0 = POINTER TO PRIOR FRAME
; + 2 = MACRO TABLE ENTRY PTR
; + 4 = CURRENT CHAR POINTER
; + 4 = LAST SOURCE (SFILE)
PSHMAC INC LEVEL ;BUMP THE MACRO LEVEL
LDA LEVEL
CMP #$09
BCC PSHM1 ;LEVEL OK
LDA #$28 ;TOO MANY LEVELS
JMP BMM3
PSHM1 LDA MCSTPT
STA NEWMAC
LDA MCSTPT+1
STA NEWMAC+1 ;SAVE STACK POINTER
LDA STKFRM
JSR PUSH
LDA STKFRM+1
JSR PUSH
LDA MACENT
JSR PUSH
LDA MACENT+1
JSR PUSH
LDA CURPNT
JSR PUSH
LDA CURPNT+1
JSR PUSH
LDA SFILE
JSR PUSH
LDA NEWMAC ;SET THE FRAME POINTER
STA STKFRM
LDA NEWMAC+1
STA STKFRM+1
RTS
POPMAC DEC LEVEL
BPL POPM1
LDA #$24 ;STACK UNDERFLOW
JMP BMM3
POPM1 LDA STKFRM
STA T0
STA MCSTPT ;RESET THE STACK POINTER
LDA STKFRM+1
STA T0+1
STA MCSTPT+1
LDY #0
LDA (T0),Y
STA STKFRM
INY
LDA (T0),Y
STA STKFRM+1
INY
LDA (T0),Y
STA MACENT
INY
LDA (T0),Y
STA MACENT+1
INY
LDA (T0),Y
STA CURPNT
INY
LDA (T0),Y
STA CURPNT+1
INY
LDA (T0),Y
STA SFILE
SEC
LDA STKFRM
SBC #<MACTAB
LDA STKFRM+1
SBC #>MACTAB
BCS POP1
LDA #$24 ;TABLE UNDERFLOW
POP0 JMP BMM3
POP1 SEC
LDA #<MCTBND
SBC STKFRM
LDA #>MCTBND
SBC STKFRM+1
BCC POP2
LDA #$23 ;TABLE OVERFLOW
BNE POP0
POP2 RTS
SETMAC LDA TMPMAC+1 ;RECOVER MACRO TABLE ENTRY
STA MACENT+1
TAX
LDA TMPMAC
STA MACENT
CLC
ADC #26 ;OFFSET TO TEXT IN TABLE
STA CURPNT
TXA
ADC #0 ;CARRY INTO HIGH BYTE
STA CURPNT+1
LDA SFILE
ORA #FRMMAC ;MARK IT FROM MACRO
STA SFILE
RTS
LABPRC LDA ISYM+1
CMP #$20 ;COULD BE A RESERVED LABEL
BNE LAB2
LDA ISYM
CMP #'A'
BEQ LAB1
CMP #'X'
BEQ LAB1
CMP #'Y'
BEQ LAB1
CMP #'S'
BEQ LAB1
CMP #'P'
BNE LAB2
LAB1 LDA #$20
LDY #3
JMP LTS1
LAB2 RTS
.END