-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprism.asm
254 lines (236 loc) · 4.86 KB
/
prism.asm
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
mcopy prism.macros
****************************************************************
*
* InstallIntercepts - install shell intercepts
* RemoveIntercepts - remove shell intercepts
*
****************************************************************
*
InstallIntercepts private
ChangeVector cv0
ChangeVector cv1
ChangeVector cv2
rtl
cv0 dc i'0,0'
dc a4'EditIntercept'
cv0o ds 4
cv1 dc i'0,1'
dc a4'cns'
cv1o ds 4
cv2 dc i'0,2'
dc a4'Abort'
cv2o ds 4
RemoveIntercepts entry
move4 cv0o,cw0o
move4 cv1o,cw1o
move4 cv2o,cw2o
ChangeVector cw0
ChangeVector cw1
ChangeVector cw2
rtl
cw0 dc i'0,0'
cw0o ds 8
cw1 dc i'0,1'
cw1o ds 8
cw2 dc i'0,2'
cw2o ds 8
;
; Cns - ignore console characters
;
Cns php
long I,M
plx
ply
pla
phy
phx
plp
rtl
end
****************************************************************
*
* SystemError - Handle run time errors
*
* Inputs:
* 4,S - error number
*
****************************************************************
*
SystemError start
longa on
longi on
errorNumber equ 4 error number
lda errorNumber,S
pha
ph4 #msg
_SysFailMgr
msg dw 'System error: '
end
****************************************************************
*
* DPArea - our DP/stack segment area
*
****************************************************************
*
DPArea start DPSegment
kind $12
ds 17*256
end
****************************************************************
*
* ~_BWCommon - Global data for the compiler
*
****************************************************************
*
~_BWCommon start
;
; Misc. variables
;
~CommandLine entry address of the shell command line
ds 4
~EOFInput entry end of file flag for input
ds 2
~EOLNInput entry end of line flag for input
ds 2
ErrorOutput entry error output file variable
dc a4'~ErrorOutputChar'
~ErrorOutputChar entry error output file buffer
ds 2
Input entry standard input file variable
dc a4'~InputChar'
~InputChar entry standard input file buffer
ds 2
~MinStack entry lowest reserved bank zero address
ds 2
Output entry standard output file variable
dc a4'~OutputChar'
~OutputChar entry standard output file buffer
ds 2
~RealVal entry last real value returned by a function
ds 10
~SANEStarted entry did we start SANE?
dc i'0'
~ThisFile entry pointer to current file variable
ds 4
~ToolError entry last error in a tool call (Pascal)
ds 2
~User_ID entry user ID (Pascal, libraries)
ds 2
ioFlag entry input output flag
ds 2
~StringList entry string buffer list
ds 4
;
; Traceback variables
;
~ProcList entry traceback list head
ds 4
~LineNumber entry current line number
ds 2
~ProcName entry current procedure name
ds 32
;
; Universal quit code
;
~Quit entry
jsl ShutDown
quit qt_dcb return to the calling shell
qt_dcb anop quit DCB
dc a4'qt_flags'
qt_flags dc i'0'
;
; ShutDown - common shutdown code for RTL and QUIT exits
;
~ShutDown entry
ShutDown pha save the return code
lda >~SANEStarted if we started SANE then
beq qt1
_SANEShutDown shut it down
stz ~SANEStarted clear the flag (for restarts)
qt1 jsl ~MM_Init zero the memory manager
ph2 >~User_ID dispose of any remaining memory
_DisposeAll allocated by the memory manager
pla restore the return code
rts
end
****************************************************************
*
* ~_BWStartUp - Compiler initialization
*
* Inputs:
* A - user ID
* X-Y - address of the command line
* D - lowest reserved bank zero address
* 4,S - amount of stack space to reserve
*
* Outputs:
* ~User_ID - user ID
* ~CommandLine - address of the command line
* ~MinStack - lowest reserved bank zero address
* ~InputChar - set to ' '
*
****************************************************************
*
~_BWStartUp start
;
; Set up initial registers
;
phk set the data bank register
plb
ora #$0100 use local user ID
sta ~User_ID save the user ID for memory manager use
case on
lda ownerid
beq lb1
dc i1'$8F' (sta long)
ownerid dc s3'_ownerid'
lb1 anop
case off
stx ~CommandLine+2 save the address of the command line
sty ~CommandLine
;
; Set stack values, initialize SANE and traceback code
;
lda #DPArea set up minStack
sta ~MinStack
pha if SANE has not been started then
_SANEStatus
pla
bne sn1
lda ~MinStack get some bank zero memory for SANE
pha
clc
adc #$0100
sta ~MinStack
_SANEStartUp initialize SANE
lda #1 set the SANE startup flag
sta ~SANEStarted
sn1 lda #' ' reset(input)
sta ~InputChar
stz ~EOLNInput
stz ~EOFInput
stz ~LineNumber initialize traceback info
stz ~ProcName
stz ~ProcList
stz ~ProcList+2
stz ~StringList initialize the string buffer list
stz ~StringList+2
stz ~thisFile initialize file lists
stz ~thisFile+2
rtl
end
****************************************************************
*
* ~Halt - Stop execution and return with error code
*
* Inputs:
* error - error code
*
****************************************************************
*
~Halt start
using ~_IOCommon
error equ 4
lda error,S
brl ~Quit
end