-
Notifications
You must be signed in to change notification settings - Fork 1
/
syntax.asm
196 lines (163 loc) · 4.63 KB
/
syntax.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
;
; Slowdos Source Code
;
;
; $Id: syntax.asm,v 1.1 2003/06/15 20:26:27 dom Exp $
; $Author: dom $
; $Date: 2003/06/15 20:26:27 $
;
; Routines concerned with syntax and interfacing with ROM3
MODULE syntax
INCLUDE "slowdos.def"
EXTERN rom3 ; We need this!
EXTERN errorn
EXTERN synexe
PUBLIC cksemi
PUBLIC getdrv
PUBLIC getdrv1
PUBLIC getdrv2
PUBLIC gdrive
PUBLIC chadd
PUBLIC error_nonsense
PUBLIC error_filename
PUBLIC ckend
PUBLIC ckenqu
PUBLIC syntax
PUBLIC getnum
PUBLIC usezer
PUBLIC rout24
PUBLIC rout32
PUBLIC readbyte
PUBLIC e32_1n
PUBLIC expt1n
PUBLIC exptex
; Check to ensure that we have ";" or a "," before a filename variable
; Entry: a = current character
; Exit: if we exit then it's okay
cksemi: cp ','
jp z,rout32
cp ';'
jp z,rout32
cp '"'
ret z
jp error_nonsense
; Various entry points dependent on whether we already have the
; character in a or not
getdrv: call rout32 ; Get the next characte
getdrv1: and 223 ; Enforce upper case
cp 'P' ; If no 'P' then nonsense in BASIC
jr nz,error_nonsense
getdrv2: call rout32 ; Now get the drive letter
; Check the drive specifier
; Entry: a = current character
; Exit: a = next character
gdrive: cp '*' ; If a * then skip over getting drive number
jr z,chadd
call expt1n ; We expect one number
call rout24 ; Skip to next valid character
call syntax ; If in syntax mode, return now
ret z
push af ; Save current character
call getnum ; Get the number off stack int bc
ld a,b ; Has to be < 256
and a
jr nz,error_baddrive
ld a,c ; Has to be < 3
cp 3
jr nc,error_baddrive
and a ; Can't be 0
jr z,error_baddrive
ld (curdrv),a ; Save the current drive
pop af
ret
chadd: call rom3 ; Skip to next printable character
defw $74 ;chadd
ret
; Various errors
error_baddrive:
call errorn
defb 36 ;invalid device
error_nonsense:
call errorn
defb 11
error_filename:
call errorn
defb 33
;Check for end of line & also for running in syntax mode
ckend: call rout24
call ckenqu
jr nz,error_nonsense ;Not end of statement, call nonsense in basic
ld (iy+0),255 ;No error
set 7,(iy+1)
call syntax ;Checks if we're doing syntax
ret nz ;We're not, so execute the command
res 7,(iy+1)
pop bc
jp synexe ;Carry on syntax checking
; Checks for end of statement
; Entry: a = character to check
; Exit: z = end of statement/ nz = not end of statement
ckenqu: cp 13
ret z
cp 58
ret
; Check if we're in syntax mode
; Entry: none
; Exit: z / nz dependent on mode
syntax: bit 7,(iy+48)
ret
; Stack a 0 on the number stack if not in syntax mode
; Entry: none
; Exit: none
usezer: call syntax
ret z
ld bc,0
call rom3
defw 11563
ret
; Get number from calculator stack into bc
; Entry: none
; Exit: bc = 16 bit number
getnum: call rom3
defw fnint2
ret
; Pick up next character
; Entry: none
; Exit: a = next char
rout32: call rom3
defw 32
ret
; Pick up current character/next if nor printable
; Entry: none
; Exit: a = next char
rout24: call rom3
defw 24
ret
; Pick up a byte from the normal BASIC memory area
; Entry: hl = address
; Exit: hl = address
; a = value at that address
readbyte: call rom3
defw 123
ret
; We expect to get a number next in the input stream
; Entry: none
; Exit: none
e32_1n: call rout32 ; Get next char if needed
expt1n: call rom3 ; Parse expression
defw 9467
bit 6,(iy+1) ; Check for numeric result
ret nz ; It was
pop bc
call errorn
defb 11
; We expect a string to be next
; Entry: none
; Exit: none
exptex: call rom3 ; Parse expression
defw 9467
bit 6,(iy+1) ; Check for string result
ret z ; It was
pop bc
call errorn
defb 11