OpenCores
URL https://opencores.org/ocsvn/rtf68ksys/rtf68ksys/trunk

Subversion Repositories rtf68ksys

[/] [rtf68ksys/] [trunk/] [Software/] [BOOTROM.lst] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 robfinch
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 1
2
BOOTROM.x68
3
 
4
                                             ;------------------------------------------------------------------------------
5
                                             ; 0x00000 to 0x00007       boot vector
6
                                             ; 0x00008 to 0x003ff       interrupt vectors
7
                                             ; 0x00400 to 0x                    system variables
8
                                             ; 0x10000 to 0x1ffff       thread control blocks
9
                                             ; 0x20000 to 0x3ffff       bitmap memory, page 1
10
                                             ; 0x40000 to 0x5ffff       bitmap memory, page 2
11
                                             ; 0x60000 to 0x7ffff       initial thread stacks
12
                                             ;------------------------------------------------------------------------------
13
                                             INACTIVE   EQU             0x0000
14
                                             ACTIVE             EQU             0x0001
15
 
16
                                             CR EQU     0x0D            ;ASCII equates
17
                                             LF EQU     0x0A
18
                                             TAB        EQU     0x09
19
                                             CTRLC      EQU     0x03
20
                                             CTRLH      EQU     0x08
21
                                             CTRLS      EQU     0x13
22
                                             CTRLX      EQU     0x18
23
 
24
                                             Milliseconds       EQU             0x400
25
                                             Lastloc                    EQU             0x404
26
                                             ScreenPtr  EQU             0x410
27
                                             ScreenColor        EQU             0x414
28
                                             CursorRow  EQU             0x418
29
                                             CursorCol  EQU             0x41A
30
                                             KeybdEcho  EQU             0x41C
31
                                             PenColor   EQU             0x420
32
                                             PenColor8  EQU             0x424
33
                                             FillColor  EQU             0x428
34
                                             FillColor8 EQU             0x42C
35
                                             DrawPos            EQU             0x430
36
                                             KeybdBuffer        EQU             0x440
37
                                             KeybdHead  EQU             0x450
38
                                             KeybdTail  EQU             0x452
39
                                             Keybuf             EQU             0x460
40
                                             memend             EQU             0x500
41
                                             scratch1   EQU             0x700
42
                                             S19StartAddress    EQU             0x800
43
                                             KEYBD              EQU             0xFFDC0000
44
                                             TEXTSCR            EQU             0xFFD00000
45
                                             COLORSCR   EQU             0xFFD10000
46
                                             PSG                        EQU             0xFFD40000
47
                                             SPRITERAM  EQU             0xFFD80000
48
                                             PSG_FREQUENCY0     EQU             0xFFD40000
49
                                             PSG_PULSEWIDTH0    EQU             0xFFD40002
50
                                             PSG_CTRL0          EQU             0xFFD40004
51
                                             PSG_ATTACK0                EQU             0xFFD40008
52
                                             PSG_DECAY0         EQU             0xFFD4000A
53
                                             PSG_SUSTAIN0       EQU             0xFFD4000C
54
                                             PSG_RELEASE0       EQU             0xFFD4000E
55
                                             PSG_MASTVOL                EQU             0xFFD40040
56
                                             BITMAPSCR  EQU             0x00020000
57
                                             UART               EQU             0xFFDC0A00
58
                                             UART_LS            EQU             UART+1
59
                                             UART_CTRL  EQU             UART+7
60
                                             RANDOM             EQU             0xFFDC0C00
61
                                             TEXTCTRL   EQU             0xFFDA0000
62
                                             TEXT_COLS  EQU             0xFFDA0000
63
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 2
64
BOOTROM.x68
65
                                             TEXT_ROWS  EQU             0xFFDA0002
66
                                             TEXT_CURPOS        EQU             0xFFDA0016
67
                                             STACK              EQU             0xFFFE07FC
68
                                             TMPPMOD            EQU             0xFFDC0300
69
                                             GRAPHICS   EQU             0xFFDAE000
70
                                             G_DRAWLINE EQU             0x0002
71
 
72
                                             ; AOS System Calls
73
 
74
                                             AOS_TASK_ON                EQU             0x01
75
                                             AOS_TASK_OFF       EQU             0x42
76
                                             AOS_TASK_STAT      EQU             0x03
77
                                             AOS_TASK_ID                EQU             0x44
78
                                             AOS_POSTBOX                EQU             0x48
79
                                             AOS_SEND           EQU             0x09
80
                                             AOS_SENDX          EQU             0x0B
81
                                             AOS_RECEIVE                EQU             0x4A
82
                                             AOS_TIME_SET       EQU             0x10
83
                                             AOS_TIME_READ      EQU             0x11
84
                                             AOS_TICK           EQU             0x12
85
                                             AOS_DELAY          EQU             0x53
86
                                             AOS_PUTCHAR                EQU             0x18
87
                                             AOS_GETCHAR                EQU             0x19
88
                                             AOS_KEYSTAT                EQU             0x1A
89
                                             AOS_TRANSTAT       EQU             0x1B
90
                                             AOS_GT_CPT         EQU             0x20
91
                                             AOS_G_STK          EQU             0xA1
92
                                             AOS_RES_TASK       EQU             0x22
93
 
94
                                             EMPTY   EQU     0
95
                                             LETTE   EQU     2     ;          TASK MAILBOXES HOLD ONLY 2 LETTERS;
96
                                             LETTERS EQU     8     ;          OUR MAILBOX HOLDS 8 LETTERS;
97
 
98
                                             ;*
99
                                             ;*============== BREAKPOINT EQUATES:
100
                                             ;*
101
                                             MSIZE   EQU     8      ;         SIZE, OR WIDTH OF LETTERS IN MAIL BOX;
102
                                             NUMBPS  EQU     8      ;         EIGHT BREAKPOINTS ARE ALLOWED;
103
                                             ;*
104
 
105
 
106
                                             ;*
107
                                             ;*  Now set up stack frames for dummy tasks.  Each task must have mail box.
108
                                             ;*
109
                                                        BSS                                     ; suppress output
110
                                                     ORG     0
111
    106 00000000                             A5L     dc.l       0
112
                                             MFRAM      EQU     $
113
    108 00000004                                     dc.l       0
114
                                             STATZ      EQU     $-MFRAM
115
    110 00000008                                     dc.w    2                  ;   Reserve space for mailbox flag;
116
                                             MLFLAG     EQU     $-MFRAM
117
    112 0000000A                                     dc.w    2           ;   Reserve space for number of letters;
118
                                             MXLTRS     EQU     $-MFRAM
119
    114 0000000C                                     fill.l  4,0xffffffff       ;  _LONG*4         LEAVE ROOM FOR 2 LETTERS;
120
                                             PSIZ       EQU     $-MFRAM
121
 
122
                                                        CODE
123
                                             ;
124
                                             ;                       ---------------------
125
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 3
126
BOOTROM.x68
127
                                             ;               $XX00  |  V    L    I    D   |
128
                                             ;                      |---------------------|
129
                                             ;               $XX04  |      RAMPTR         |
130
                                             ;                      |---------------------|
131
                                             ;               $XX08  |      RAMSIZE        |
132
                                             ;                      |---------------------|
133
                                             ;               $XX0C  |      AUXRST         |
134
                                             ;                      |---------------------|
135
                                             ;               $XX10  |      AUXDSP         |
136
                                             ;                      |---------------------|
137
                                             ;               $XX14  |      SERVPTR        |
138
                                             ;                      |---------------------|
139
                                             ;               $XX18  |      DATAPTR        |
140
                                             ;                      |---------------------|
141
                                             ;               $XX1C  |      NTASKS         |
142
                                             ;                       ---------------------
143
                                             ;
144
 
145
                                                org     0xFFFF1000
146
 
147
    140 FFFF1000                             configTable:
148
    141 FFFF1000 56 4C 49 44                    dc.b    "VLID"
149
    142 FFFF1004 00100000                       dc.l    0x0100000       ; first megabyte
150
    143 FFFF1008 00200000                       dc.l    0x0200000       ; 2 megabytes available
151
    144 FFFF100C 00000000                       dc.l    0x0000          ; auxillary reset code pointer
152
    145 FFFF1010 00000000                       dc.l    0x0000          ; AUXDSP auxillary dispatch routine pointer
153
    146 FFFF1014 FFFF1074                       dc.l    SERVEC          ; SERVPTR
154
    147 FFFF1018 FFFF1084                       dc.l    SSTACK          ; DATAPTR
155
    148 FFFF101C 00000003                       dc.l    0x00000003      ; NTASKS
156
 
157
                                             ; Static task control block
158
                                             ;
159
                                             ;                       _______________
160
                                             ;                      |   |   |   |   |
161
                                             ;              $XX20   | STARTING ADR  | --> PCTR
162
                                             ;                      |___|___|___|___|_______________
163
                                             ;                      |   |   |   |   |   |   |   |   |
164
                                             ;              $XX24   | T | A | S | K | N | A | M | E |
165
                                             ;                      |___|___|___|___|___|___|___|___|
166
                                             ;                      |   |   |   |   |
167
                                             ;              $XX2C   | S T K S I Z E |
168
                                             ;                      |___|___|___|___|
169
                                             ;                      |   |   |   |   |
170
                                             ;              $XX30   | EDC TBLE PNTR |
171
                                             ;                      |___|___|___|___|
172
                                             ;                      |   |   |   |   |
173
                                             ;              $XX34   |  U S R P A R  |
174
                                             ;                      |___|___|___|___|
175
                                             ;                      |   |   |
176
                                             ;              $XX38   | STATE |
177
                                             ;                      |___|___|
178
                                             ;                      |   |   |
179
                                             ;              $XX3A   | TSKNO |
180
                                             ;                      |___|___|
181
                                             ;
182
                                             ;
183
 
184
    177 FFFF1020 FFFF1A5E                       dc.l    StartMon
185
    178 FFFF1024 4D 4F 4E 49 54 4F 52 20        dc.b    "MONITOR "
186
 
187
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 4
188
BOOTROM.x68
189
    180 FFFF102C 00000800                       dc.l    0x00000800      ; 2k stack
190
    181 FFFF1030 00000000                       dc.l    0x00000000      ; EDC table pointer
191
    182 FFFF1034 00000000                       dc.l    0x00000000      ; user parameter
192
    183 FFFF1038 0000                           dc.w    INACTIVE
193
    184 FFFF103A 0001                           dc.w    0x0001          ; task #1
194
 
195
    186 FFFF103C FFFF2400                       dc.l    START           ; starting address
196
    187 FFFF1040 54 49 4E 59 20 42 41 53        dc.b    "TINY BAS"      ; Tiny basic
197
 
198
    189 FFFF1048 00000800                       dc.l    0x00000800      ; 2k stack required
199
    190 FFFF104C 00000000                       dc.l    0x00000000      ; EDC table pointer
200
    191 FFFF1050 00000000                       dc.l    0x00000000      ; user parameter
201
    192 FFFF1054 0001                           dc.w    ACTIVE
202
    193 FFFF1056 0002                           dc.w    0x0002          ; task #2
203
 
204
    195 FFFF1058 FFFF12EC                       dc.l    IdleTask
205
    196 FFFF105C 49 44 4C 45 54 41 53 4B        dc.b    "IDLETASK"
206
 
207
    198 FFFF1064 00000400                       dc.l    0x00000400      ; 1k stack
208
    199 FFFF1068 00000000                       dc.l    0x00000000
209
    200 FFFF106C 00000000                       dc.l    0x00000000
210
    201 FFFF1070 0001                           dc.w    ACTIVE
211
    202 FFFF1072 0003                           dc.w    0x0003
212
 
213
 
214
                                             ;*
215
                                             ;*============== SERVEC:
216
                                             ;*
217
                                             ;*  The service vector locations will be 16 vectors (eventually).  The
218
                                             ;*  first 8 are reserved for in_character, out_character, etc.  The last
219
                                             ;*  eight are user defined service routines.
220
                                             ;*
221
    212 FFFF1074 FFFF16B0                    SERVEC     dc.l    GET
222
    213 FFFF1078 FFFF16D4                               dc.l    PUT
223
    214 FFFF107C FFFF1680                               dc.l    KeyStatus
224
    215 FFFF1080 FFFF169A                               dc.l    TranStatus
225
 
226
    217 FFFF1084 00000200                    SSTACK     dc.l    0x200   ; 512 bytes system stack
227
 
228
                                             ;------------------------------------------------------------------------------
229
                                             ;------------------------------------------------------------------------------
230
                                             ; Clear all memory
231
 
232
                                             ; RAM test
233
                                                even
234
 
235
                                             ; We clear the screen to give a visual indication that the system
236
                                             ; is working at all.
237
                                             ;
238
    229 FFFF1088 FF FF FF FF FF FF FF FF        org     0xFFFF1100
239
    230 FFFF1090 FF FF FF FF FF FF FF FF
240
    231 FFFF1098 FF FF FF FF FF FF FF FF
241
    232 FFFF10A0 FF FF FF FF FF FF FF FF
242
    233 FFFF10A8 FF FF FF FF FF FF FF FF
243
    234 FFFF10B0 FF FF FF FF FF FF FF FF
244
    235 FFFF10B8 FF FF FF FF FF FF FF FF
245
    236 FFFF10C0 FF FF FF FF FF FF FF FF
246
    237 FFFF10C8 FF FF FF FF FF FF FF FF
247
    238 FFFF10D0 FF FF FF FF FF FF FF FF
248
    239 FFFF10D8 FF FF FF FF FF FF FF FF
249
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 5
250
BOOTROM.x68
251
    240 FFFF10E0 FF FF FF FF FF FF FF FF
252
    241 FFFF10E8 FF FF FF FF FF FF FF FF
253
    242 FFFF10F0 FF FF FF FF FF FF FF FF
254
    243 FFFF10F8 FF FF FF FF FF FF FF FF
255
 
256
    245 FFFF1100                             main:
257
    246 FFFF1100 31FC 00CE 0414                 move.w  #0xCE,ScreenColor       ; blue on blue
258
    247 FFFF1106 11FC 0001 041C                 move.b  #1,KeybdEcho            ; turn on keyboard echo
259
    248 FFFF110C 4EB9 FFFF 18E8                 jsr             ClearScreen
260
    249 FFFF1112 4278 0418                      clr.w   CursorRow
261
    250 FFFF1116 4278 041A                      clr.w   CursorCol
262
    251 FFFF111A 43F9 FFFF 1238                 lea             MSGRAM,a1
263
    252 FFFF1120 4EB9 FFFF 1858                 jsr             DisplayString
264
 
265
    254 FFFF1126 47F9 FFFF 1132                  lea    main5,a3      ; get return address for ram test
266
    255 FFFF112C 4EF9 FFFF 1F52                  jmp    ramtest       ; Call ram test routine. (Called this way in case there's no RAM).
267
    256 FFFF1132                             main5:
268
                                                ; setup user stack pointer
269
                                                ;
270
    259 FFFF1132 2079 FFFF 2420                 move.l  ENDMEM,a0
271
    260 FFFF1138 4E60                           move.l  a0,usp
272
 
273
                                                ; reset the screen stuff
274
                                                ;
275
    264 FFFF113A 31FC 00CE 0414                 move.w  #0xCE,ScreenColor       ; blue on blue
276
    265 FFFF1140 11FC 0001 041C                 move.b  #1,KeybdEcho            ; turn on keyboard echo
277
    266 FFFF1146 4278 0418                      clr.w   CursorRow               ; reset after RAMTEST
278
    267 FFFF114A 4278 041A                      clr.w   CursorCol
279
 
280
                                                ; randomize sprite memory
281
    270 FFFF114E 223C 0000 8000                 move.l  #32768,d1
282
    271 FFFF1154 41F9 FFD8 0000                 lea             SPRITERAM,a0
283
    272 FFFF115A                             main6:
284
    273 FFFF115A 2039 FFDC 0C00                 move.l  RANDOM,d0
285
    274 FFFF1160 30C0                           move.w  d0,(a0)+
286
    275 FFFF1162 5381                           subi.l  #1,d1
287
    276 FFFF1164 66F4                           bne             main6
288
 
289
                                                ; setup vector table
290
                                                ;
291
    280 FFFF1166 41F9 FFFF 2022                 lea             BusError,a0
292
    281 FFFF116C 21C8 0008                      move.l  a0,0x008                ; set bus error vector
293
    282 FFFF1170 41F9 FFFF 200C                 lea             AddressError,a0
294
    283 FFFF1176 21C8 000C                      move.l  a0,0x00C                ; set address error vector
295
    284 FFFF117A 41F9 FFFF 2038                 lea             IllegalInstruction,a0
296
    285 FFFF1180 21C8 0010                      move.l  a0,0x010
297
    286 FFFF1184 41F9 FFFF 1298                 lea             Pulse1000,a0
298
    287 FFFF118A 21C8 0078                      move.l  a0,0x078                ; set autovector 6
299
    288 FFFF118E 41F9 FFFF 1250                 lea             KeybdNMI,a0
300
    289 FFFF1194 21C8 007C                      move.l  a0,0x07C                ; set autovector 7
301
    290 FFFF1198 41F9 FFFF 0800                 lea             0xFFFF0800,a0
302
    291 FFFF119E 21C8 0080                      move.l  a0,0x080                ; trap #0 AOS entry     - task switch
303
    292 FFFF11A2 41F9 FFFF 0400                 lea             0xFFFF0400,a0
304
    293 FFFF11A8 21C8 0084                      move.l  a0,0x084                ; trap #1 AOS entry - AOS system call dispatcher
305
    294 FFFF11AC 41F9 FFFF 0C00                 lea             0xFFFF0C00,a0
306
    295 FFFF11B2 21C8 0088                      move.l  a0,0x088                ; trap #2 AOS entry - dispatcher
307
    296 FFFF11B6 41F9 FFFF 1312                 lea             TRAP15,a0
308
    297 FFFF11BC 21C8 00BC                      move.l  a0,0x0BC                ; set trap 15 vector
309
 
310
    299 FFFF11C0 42B8 0400                      clr.l   Milliseconds
311
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 6
312
BOOTROM.x68
313
    300 FFFF11C4 027C F000                      andi    #0xF000,sr              ; enable interrupts, stay in supervisor mode
314
 
315
    302 FFFF11C8 700E                           moveq   #14,d0
316
    303 FFFF11CA 43F9 FFFF 1241                 lea             MSGBOOTING,a1   ; Display the boot message
317
    304 FFFF11D0 4E4F                           trap    #15
318
 
319
                                             ;  jsr             Beep
320
 
321
                                                ; test keyboard, wait for 'x' to be pressed
322
    309 FFFF11D2                             j7:
323
                                             ;  jmp             0xFFFF0000              ; start AOS
324
    311 FFFF11D2 4EF9 FFFF 2400                 jmp             START
325
 
326
    313 FFFF11D8 7005                           moveq   #5,d0
327
    314 FFFF11DA 4E4F                           trap    #15
328
    315 FFFF11DC 0C01 0078                      cmpi.b  #'x',d1
329
    316 FFFF11E0 66F0                           bne             j7
330
 
331
                                                ; Clear bitmap memory
332
    319 FFFF11E2 203C 0004 0000                 move.l  #0x40000,d0
333
    320 FFFF11E8 41F9 0002 0000                 lea             BITMAPSCR,a0
334
    321 FFFF11EE 343C 1234                      move.w  #0x1234,d2
335
    322 FFFF11F2                             j8:
336
    323 FFFF11F2 30C2                           move.w  d2,(a0)+
337
    324 FFFF11F4 5380                           subi.l  #1,d0                   ; can't use dbeq (>count ffff)
338
    325 FFFF11F6 66FA                           bne             j8
339
 
340
    327 FFFF11F8 4EF9 FFFF 2400                 jmp             START                   ; goto tiny basic
341
 
342
 
343
    330 FFFF11FE 4239 FFDC 0A07                 clr.b   UART_CTRL               ; turn off hardware flow control
344
    331 FFFF1204                             j10:
345
    332 FFFF1204 45F9 FFFF 0000                 lea             0xFFFF0000,a2   ; start of bootstrap ROM
346
    333 FFFF120A                             j9:
347
    334 FFFF120A 121A                           move.b  (a2)+,d1
348
    335 FFFF120C                             j6:
349
    336 FFFF120C 1039 FFDC 0A01                 move.b  UART_LS,d0              ; check line status
350
    337 FFFF1212 0800 0005                      btst    #5,d0                   ; can we transmit more ?
351
    338 FFFF1216 67F4                           beq             j6                              ; no, go back
352
    339 FFFF1218 13C1 FFDC 0A00                 move.b  d1,UART
353
    340 FFFF121E B5FC FFFF 0100                 cmpa.l  #0xFFFF0100,a2
354
    341 FFFF1224 65E4                           blo             j9
355
    342 FFFF1226 60DC                           bra             j10
356
    343 FFFF1228                             j2:
357
    344 FFFF1228 1039 FFDD 0000                 move.b  0xFFDD0000,d0
358
    345 FFFF122E 6AF8                           bpl             j2
359
    346 FFFF1230 2079 FFDD 0004                 move.l  0xFFDD0004,a0
360
    347 FFFF1236 4ED0                           jmp             (a0)
361
 
362
    349 FFFF1238                             MSGRAM:
363
    350 FFFF1238 52 41 4D 20 54 45 53 54        dc.b    "RAM TEST",0
364
    351 FFFF1240 00
365
    352 FFFF1241                             MSGBOOTING:
366
    353 FFFF1241 42 4F 4F 54 49 4E 47 2E        dc.b    "BOOTING....",0
367
    354 FFFF1249 2E 2E 2E 00
368
 
369
    356 FFFF124D FF FF FF                       align   16
370
 
371
                                             ;------------------------------------------------------------------------------
372
                                             ; Pressing Ctl-Alt-Del on the keyboard causes a keyboard NMI, the highest
373
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 7
374
BOOTROM.x68
375
                                             ; priority interrupt in the system. This should be almost the same as a reset.
376
                                             ;------------------------------------------------------------------------------
377
                                             ;
378
    363 FFFF1250                             KeybdNMI:
379
    364 FFFF1250 4EF9 FFFF 1100                 jmp             main
380
    365 FFFF1256 4E73                           rte
381
 
382
                                             ;------------------------------------------------------------------------------
383
                                             ; Unimplemented yet.
384
                                             ;
385
                                             ; Normal keyboard interrupt, the lowest priority interrupt in the system.
386
                                             ; Grab the character from the keyboard device and store it in a buffer.
387
                                             ;------------------------------------------------------------------------------
388
                                             ;
389
    374 FFFF1258                             KeybdIRQ:
390
    375 FFFF1258 48E7 C080                      movem.l a0/d0/d1,-(a7)
391
    376 FFFF125C 3238 0450                      move.w  KeybdHead,d1
392
    377 FFFF1260 0241 000F                      andi.w  #0xf,d1                                 ; D1 = index into buffer
393
    378 FFFF1264 41F8 0440                      lea             KeybdBuffer,a0
394
    379 FFFF1268                             KeybdIRQa:
395
    380 FFFF1268 3039 FFDC 0000                 move.w  KEYBD,d0                                ; get keyboard character
396
    381 FFFF126E 4279 FFDC 0002                 clr.w   KEYBD+2                                 ; clear keyboard strobe
397
    382 FFFF1274 1180 1000                      move.b  d0,(a0,d1.w)                    ; store character in buffer
398
    383 FFFF1278 5241                           addi.w  #1,d1                                   ; increment head index
399
    384 FFFF127A 0241 000F                      andi.w  #0xF,d1
400
    385 FFFF127E 31C1 0450                      move.w  d1,KeybdHead
401
    386 FFFF1282                             KeybdIRQb:
402
    387 FFFF1282 B278 0452                      cmp.w   KeybdTail,d1                    ; check to see if we've collided
403
    388 FFFF1286 660A                           bne             KeybdIRQc                               ; with the tail
404
    389 FFFF1288 5241                           addi.w  #1,d1                                   ; if so, increment the tail index
405
    390 FFFF128A 0241 000F                      andi.w  #0xf,d1                                 ; the oldest character will be lost
406
    391 FFFF128E 31C1 0452                      move.w  d1,KeybdTail
407
    392 FFFF1292                             KeybdIRQc:
408
    393 FFFF1292 4CDF 0103                      movem.l (a7)+,a0/d0/d1
409
    394 FFFF1296 4E73                           rte
410
 
411
                                             ;------------------------------------------------------------------------------
412
                                             ; 1000 Hz interrupt
413
                                             ; - takes care of "flashing" the cursor
414
                                             ;------------------------------------------------------------------------------
415
                                             ;
416
    401 FFFF1298                             Pulse1000:
417
    402 FFFF1298 2F00                           move.l  d0,-(a7)
418
    403 FFFF129A 52B8 0400                      add.l   #1,Milliseconds
419
    404 FFFF129E 5279 FFD0 0066                 add.w   #1,TEXTSCR+102
420
    405 FFFF12A4 4A39 FFFF 0000                 tst.b   0xFFFF0000              ; clear interrupt
421
    406 FFFF12AA 2038 0400                      move.l  Milliseconds,d0
422
    407 FFFF12AE 0200 007F                      andi.b  #0x7f,d0
423
    408 FFFF12B2 0C00 0040                      cmpi.b  #64,d0
424
    409 FFFF12B6 6604                           bne             p10001
425
    410 FFFF12B8 6100 0006                      bsr             FlashCursor
426
    411 FFFF12BC                             p10001:
427
                                             ;  moveq   #AOS_TICK,d0
428
                                             ;  trap    #1
429
    414 FFFF12BC 201F                           move.l  (a7)+,d0
430
    415 FFFF12BE 4E73                           rte
431
 
432
                                             ;------------------------------------------------------------------------------
433
                                             ; Flash Cursor
434
                                             ;------------------------------------------------------------------------------
435
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 8
436
BOOTROM.x68
437
                                             ;
438
    421 FFFF12C0                             FlashCursor:
439
    422 FFFF12C0 48E7 A0C0                      movem.l a0/a1/d0/d2,-(a7)
440
    423 FFFF12C4 6100 0440                      bsr             CalcScreenLoc
441
    424 FFFF12C8 D1FC 0001 0000                 adda.l  #0x10000,a0
442
                                                ; causes screen colors to flip around
443
    426 FFFF12CE 3010                           move.w  (a0),d0
444
    427 FFFF12D0 E818                           ror.b   #4,d0
445
    428 FFFF12D2 3080                           move.w  d0,(a0)
446
    429 FFFF12D4 B1F8 0404                      cmpa.l  Lastloc,a0
447
    430 FFFF12D8 670C                           beq             flshcrsr1
448
                                                ; restore the screen colors of the previous cursor location
449
    432 FFFF12DA 2278 0404                      move.l  Lastloc,a1
450
    433 FFFF12DE 32B8 0414                      move.w  ScreenColor,(a1)
451
    434 FFFF12E2 21C8 0404                      move.l  a0,Lastloc
452
    435 FFFF12E6                             flshcrsr1:
453
    436 FFFF12E6 4CDF 0305                      movem.l (a7)+,a0/a1/d0/d2
454
    437 FFFF12EA 4E75                           rts
455
 
456
                                             ;------------------------------------------------------------------------------
457
                                             ;------------------------------------------------------------------------------
458
    441 FFFF12EC                             IdleTask:
459
    442 FFFF12EC 4E55 FFE8                      LINK    A5,#-PSIZ       ;RESERVE SPACE ON STACK FOR INPUT COMMAND LINE;
460
    443 FFFF12F0 41ED FFFA                       lea.l   -MLFLAG(A5),A0
461
    444 FFFF12F4 43ED FFFC                      LEA.L   -STATZ(A5),A1
462
    445 FFFF12F8 3B7C 0000 FFFA                 MOVE.W  #EMPTY,-MLFLAG(A5)
463
    446 FFFF12FE 3B7C 0002 FFF8                 MOVE.W  #LETTE,-MXLTRS(A5)      ;SETUP FOR "LETTE" LETTERS (WAS 2);
464
    447 FFFF1304 7048                           MOVE.L  #AOS_POSTBOX,D0
465
    448 FFFF1306 4E41                           TRAP    #1                      ;POST MAILBOX;
466
    449 FFFF1308                             IdleTask1:
467
    450 FFFF1308 5279 FFD0 0064                 add.w   #1,TEXTSCR+100
468
    451 FFFF130E 4E40                           trap    #0
469
    452 FFFF1310 60F6                           bra             IdleTask1
470
 
471
                                             ;------------------------------------------------------------------------------
472
                                             ; TRAP #15 handler
473
                                             ;------------------------------------------------------------------------------
474
                                             ;
475
    458 FFFF1312                             TRAP15:
476
    459 FFFF1312 48E7 8080                      movem.l d0/a0,-(a7)
477
    460 FFFF1316 41F9 FFFF 1330                 lea             T15DispatchTable,a0
478
    461 FFFF131C 0280 0000 00FF                 andi.l  #0x0ff,d0
479
    462 FFFF1322 E580                           asl.l   #2,d0
480
    463 FFFF1324 2070 0000                      move.l  (a0,d0.w),a0
481
    464 FFFF1328 4E90                           jsr             (a0)
482
    465 FFFF132A 4CDF 0101                      movem.l (a7)+,d0/a0
483
    466 FFFF132E 4E73                           rte
484
 
485
    468 FFFF1330                             T15DispatchTable:
486
                                             ; Task 0
487
    470 FFFF1330 FFFF189A                    dc.l       DisplayString0
488
    471 FFFF1334 FFFF187A                    dc.l       DisplayString1
489
    472 FFFF1338 FFFF149C                    dc.l       StubRout
490
    473 FFFF133C FFFF19A0                    dc.l       DisplayNum3
491
    474 FFFF1340 FFFF149C                    dc.l       StubRout
492
    475 FFFF1344 FFFF1658                    dc.l       GetKey
493
    476 FFFF1348 FFFF1732                    dc.l       DisplayChar
494
    477 FFFF134C FFFF16DA                    dc.l       CheckForKey
495
    478 FFFF1350 FFFF149C                    dc.l       StubRout
496
    479 FFFF1354 FFFF149C                    dc.l       StubRout
497
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 9
498
BOOTROM.x68
499
                                             ; Task 10
500
    481 FFFF1358 FFFF149C                    dc.l       StubRout
501
    482 FFFF135C FFFF18A2                    dc.l       Cursor1
502
    483 FFFF1360 FFFF162C                    dc.l       SetKeyboardEcho
503
    484 FFFF1364 FFFF1872                    dc.l       DisplayStringCRLF
504
    485 FFFF1368 FFFF1858                    dc.l       DisplayString
505
    486 FFFF136C FFFF149C                    dc.l       StubRout
506
    487 FFFF1370 FFFF149C                    dc.l       StubRout
507
    488 FFFF1374 FFFF149C                    dc.l       StubRout
508
    489 FFFF1378 FFFF149C                    dc.l       StubRout
509
    490 FFFF137C FFFF149C                    dc.l       StubRout
510
                                             ; Task 20
511
    492 FFFF1380 FFFF198C                    dc.l       DisplayNum20
512
    493 FFFF1384 FFFF149C                    dc.l       StubRout
513
    494 FFFF1388 FFFF149C                    dc.l       StubRout
514
    495 FFFF138C FFFF149C                    dc.l       StubRout
515
    496 FFFF1390 FFFF149C                    dc.l       StubRout
516
    497 FFFF1394 FFFF149C                    dc.l       StubRout
517
    498 FFFF1398 FFFF149C                    dc.l       StubRout
518
    499 FFFF139C FFFF149C                    dc.l       StubRout
519
    500 FFFF13A0 FFFF149C                    dc.l       StubRout
520
    501 FFFF13A4 FFFF149C                    dc.l       StubRout
521
                                             ; Task 30
522
    503 FFFF13A8 FFFF149C                    dc.l       StubRout
523
    504 FFFF13AC FFFF149C                    dc.l       StubRout
524
    505 FFFF13B0 FFFF149C                    dc.l       StubRout
525
    506 FFFF13B4 FFFF149C                    dc.l       StubRout
526
    507 FFFF13B8 FFFF149C                    dc.l       StubRout
527
    508 FFFF13BC FFFF149C                    dc.l       StubRout
528
    509 FFFF13C0 FFFF149C                    dc.l       StubRout
529
    510 FFFF13C4 FFFF149C                    dc.l       StubRout
530
    511 FFFF13C8 FFFF149C                    dc.l       StubRout
531
    512 FFFF13CC FFFF149C                    dc.l       StubRout
532
                                             ; Task 40
533
    514 FFFF13D0 FFFF149C                    dc.l       StubRout
534
    515 FFFF13D4 FFFF149C                    dc.l       StubRout
535
    516 FFFF13D8 FFFF149C                    dc.l       StubRout
536
    517 FFFF13DC FFFF149C                    dc.l       StubRout
537
    518 FFFF13E0 FFFF149C                    dc.l       StubRout
538
    519 FFFF13E4 FFFF149C                    dc.l       StubRout
539
    520 FFFF13E8 FFFF149C                    dc.l       StubRout
540
    521 FFFF13EC FFFF149C                    dc.l       StubRout
541
    522 FFFF13F0 FFFF149C                    dc.l       StubRout
542
    523 FFFF13F4 FFFF149C                    dc.l       StubRout
543
                                             ; Task 50
544
    525 FFFF13F8 FFFF149C                    dc.l       StubRout
545
    526 FFFF13FC FFFF149C                    dc.l       StubRout
546
    527 FFFF1400 FFFF149C                    dc.l       StubRout
547
    528 FFFF1404 FFFF149C                    dc.l       StubRout
548
    529 FFFF1408 FFFF149C                    dc.l       StubRout
549
    530 FFFF140C FFFF149C                    dc.l       StubRout
550
    531 FFFF1410 FFFF149C                    dc.l       StubRout
551
    532 FFFF1414 FFFF149C                    dc.l       StubRout
552
    533 FFFF1418 FFFF149C                    dc.l       StubRout
553
    534 FFFF141C FFFF149C                    dc.l       StubRout
554
                                             ; Task 60
555
    536 FFFF1420 FFFF149C                    dc.l       StubRout
556
    537 FFFF1424 FFFF149C                    dc.l       StubRout
557
    538 FFFF1428 FFFF149C                    dc.l       StubRout
558
    539 FFFF142C FFFF149C                    dc.l       StubRout
559
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 10
560
BOOTROM.x68
561
    540 FFFF1430 FFFF149C                    dc.l       StubRout
562
    541 FFFF1434 FFFF149C                    dc.l       StubRout
563
    542 FFFF1438 FFFF149C                    dc.l       StubRout
564
    543 FFFF143C FFFF149C                    dc.l       StubRout
565
    544 FFFF1440 FFFF149C                    dc.l       StubRout
566
    545 FFFF1444 FFFF149C                    dc.l       StubRout
567
                                             ; Task 70
568
    547 FFFF1448 FFFF149C                    dc.l       StubRout
569
    548 FFFF144C FFFF149C                    dc.l       StubRout
570
    549 FFFF1450 FFFF149C                    dc.l       StubRout
571
    550 FFFF1454 FFFF149C                    dc.l       StubRout
572
    551 FFFF1458 FFFF149C                    dc.l       StubRout
573
    552 FFFF145C FFFF149C                    dc.l       StubRout
574
    553 FFFF1460 FFFF149C                    dc.l       StubRout
575
    554 FFFF1464 FFFF149C                    dc.l       StubRout
576
    555 FFFF1468 FFFF149C                    dc.l       StubRout
577
    556 FFFF146C FFFF149C                    dc.l       StubRout
578
                                             ; Task 80
579
    558 FFFF1470 FFFF149E                    dc.l       SetPenColor
580
    559 FFFF1474 FFFF14B4                    dc.l       SetFillColor
581
    560 FFFF1478 FFFF14FE                    dc.l       DrawPixel
582
    561 FFFF147C FFFF149C                    dc.l       StubRout
583
    562 FFFF1480 FFFF1528                    dc.l       DrawLine
584
    563 FFFF1484 FFFF159A                    dc.l       DrawLineTo
585
    564 FFFF1488 FFFF15B4                    dc.l       MoveTo
586
    565 FFFF148C FFFF15FA                    dc.l       FillRectangle
587
    566 FFFF1490 FFFF149C                    dc.l       StubRout
588
    567 FFFF1494 FFFF149C                    dc.l       StubRout
589
                                             ; Task 90
590
    569 FFFF1498 FFFF15BE                    dc.l       DrawRectangle
591
 
592
                                             ;------------------------------------------------------------------------------
593
                                             ; Stub routine for unimplemented functionality.
594
                                             ;------------------------------------------------------------------------------
595
                                             ;
596
    575 FFFF149C                             StubRout:
597
    576 FFFF149C 4E75                           rts
598
 
599
                                             ;------------------------------------------------------------------------------
600
                                             ; Set the graphics mode pen color
601
                                             ;------------------------------------------------------------------------------
602
    581 FFFF149E                             SetPenColor:
603
    582 FFFF149E 48E7 C000                      movem.l d0/d1,-(a7)
604
    583 FFFF14A2 21C1 0420                      move.l  d1,PenColor
605
    584 FFFF14A6 6100 0022                      bsr             Cvt24To8
606
    585 FFFF14AA 11C1 0424                      move.b  d1,PenColor8
607
    586 FFFF14AE 4CDF 0003                      movem.l (a7)+,d0/d1
608
    587 FFFF14B2 4E75                           rts
609
 
610
    589 FFFF14B4                             SetFillColor:
611
    590 FFFF14B4 48E7 C000                      movem.l d0/d1,-(a7)
612
    591 FFFF14B8 21C1 0428                      move.l  d1,FillColor
613
    592 FFFF14BC 6100 000C                      bsr             Cvt24To8
614
    593 FFFF14C0 11C1 042C                      move.b  d1,FillColor8
615
    594 FFFF14C4 4CDF 0003                      movem.l (a7)+,d0/d1
616
    595 FFFF14C8 4E75                           rts
617
 
618
    597 FFFF14CA                             Cvt24To8:
619
    598 FFFF14CA 48E7 A000                      movem.l d0/d2,-(a7)
620
    599 FFFF14CE 4282                           clr.l   d2
621
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 11
622
BOOTROM.x68
623
    600 FFFF14D0 EC99                           ror.l   #6,d1
624
    601 FFFF14D2 2001                           move.l  d1,d0
625
    602 FFFF14D4 0200 0003                      and.b   #3,d0
626
    603 FFFF14D8 1400                           move.b  d0,d2
627
    604 FFFF14DA E499                           ror.l   #2,d1                   ;
628
    605 FFFF14DC EA99                           ror.l   #5,d1
629
    606 FFFF14DE 1001                           move.b  d1,d0
630
    607 FFFF14E0 0200 0007                      and.b   #7,d0
631
    608 FFFF14E4 E540                           asl.w   #2,d0
632
    609 FFFF14E6 8400                           or.b    d0,d2
633
    610 FFFF14E8 E699                           ror.l   #3,d1
634
    611 FFFF14EA EA99                           ror.l   #5,d1
635
    612 FFFF14EC 1001                           move.b  d1,d0
636
    613 FFFF14EE 0200 0007                      and.b   #7,d0
637
    614 FFFF14F2 EB40                           asl.w   #5,d0
638
    615 FFFF14F4 8400                           or.b    d0,d2
639
    616 FFFF14F6 2202                           move.l  d2,d1
640
    617 FFFF14F8 4CDF 0005                      movem.l (a7)+,d0/d2
641
    618 FFFF14FC 4E75                           rts
642
 
643
                                             ;------------------------------------------------------------------------------
644
                                             ; d1.w = X
645
                                             ; d2.w = Y
646
                                             ;------------------------------------------------------------------------------
647
    624 FFFF14FE                             DrawPixel:
648
    625 FFFF14FE 48E7 6080                      movem.l a0/d1/d2,-(a7)
649
    626 FFFF1502 C4FC 00D0                      mulu.w  #208,d2         ; Y * 208
650
    627 FFFF1506 0282 0000 FFFF                 andi.l  #0xffff,d2
651
    628 FFFF150C E382                           asl.l   #1,d2           ; Y * 416
652
    629 FFFF150E 0281 0000 01FF                 and.l   #0x1ff,d1
653
    630 FFFF1514 D481                           add.l   d1,d2           ; Y * 416 + X
654
    631 FFFF1516 0682 0002 0000                 add.l   #BITMAPSCR,d2
655
    632 FFFF151C 2042                           move.l  d2,a0
656
    633 FFFF151E 10B8 0424                      move.b  PenColor8,(a0)
657
    634 FFFF1522 4CDF 0106                      movem.l (a7)+,a0/d1/d2
658
    635 FFFF1526 4E75                           rts
659
 
660
                                             ;------------------------------------------------------------------------------
661
                                             ; d1.w = X1
662
                                             ; d2.w = Y1
663
                                             ; d3.w = X2
664
                                             ; d4.w = Y2
665
                                             ;
666
                                             ; From Wikipedia:
667
                                             ;
668
                                             ;function line(x0, y0, x1, y1)
669
                                             ;   dx := abs(x1-x0)
670
                                             ;   dy := abs(y1-y0)
671
                                             ;   if x0 < x1 then sx := 1 else sx := -1
672
                                             ;   if y0 < y1 then sy := 1 else sy := -1
673
                                             ;   err := dx-dy
674
                                             ;
675
                                             ;   loop
676
                                             ;     setPixel(x0,y0)
677
                                             ;     if x0 = x1 and y0 = y1 exit loop
678
                                             ;     e2 := 2*err
679
                                             ;     if e2 > -dy then
680
                                             ;       err := err - dy
681
                                             ;       x0 := x0 + sx
682
                                             ;     end if
683
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 12
684
BOOTROM.x68
685
                                             ;     if e2 <  dx then
686
                                             ;       err := err + dx
687
                                             ;       y0 := y0 + sy
688
                                             ;     end if
689
                                             ;   end loop
690
                                             ;
691
                                             ; Registers
692
                                             ; d1,d2,d3,d4 = X1,Y1,X2,Y2 respectively
693
                                             ; d0 = sx, d7 = sy
694
                                             ; d5 = dx, d6 = dy
695
                                             ; a2 = err
696
                                             ; a3 = 2*err
697
                                             ;------------------------------------------------------------------------------
698
    673 FFFF1528                             DrawLine:
699
    674 FFFF1528 48E7 FF30                      movem.l d0/d1/d2/d3/d4/d5/d6/d7/a2/a3,-(a7)
700
    675 FFFF152C 0281 0000 01FF                 andi.l  #0x1ff,d1
701
    676 FFFF1532 0282 0000 01FF                 andi.l  #0x1ff,d2
702
    677 FFFF1538 0283 0000 01FF                 andi.l  #0x1ff,d3
703
    678 FFFF153E 0284 0000 01FF                 andi.l  #0x1ff,d4
704
    679 FFFF1544 31C3 0430                      move.w  d3,DrawPos              ; X
705
    680 FFFF1548 31C4 0432                      move.w  d4,DrawPos+2    ; Y
706
    681 FFFF154C 2A01                           move.l  d1,d5
707
    682 FFFF154E 9A83                           sub.l   d3,d5
708
    683 FFFF1550 6A02                           bpl             dl1
709
    684 FFFF1552 4485                           neg.l   d5              ; d5 = dx
710
    685 FFFF1554                             dl1:
711
    686 FFFF1554 2C02                           move.l  d2,d6
712
    687 FFFF1556 9C84                           sub.l   d4,d6
713
    688 FFFF1558 6A02                           bpl             dl2
714
    689 FFFF155A 4486                           neg.l   d6              ; d6 = dy
715
    690 FFFF155C                             dl2:
716
    691 FFFF155C 7001                           moveq   #1,d0   ; sx = 1
717
    692 FFFF155E 7E01                           moveq   #1,d7   ; sy = 1
718
    693 FFFF1560 B283                           cmp.l   d3,d1
719
    694 FFFF1562 6502                           blo             dl3
720
    695 FFFF1564 4480                           neg.l   d0              ; sx = -1
721
    696 FFFF1566                             dl3:
722
    697 FFFF1566 B484                           cmp.l   d4,d2
723
    698 FFFF1568 6502                           blo             dl5
724
    699 FFFF156A 4487                           neg.l   d7              ; sy = -1
725
    700 FFFF156C                             dl5:
726
    701 FFFF156C 2445                           move.l  d5,a2
727
    702 FFFF156E 95C6                           suba.l  d6,a2   ; err = dx-dy
728
    703 FFFF1570 4486                           neg.l   d6                      ; -dy
729
 
730
    705 FFFF1572                             DrawLineLoop:
731
    706 FFFF1572 6100 FF8A                      bsr             DrawPixel
732
    707 FFFF1576 B681                           cmp.l   d1,d3           ; x0 = x1 ?
733
    708 FFFF1578 6604                           bne             dl7                     ; no, keep going
734
    709 FFFF157A B882                           cmp.l   d2,d4           ; y0 = y1 ?
735
    710 FFFF157C 6716                           beq             dldone          ; yes -> line draw is done
736
    711 FFFF157E                             dl7:
737
    712 FFFF157E 264A                           move.l  a2,a3           ; e2 = err
738
    713 FFFF1580 D7CB                           adda.l  a3,a3           ; e2 = 2*err
739
    714 FFFF1582 B7C6                           cmpa.l  d6,a3           ; if (e2 > -dy)
740
    715 FFFF1584 6F04                           ble             dl8
741
    716 FFFF1586 D5C6                           adda.l  d6,a2           ;     err = err + -dy
742
    717 FFFF1588 D280                           add.l   d0,d1           ;     x0 = x0 + sx
743
    718 FFFF158A                             dl8:
744
    719 FFFF158A B7C5                           cmpa.l  d5,a3           ; if (e2 < dx)
745
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 13
746
BOOTROM.x68
747
    720 FFFF158C 6C04                           bge             dl9
748
    721 FFFF158E D5C5                           adda.l  d5,a2           ;     err = err + dx
749
    722 FFFF1590 D487                           add.l   d7,d2           ;     y0 = y0 + sy
750
    723 FFFF1592                             dl9:
751
    724 FFFF1592 60DE                           bra DrawLineLoop
752
    725 FFFF1594                             dldone:
753
    726 FFFF1594 4CDF 0CFF                      movem.l (a7)+,d0/d1/d2/d3/d4/d5/d6/d7/a2/a3
754
    727 FFFF1598 4E75                           rts
755
 
756
                                             ;------------------------------------------------------------------------------
757
                                             ; Draw line to X,Y
758
                                             ; D1.W = X
759
                                             ; D2.W = Y
760
                                             ;------------------------------------------------------------------------------
761
                                             ;
762
    735 FFFF159A                             DrawLineTo:
763
    736 FFFF159A 48E7 7800                      movem.l d1/d2/d3/d4,-(a7)
764
    737 FFFF159E 3601                           move.w  d1,d3
765
    738 FFFF15A0 3802                           move.w  d2,d4
766
    739 FFFF15A2 3238 0430                      move.w  DrawPos,d1
767
    740 FFFF15A6 3438 0432                      move.w  DrawPos+2,d2
768
    741 FFFF15AA 6100 FF7C                      bsr             DrawLine
769
    742 FFFF15AE 4CDF 001E                      movem.l (a7)+,d1/d2/d3/d4
770
    743 FFFF15B2 4E75                           rts
771
 
772
 
773
                                             ;------------------------------------------------------------------------------
774
                                             ; Move drawing position to X,Y
775
                                             ; d1.w = X
776
                                             ; d2.w = y
777
                                             ;------------------------------------------------------------------------------
778
                                             ;
779
    752 FFFF15B4                             MoveTo:
780
    753 FFFF15B4 31C1 0430                      move.w  d1,DrawPos
781
    754 FFFF15B8 31C2 0432                      move.w  d2,DrawPos+2
782
    755 FFFF15BC 4E75                           rts
783
 
784
    757 FFFF15BE                             DrawRectangle:
785
    758 FFFF15BE 48E7 FF00                      movem.l d0/d1/d2/d3/d4/d5/d6/d7,-(a7)
786
    759 FFFF15C2 3001                           move.w  d1,d0
787
    760 FFFF15C4 3E02                           move.w  d2,d7
788
    761 FFFF15C6 3A03                           move.w  d3,d5
789
    762 FFFF15C8 3C04                           move.w  d4,d6
790
    763 FFFF15CA 3802                           move.w  d2,d4
791
    764 FFFF15CC 6100 FF5A                      bsr             DrawLine
792
    765 FFFF15D0 3203                           move.w  d3,d1
793
    766 FFFF15D2 3404                           move.w  d4,d2
794
    767 FFFF15D4 3605                           move.w  d5,d3
795
    768 FFFF15D6 3806                           move.w  d6,d4
796
    769 FFFF15D8 6100 FF4E                      bsr             DrawLine
797
    770 FFFF15DC 3203                           move.w  d3,d1
798
    771 FFFF15DE 3404                           move.w  d4,d2
799
    772 FFFF15E0 3600                           move.w  d0,d3
800
    773 FFFF15E2 3806                           move.w  d6,d4
801
    774 FFFF15E4 6100 FF42                      bsr             DrawLine
802
    775 FFFF15E8 3203                           move.w  d3,d1
803
    776 FFFF15EA 3404                           move.w  d4,d2
804
    777 FFFF15EC 3600                           move.w  d0,d3
805
    778 FFFF15EE 3807                           move.w  d7,d4
806
    779 FFFF15F0 6100 FF36                      bsr             DrawLine
807
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 14
808
BOOTROM.x68
809
    780 FFFF15F4 4CDF 00FF                      movem.l (a7)+,d0/d1/d2/d3/d4/d5/d6/d7
810
    781 FFFF15F8 4E75                           rts
811
 
812
                                             ;------------------------------------------------------------------------------
813
                                             ; Draw a filled rectangle
814
                                             ;------------------------------------------------------------------------------
815
    786 FFFF15FA                             FillRectangle:
816
    787 FFFF15FA 48E7 7800                      movem.l d1/d2/d3/d4,-(a7)
817
    788 FFFF15FE 3F38 0424                      move.w  PenColor8,-(a7)
818
    789 FFFF1602 6100 FFBA                      bsr     DrawRectangle
819
    790 FFFF1606 31F8 042C 0424                 move.w  FillColor8,PenColor8
820
    791 FFFF160C                             FillRect3:
821
    792 FFFF160C B641                           cmp.w   d1,d3
822
    793 FFFF160E 6504                           blo             FillRect1
823
    794 FFFF1610 B842                           cmp.w   d2,d4
824
    795 FFFF1612 640E                           bhs             FillRect2
825
    796 FFFF1614                             FillRect1:
826
    797 FFFF1614 5241                           addi.w  #1,d1
827
    798 FFFF1616 5242                           addi.w  #1,d2
828
    799 FFFF1618 5343                           subi.w  #1,d3
829
    800 FFFF161A 5344                           subi.w  #1,d4
830
    801 FFFF161C 6100 FFA0                      bsr             DrawRectangle
831
    802 FFFF1620 60EA                           bra             FillRect3
832
    803 FFFF1622                             FillRect2:
833
    804 FFFF1622 31DF 0424                      move.w  (a7)+,PenColor8
834
    805 FFFF1626 4CDF 001E                      movem.l (a7)+,d1/d2/d3/d4
835
    806 FFFF162A 4E75                           rts
836
 
837
                                             ;------------------------------------------------------------------------------
838
                                             ; d1.b 0=echo off, non-zero = echo on
839
                                             ;------------------------------------------------------------------------------
840
    811 FFFF162C                             SetKeyboardEcho:
841
    812 FFFF162C 11C1 041C                      move.b  d1,KeybdEcho
842
    813 FFFF1630 4E75                           rts
843
 
844
                                             ;------------------------------------------------------------------------------
845
                                             ; read ascii character into d1.b
846
                                             ;------------------------------------------------------------------------------
847
                                             ;
848
    819 FFFF1632 4E71                           nop
849
    820 FFFF1634 4E71                           nop
850
    821 FFFF1636 4E71                           nop
851
    822 FFFF1638 4E71                           nop
852
    823 FFFF163A 4E71                           nop
853
    824 FFFF163C 4E71                           nop
854
    825 FFFF163E 4E71                           nop
855
    826 FFFF1640 4E71                           nop
856
    827 FFFF1642 4E71                           nop
857
    828 FFFF1644 4E71                           nop
858
    829 FFFF1646 4E71                           nop
859
    830 FFFF1648 4E71                           nop
860
    831 FFFF164A 4E71                           nop
861
    832 FFFF164C 4E71                           nop
862
    833 FFFF164E 4E71                           nop
863
    834 FFFF1650 4E71                           nop
864
    835 FFFF1652 4E71                           nop
865
    836 FFFF1654 4E71                           nop
866
    837 FFFF1656 4E71                           nop
867
 
868
    839 FFFF1658                             GetKey:
869
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 15
870
BOOTROM.x68
871
    840 FFFF1658 3239 FFDC 0000                 move.w  KEYBD,d1
872
    841 FFFF165E 6AF8                           bpl     GetKey
873
    842 FFFF1660 4279 FFDC 0002                 clr.w   KEYBD+2                 ; clear the keyboard strobe
874
    843 FFFF1666 0241 00FF                      and.w   #0xFF,d1                ; remove strobe bit
875
    844 FFFF166A 0C38 0000 041C                 cmpi.b  #0,KeybdEcho    ; is keyboard echo on ?
876
    845 FFFF1670 670C                           beq             gk1
877
    846 FFFF1672 0C01 000D                      cmpi.b  #'\r',d1                ; convert CR keystroke into CRLF
878
    847 FFFF1676 6774                           beq             CRLF
879
    848 FFFF1678 4EB9 FFFF 1732                 jsr             DisplayChar
880
    849 FFFF167E                             gk1:
881
    850 FFFF167E 4E75                           rts
882
 
883
                                             ;------------------------------------------------------------------------------
884
                                             ; AOS support routines
885
                                             ;------------------------------------------------------------------------------
886
                                             ; AOS - CF = 0 if no key is available, otherwise CF = 1
887
                                             ;
888
    857 FFFF1680                             KeyStatus:
889
    858 FFFF1680 3F01                           move.w  d1,-(a7)
890
    859 FFFF1682 3239 FFDC 0000                 move.w  KEYBD,d1
891
    860 FFFF1688 6A08                           bpl             KST1
892
    861 FFFF168A 321F                           move.w  (a7)+,d1
893
    862 FFFF168C 003C 0001                      ori             #1,ccr
894
    863 FFFF1690 4E75                           rts
895
    864 FFFF1692                             KST1:
896
    865 FFFF1692 321F                           move.w  (a7)+,d1
897
    866 FFFF1694 023C 00FE                      andi    #0xFE,ccr
898
    867 FFFF1698 4E75                           rts
899
 
900
    869 FFFF169A                             TranStatus
901
    870 FFFF169A 0839 0000 FFDC 0A01            btst    #0,UART_LS
902
    871 FFFF16A2 6706                           beq             trnstat1
903
    872 FFFF16A4 003C 0001                      ori             #1,ccr
904
    873 FFFF16A8 4E75                           rts
905
    874 FFFF16AA                             trnstat1:
906
    875 FFFF16AA 023C 00FE                      andi    #0xfe,ccr
907
    876 FFFF16AE 4E75                           rts
908
 
909
                                             ;*
910
                                             ;*============== GET:
911
                                             ;*
912
                                             ;*  Get's charter in life is to input characters from the user default
913
                                             ;*  i/o device.  Get is also a hook into ADVANCE, telling ADVANCE where
914
                                             ;*  and how to get characters from the user-supplied input device.
915
                                             ;*
916
                                             ;*  Entry conditions:
917
                                             ;*
918
                                             ;*       A0 = place where we put the input character
919
                                             ;*
920
    889 FFFF16B0                             GET:
921
    890 FFFF16B0 4280                           clr.l   d0                              ; clear upper bits of d0
922
    891 FFFF16B2 3039 FFDC 0000                 move.w  KEYBD,d0
923
    892 FFFF16B8 6A12                           bpl             GET1
924
    893 FFFF16BA 0240 00FF                      andi.w  #0xff,d0                ; mask off strobe bit
925
    894 FFFF16BE 4279 FFDC 0002                 clr.w   KEYBD+2                 ; clear the keyboard strobe
926
    895 FFFF16C4 41F8 0460                      lea             Keybuf,a0
927
    896 FFFF16C8 2080                           move.l  d0,(a0)
928
    897 FFFF16CA 4E75                           rts
929
    898 FFFF16CC                             GET1:
930
    899 FFFF16CC 41F8 0460                      lea             Keybuf,a0
931
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 16
932
BOOTROM.x68
933
    900 FFFF16D0 4290                           clr.l   (a0)
934
    901 FFFF16D2 4E75                           rts
935
 
936
                                             ;*
937
                                             ;*============== PUT:
938
                                             ;*
939
                                             ;*  Put's charter in life is to output characters from the user default
940
                                             ;*  i/o device.  Put is also a hook into ADVANCE, telling ADVANCE where
941
                                             ;*  and how to get characters from the user-supplied output device.
942
                                             ;*
943
                                             ;*  Entry conditions:
944
                                             ;*
945
                                             ;*       D1 = character you want to output to the user-supplied device.
946
                                             ;*
947
    914 FFFF16D4                             PUT:
948
    915 FFFF16D4 6100 005C                      bsr             DisplayChar
949
    916 FFFF16D8 4E75                           rts
950
 
951
                                             ;------------------------------------------------------------------------------
952
                                             ; get key pending status into d1.b
953
                                             ;------------------------------------------------------------------------------
954
                                             ;
955
    922 FFFF16DA                             CheckForKey:
956
    923 FFFF16DA 3239 FFDC 0000                 move.w  KEYBD,d1
957
    924 FFFF16E0 6A06                           bpl             cfk1
958
    925 FFFF16E2 123C 0001                      move.b  #1,d1
959
    926 FFFF16E6 4E75                           rts
960
    927 FFFF16E8                             cfk1:
961
    928 FFFF16E8 4201                           clr.b   d1
962
    929 FFFF16EA 4E75                           rts
963
 
964
                                             ;
965
    932 FFFF16EC                             CRLF:
966
    933 FFFF16EC 2F01                           move.l  d1,-(a7)
967
    934 FFFF16EE 123C 000D                      move.b  #'\r',d1
968
    935 FFFF16F2 4EB9 FFFF 1732                 jsr             DisplayChar
969
    936 FFFF16F8 123C 000A                      move.b  #'\n',d1
970
    937 FFFF16FC 4EB9 FFFF 1732                 jsr             DisplayChar
971
    938 FFFF1702 221F                           move.l  (a7)+,d1
972
    939 FFFF1704 4E75                           rts
973
 
974
                                             ;------------------------------------------------------------------------------
975
                                             ; Calculate screen memory location from CursorRow,CursorCol.
976
                                             ; Destroys d0,d2,a0
977
                                             ;------------------------------------------------------------------------------
978
                                             ;
979
    946 FFFF1706                             CalcScreenLoc:
980
    947 FFFF1706 3038 0418                      move.w  CursorRow,d0            ; compute screen location
981
    948 FFFF170A 0240 007F                      andi.w  #0x7f,d0
982
    949 FFFF170E C0F9 FFDA 0000                 mulu.w  TEXT_COLS,d0
983
    950 FFFF1714 3438 041A                      move.w  CursorCol,d2
984
    951 FFFF1718 0242 00FF                      andi.w  #0xff,d2
985
    952 FFFF171C D042                           add.w   d2,d0
986
    953 FFFF171E E340                           asl.w   #1,d0
987
    954 FFFF1720 0680 FFD0 0000                 add.l   #TEXTSCR,d0
988
    955 FFFF1726 2040                           move.l  d0,a0                           ; a0 = screen location
989
    956 FFFF1728 E288                           lsr.l   #1,d0
990
    957 FFFF172A 33C0 FFDA 0016                 move.w  d0,TEXT_CURPOS
991
    958 FFFF1730 4E75                           rts
992
 
993
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 17
994
BOOTROM.x68
995
                                             ;------------------------------------------------------------------------------
996
                                             ; Display a character on the screen
997
                                             ; d1.b = char to display
998
                                             ;------------------------------------------------------------------------------
999
                                             ;
1000
    965 FFFF1732                             DisplayChar:
1001
    966 FFFF1732 0C01 000D                      cmpi.b  #'\r',d1                        ; carriage return ?
1002
    967 FFFF1736 6606                           bne             dccr
1003
    968 FFFF1738 4278 041A                      clr.w   CursorCol                       ; just set cursor column to zero on a CR
1004
    969 FFFF173C 4E75                           rts
1005
    970 FFFF173E                             dccr:
1006
    971 FFFF173E 0C01 0091                      cmpi.b  #0x91,d1                        ; cursor right ?
1007
    972 FFFF1742 660E                           bne     dcx6
1008
    973 FFFF1744 0C78 0033 041A                 cmpi.w  #51,CursorCol
1009
    974 FFFF174A 6704                           beq             dcx7
1010
    975 FFFF174C 5278 041A                      addi.w  #1,CursorCol
1011
    976 FFFF1750                             dcx7:
1012
    977 FFFF1750 4E75                           rts
1013
    978 FFFF1752                             dcx6:
1014
    979 FFFF1752 0C01 0090                      cmpi.b  #0x90,d1                        ; cursor up ?
1015
    980 FFFF1756 660E                           bne             dcx8
1016
    981 FFFF1758 0C78 0000 0418                 cmpi.w  #0,CursorRow
1017
    982 FFFF175E 67F0                           beq             dcx7
1018
    983 FFFF1760 5378 0418                      subi.w  #1,CursorRow
1019
    984 FFFF1764 4E75                           rts
1020
    985 FFFF1766                             dcx8:
1021
    986 FFFF1766 0C01 0093                      cmpi.b  #0x93,d1                        ; cursor left?
1022
    987 FFFF176A 660E                           bne             dcx9
1023
    988 FFFF176C 0C78 0000 041A                 cmpi.w  #0,CursorCol
1024
    989 FFFF1772 67DC                           beq             dcx7
1025
    990 FFFF1774 5378 041A                      subi.w  #1,CursorCol
1026
    991 FFFF1778 4E75                           rts
1027
    992 FFFF177A                             dcx9:
1028
    993 FFFF177A 0C01 0092                      cmpi.b  #0x92,d1                        ; cursor down ?
1029
    994 FFFF177E 660E                           bne             dcx10
1030
    995 FFFF1780 0C78 001E 0418                 cmpi.w  #30,CursorRow
1031
    996 FFFF1786 67C8                           beq             dcx7
1032
    997 FFFF1788 5278 0418                      addi.w  #1,CursorRow
1033
    998 FFFF178C 4E75                           rts
1034
    999 FFFF178E                             dcx10:
1035
   1000 FFFF178E 0C01 0094                      cmpi.b  #0x94,d1                        ; cursor home ?
1036
   1001 FFFF1792 6614                           bne             dcx11
1037
   1002 FFFF1794 0C78 0000 041A                 cmpi.w  #0,CursorCol
1038
   1003 FFFF179A 6706                           beq             dcx12
1039
   1004 FFFF179C 4278 041A                      clr.w   CursorCol
1040
   1005 FFFF17A0 4E75                           rts
1041
   1006 FFFF17A2                             dcx12
1042
   1007 FFFF17A2 4278 0418                      clr.w   CursorRow
1043
   1008 FFFF17A6 4E75                           rts
1044
   1009 FFFF17A8                             dcx11:
1045
   1010 FFFF17A8 48E7 E080                      movem.l d0/d1/d2/a0,-(a7)
1046
   1011 FFFF17AC 0C01 0099                      cmpi.b  #0x99,d1                        ; delete ?
1047
   1012 FFFF17B0 660A                           bne             dcx13
1048
   1013 FFFF17B2 6100 FF52                      bsr             CalcScreenLoc
1049
   1014 FFFF17B6 3038 041A                      move.w  CursorCol,d0
1050
   1015 FFFF17BA 601A                           bra             dcx5
1051
   1016 FFFF17BC                             dcx13:
1052
   1017 FFFF17BC 0C01 0008                      cmpi.b  #CTRLH,d1                       ; backspace ?
1053
   1018 FFFF17C0 662C                           bne     dcx3
1054
   1019 FFFF17C2 0C78 0000 041A                 cmpi.w  #0,CursorCol
1055
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 18
1056
BOOTROM.x68
1057
   1020 FFFF17C8 6742                           beq     dcx4
1058
   1021 FFFF17CA 5378 041A                      subi.w  #1,CursorCol
1059
   1022 FFFF17CE 6100 FF36                      bsr             CalcScreenLoc           ; a0 = screen location
1060
   1023 FFFF17D2 3038 041A                      move.w  CursorCol,d0
1061
   1024 FFFF17D6                             dcx5:
1062
   1025 FFFF17D6 30E8 0002                      move.w  2(a0),(a0)+
1063
   1026 FFFF17DA 5240                           addi.w  #1,d0
1064
   1027 FFFF17DC B079 FFDA 0000                 cmp.w   TEXT_COLS,d0
1065
   1028 FFFF17E2 65F2                           blo             dcx5
1066
   1029 FFFF17E4 303C 0020                      move.w  #32,d0
1067
   1030 FFFF17E8 3140 FFFE                      move.w  d0,-2(a0)
1068
   1031 FFFF17EC 601E                           bra             dcx4
1069
   1032 FFFF17EE                             dcx3:
1070
   1033 FFFF17EE 0C01 000A                      cmpi.b  #'\n',d1                ; linefeed ?
1071
   1034 FFFF17F2 6714                           beq             dclf
1072
 
1073
   1036 FFFF17F4 6100 FF10                      bsr             CalcScreenLoc   ; a0 = screen location
1074
   1037 FFFF17F8 6100 01B8                      bsr             AsciiToScreen   ; convert ascii char to screen char
1075
   1038 FFFF17FC 30C1                           move.w  d1,(a0)+
1076
   1039 FFFF17FE 6100 0012                      bsr             IncCursorPos
1077
   1040 FFFF1802 4CDF 0107                      movem.l (a7)+,d0/d1/d2/a0
1078
   1041 FFFF1806 4E75                           rts
1079
   1042 FFFF1808                             dclf:
1080
   1043 FFFF1808 6100 0022                      bsr             IncCursorRow
1081
   1044 FFFF180C                             dcx4:
1082
   1045 FFFF180C 4CDF 0107                      movem.l (a7)+,d0/d1/d2/a0               ; get back a0
1083
   1046 FFFF1810 4E75                           rts
1084
 
1085
                                             ;------------------------------------------------------------------------------
1086
                                             ; Increment the cursor position, scroll the screen if needed.
1087
                                             ;------------------------------------------------------------------------------
1088
                                             ;
1089
   1052 FFFF1812                             IncCursorPos:
1090
   1053 FFFF1812 5279 FFDA 0016                 addi.w  #1,TEXT_CURPOS
1091
   1054 FFFF1818 5278 041A                      addi.w  #1,CursorCol
1092
   1055 FFFF181C 3039 FFDA 0000                 move.w  TEXT_COLS,d0
1093
   1056 FFFF1822 B078 041A                      cmp.w   CursorCol,d0
1094
   1057 FFFF1826 642E                           bhs             icc1
1095
   1058 FFFF1828 4278 041A                      clr.w   CursorCol
1096
   1059 FFFF182C                             IncCursorRow:
1097
   1060 FFFF182C 5278 0418                      addi.w  #1,CursorRow
1098
   1061 FFFF1830 3039 FFDA 0002                 move.w  TEXT_ROWS,d0
1099
   1062 FFFF1836 B078 0418                      cmp.w   CursorRow,d0
1100
   1063 FFFF183A 621A                           bhi             icc1
1101
   1064 FFFF183C 3039 FFDA 0002                 move.w  TEXT_ROWS,d0
1102
   1065 FFFF1842 31C0 0418                      move.w  d0,CursorRow            ; in case CursorRow is way over
1103
   1066 FFFF1846 5378 0418                      subi.w  #1,CursorRow
1104
   1067 FFFF184A E340                           asl.w   #1,d0
1105
   1068 FFFF184C 9179 FFDA 0016                 sub.w   d0,TEXT_CURPOS
1106
   1069 FFFF1852 6100 00CE                      bsr             ScrollUp
1107
   1070 FFFF1856                             icc1:
1108
   1071 FFFF1856 4E75                           rts
1109
 
1110
                                             ;------------------------------------------------------------------------------
1111
                                             ; Display a string on the screen.
1112
                                             ;------------------------------------------------------------------------------
1113
                                             ;
1114
   1077 FFFF1858                             DisplayString:
1115
   1078 FFFF1858 48E7 C040                      movem.l d0/d1/a1,-(a7)
1116
   1079 FFFF185C                             dspj1:
1117
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 19
1118
BOOTROM.x68
1119
   1080 FFFF185C 4281                           clr.l   d1                              ; clear upper bits of d1
1120
   1081 FFFF185E 1219                           move.b  (a1)+,d1                ; move string char into d1
1121
   1082 FFFF1860 0C01 0000                      cmpi.b  #0,d1                   ; is it end of string ?
1122
   1083 FFFF1864 6706                           beq             dsret
1123
   1084 FFFF1866 6100 FECA                      bsr             DisplayChar             ; display character
1124
   1085 FFFF186A 60F0                           bra             dspj1                   ; go back for next character
1125
   1086 FFFF186C                             dsret:
1126
   1087 FFFF186C 4CDF 0203                      movem.l (a7)+,d0/d1/a1
1127
   1088 FFFF1870 4E75                           rts
1128
 
1129
   1090 FFFF1872                             DisplayStringCRLF:
1130
   1091 FFFF1872 6100 FFE4                      bsr             DisplayString
1131
   1092 FFFF1876 6000 FE74                      bra             CRLF
1132
 
1133
                                             ;------------------------------------------------------------------------------
1134
                                             ; Display a string on the screen. Stop at 255 chars, or NULL or D1.W
1135
                                             ;------------------------------------------------------------------------------
1136
                                             ;
1137
   1098 FFFF187A                             DisplayString1:
1138
   1099 FFFF187A 48E7 C040                      movem.l d0/d1/a1,-(a7)
1139
   1100 FFFF187E 0241 00FF                      andi.w  #255,d1                 ; max 255 chars
1140
   1101 FFFF1882 2001                           move.l  d1,d0
1141
   1102 FFFF1884                             dspj11:
1142
   1103 FFFF1884 1219                           move.b  (a1)+,d1                ; move string char into d1
1143
   1104 FFFF1886 0C01 0000                      cmpi.b  #0,d1                   ; is it end of string ?
1144
   1105 FFFF188A 6708                           beq             dsret1
1145
   1106 FFFF188C 6100 FEA4                      bsr             DisplayChar             ; display character
1146
   1107 FFFF1890 57C8 FFF2                      dbeq    d0,dspj11               ; go back for next character
1147
   1108 FFFF1894                             dsret1:
1148
   1109 FFFF1894 4CDF 0203                      movem.l (a7)+,d0/d1/a1
1149
   1110 FFFF1898 4E75                           rts
1150
 
1151
                                             ;------------------------------------------------------------------------------
1152
                                             ; Display a string on the screen. Stop at 255 chars, or NULL or D1.W
1153
                                             ; end string with CR,LF
1154
                                             ;------------------------------------------------------------------------------
1155
                                             ;
1156
   1117 FFFF189A                             DisplayString0:
1157
   1118 FFFF189A 6100 FFDE                      bsr             DisplayString1
1158
   1119 FFFF189E 6000 FE4C                      bra             CRLF
1159
 
1160
                                             ;------------------------------------------------------------------------------
1161
                                             ; Dispatch cursor functions
1162
                                             ;------------------------------------------------------------------------------
1163
                                             ;
1164
   1125 FFFF18A2                             Cursor1:
1165
   1126 FFFF18A2 0C41 00FF                      cmpi.w  #0x00ff,d1
1166
   1127 FFFF18A6 670E                           beq             GetCursorPos
1167
   1128 FFFF18A8 0C41 FF00                      cmpi.w  #0xFF00,d1
1168
   1129 FFFF18AC 6714                           beq             SetCursorPos
1169
   1130 FFFF18AE 4EB9 FFFF 18E8                 jsr             ClearScreen
1170
   1131 FFFF18B4 4E75                           rts
1171
 
1172
                                             ;------------------------------------------------------------------------------
1173
                                             ; Get the cursor position.
1174
                                             ; d1.b0 = row
1175
                                             ; d1.b1 = col
1176
                                             ;------------------------------------------------------------------------------
1177
                                             ;
1178
   1139 FFFF18B6                             GetCursorPos:
1179
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 20
1180
BOOTROM.x68
1181
   1140 FFFF18B6 3238 041A                      move.w  CursorCol,d1
1182
   1141 FFFF18BA E141                           asl.w   #8,D1
1183
   1142 FFFF18BC 1238 0418                      move.b  CursorRow,d1
1184
   1143 FFFF18C0 4E75                           rts
1185
 
1186
                                             ;------------------------------------------------------------------------------
1187
                                             ; Set the position of the cursor, update the linear screen pointer.
1188
                                             ; d1.b0 = row
1189
                                             ; d1.b1 = col
1190
                                             ;------------------------------------------------------------------------------
1191
                                             ;
1192
   1151 FFFF18C2                             SetCursorPos:
1193
   1152 FFFF18C2 2F01                           move.l  d1,-(a7)
1194
   1153 FFFF18C4 11C1 0418                      move.b  d1,CursorRow
1195
   1154 FFFF18C8 E049                           lsr.w   #8,d1
1196
   1155 FFFF18CA 31C1 041A                      move.w  d1,CursorCol
1197
   1156 FFFF18CE 3238 0418                      move.w  CursorRow,d1
1198
   1157 FFFF18D2 C2F9 FFDA 0000                 mulu.w  TEXT_COLS,d1
1199
   1158 FFFF18D8 D278 041A                      add.w   CursorCol,d1
1200
   1159 FFFF18DC E341                           asl.w   #1,d1
1201
   1160 FFFF18DE 33C1 FFDA 0016                 move.w  d1,TEXT_CURPOS
1202
   1161 FFFF18E4                             scp1:
1203
   1162 FFFF18E4 221F                           move.l  (a7)+,d1
1204
   1163 FFFF18E6 4E75                           rts
1205
 
1206
                                             ;------------------------------------------------------------------------------
1207
                                             ; Clear the screen and the screen color memory
1208
                                             ; We clear the screen to give a visual indication that the system
1209
                                             ; is working at all.
1210
                                             ;------------------------------------------------------------------------------
1211
                                             ;
1212
   1171 FFFF18E8                             ClearScreen:
1213
   1172 FFFF18E8 3239 FFDA 0000                 move.w  TEXT_COLS,d1    ; calc number to clear
1214
   1173 FFFF18EE C2F9 FFDA 0002                 mulu.w  TEXT_ROWS,d1
1215
   1174 FFFF18F4 303C 0020                      move.w  #32,d0                  ; space character
1216
   1175 FFFF18F8 207C FFD0 0000                 move.l  #TEXTSCR,a0             ; text screen address
1217
   1176 FFFF18FE                             csj4:
1218
   1177 FFFF18FE 30C0                           move.w  d0,(a0)+
1219
   1178 FFFF1900 57C9 FFFC                      dbeq    d1,csj4
1220
 
1221
   1180 FFFF1904 3239 FFDA 0000                 move.w  TEXT_COLS,d1    ; calc number to clear
1222
   1181 FFFF190A C2F9 FFDA 0002                 mulu.w  TEXT_ROWS,d1
1223
   1182 FFFF1910 3038 0414                      move.w  ScreenColor,d0          ; a nice color blue, light blue
1224
   1183 FFFF1914 207C FFD1 0000                 move.l  #COLORSCR,a0            ; text color address
1225
   1184 FFFF191A                             csj3:
1226
   1185 FFFF191A 30C0                           move.w  d0,(a0)+
1227
   1186 FFFF191C 57C9 FFFC                      dbeq    d1,csj3
1228
   1187 FFFF1920 4E75                           rts
1229
 
1230
                                             ;------------------------------------------------------------------------------
1231
                                             ; Scroll text on the screen upwards
1232
                                             ;------------------------------------------------------------------------------
1233
                                             ;
1234
   1193 FFFF1922                             ScrollUp:
1235
   1194 FFFF1922 48E7 E080                      movem.l d0/d1/d2/a0,-(a7)
1236
   1195 FFFF1926 3039 FFDA 0000                 move.w  TEXT_COLS,d0            ; calc number of chars to scroll
1237
   1196 FFFF192C C0F9 FFDA 0002                 mulu.w  TEXT_ROWS,d0
1238
   1197 FFFF1932 9079 FFDA 0000                 sub.w   TEXT_COLS,d0            ; one less row
1239
   1198 FFFF1938 41F9 FFD0 0000                 lea             TEXTSCR,a0
1240
   1199 FFFF193E 3439 FFDA 0000                 move.w  TEXT_COLS,d2
1241
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 21
1242
BOOTROM.x68
1243
   1200 FFFF1944 E342                           asl.w   #1,d2
1244
   1201 FFFF1946                             scrup1:
1245
   1202 FFFF1946 30F0 2000                      move.w  (a0,d2.w),(a0)+
1246
   1203 FFFF194A 57C8 FFFA                      dbeq    d0,scrup1
1247
 
1248
   1205 FFFF194E 3239 FFDA 0002                 move.w  TEXT_ROWS,d1
1249
   1206 FFFF1954 5341                           subi.w  #1,d1
1250
   1207 FFFF1956 4EB9 FFFF 1962                 jsr             BlankLine
1251
   1208 FFFF195C 4CDF 0107                      movem.l (a7)+,d0/d1/d2/a0
1252
   1209 FFFF1960 4E75                           rts
1253
 
1254
                                             ;------------------------------------------------------------------------------
1255
                                             ; Blank out a line on the display
1256
                                             ; line number to blank is in D1.W
1257
                                             ;------------------------------------------------------------------------------
1258
                                             ;
1259
   1216 FFFF1962                             BlankLine:
1260
   1217 FFFF1962 48E7 8080                      movem.l d0/a0,-(a7)
1261
   1218 FFFF1966 3039 FFDA 0000                 move.w  TEXT_COLS,d0
1262
   1219 FFFF196C C0C1                           mulu.w  d1,d0                           ; d0 = row * cols
1263
   1220 FFFF196E E340                           asl.w   #1,d0                           ; *2 for moving words, not bytes
1264
   1221 FFFF1970 0680 FFD0 0000                 add.l   #TEXTSCR,d0                     ; add in screen base
1265
   1222 FFFF1976 2040                           move.l  d0,a0
1266
   1223 FFFF1978 3039 FFDA 0000                 move.w  TEXT_COLS,d0            ; d0 = number of chars to blank out
1267
   1224 FFFF197E                             blnkln1:
1268
   1225 FFFF197E 30FC 0020                      move.w  #' ',(a0)+
1269
   1226 FFFF1982 57C8 FFFA                      dbeq    d0,blnkln1
1270
   1227 FFFF1986 4CDF 0101                      movem.l (a7)+,d0/a0
1271
   1228 FFFF198A 4E75                           rts
1272
 
1273
                                             ;------------------------------------------------------------------------------
1274
                                             ; d1 = number
1275
                                             ; d2.b = column width
1276
                                             ;------------------------------------------------------------------------------
1277
   1234 FFFF198C                             DisplayNum20:
1278
   1235 FFFF198C 48E7 F800                      movem.l d0/d1/d2/d3/d4,-(a7)
1279
   1236 FFFF1990 4284                           clr.l   d4
1280
   1237 FFFF1992 1802                           move.b  d2,d4
1281
   1238 FFFF1994 4EB9 FFFF 2F7A                 jsr             PRTNUM
1282
   1239 FFFF199A 4CDF 001F                      movem.l (a7)+,d0/d1/d2/d3/d4
1283
   1240 FFFF199E 4E75                           rts
1284
 
1285
                                             ;------------------------------------------------------------------------------
1286
                                             ; d1 = number
1287
                                             ;------------------------------------------------------------------------------
1288
   1245 FFFF19A0                             DisplayNum3:
1289
   1246 FFFF19A0 48E7 F800                      movem.l d0/d1/d2/d3/d4,-(a7)
1290
   1247 FFFF19A4 4284                           clr.l   d4
1291
   1248 FFFF19A6 4EB9 FFFF 2F7A                 jsr             PRTNUM
1292
   1249 FFFF19AC 4CDF 001F                      movem.l (a7)+,d0/d1/d2/d3/d4
1293
   1250 FFFF19B0 4E75                           rts
1294
 
1295
                                             ;------------------------------------------------------------------------------
1296
                                             ; Convert ASCII character to screen display character.
1297
                                             ;------------------------------------------------------------------------------
1298
                                             ;
1299
   1256 FFFF19B2                             AsciiToScreen:
1300
   1257 FFFF19B2 0241 00FF                      andi.w  #0x00ff,d1
1301
   1258 FFFF19B6 0C01 0041                      cmpi.b  #'A',d1
1302
   1259 FFFF19BA 6516                           blo             atoscr1
1303
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 22
1304
BOOTROM.x68
1305
   1260 FFFF19BC 0C01 005A                      cmpi.b  #'Z',d1
1306
   1261 FFFF19C0 6310                           bls             atoscr1
1307
   1262 FFFF19C2 0C01 007A                      cmpi.b  #'z',d1
1308
   1263 FFFF19C6 620A                           bhi     atoscr1
1309
   1264 FFFF19C8 0C01 0061                      cmpi.b  #'a',d1
1310
   1265 FFFF19CC 6504                           blo     atoscr1
1311
   1266 FFFF19CE 0401 0060                      subi.b  #0x60,d1
1312
   1267 FFFF19D2                             atoscr1:
1313
   1268 FFFF19D2 0041 0100                      ori.w   #0x100,d1
1314
   1269 FFFF19D6 4E75                           rts
1315
 
1316
                                             ;------------------------------------------------------------------------------
1317
                                             ; Convert screen character to ascii character
1318
                                             ;------------------------------------------------------------------------------
1319
                                             ;
1320
   1275 FFFF19D8                             ScreenToAscii:
1321
   1276 FFFF19D8 0201 00FF                      andi.b  #0xff,d1
1322
   1277 FFFF19DC 0C01 001A                      cmpi.b  #26,d1
1323
   1278 FFFF19E0 6204                           bhi             stasc1
1324
   1279 FFFF19E2 0601 0060                      addi.b  #0x60,d1
1325
   1280 FFFF19E6                             stasc1:
1326
   1281 FFFF19E6 4E75                           rts
1327
 
1328
                                             ;------------------------------------------------------------------------------
1329
                                             ; Display nybble in D1.B
1330
                                             ;------------------------------------------------------------------------------
1331
                                             ;
1332
   1287 FFFF19E8                             DisplayNybble:
1333
   1288 FFFF19E8 3F01                           move.w  d1,-(a7)
1334
   1289 FFFF19EA 0201 000F                      andi.b  #0xF,d1
1335
   1290 FFFF19EE 0601 0030                      addi.b  #'0',d1
1336
   1291 FFFF19F2 0C01 0039                      cmpi.b  #'9',d1
1337
   1292 FFFF19F6 6302                           bls             dispnyb1
1338
   1293 FFFF19F8 5E01                           addi.b  #7,d1
1339
   1294 FFFF19FA                             dispnyb1:
1340
   1295 FFFF19FA 6100 FD36                      bsr             DisplayChar
1341
   1296 FFFF19FE 321F                           move.w  (a7)+,d1
1342
   1297 FFFF1A00 4E75                           rts
1343
 
1344
                                             ;------------------------------------------------------------------------------
1345
                                             ; Display the byte in D1.B
1346
                                             ;------------------------------------------------------------------------------
1347
                                             ;
1348
   1303 FFFF1A02                             DisplayByte:
1349
   1304 FFFF1A02 3F01                           move.w  d1,-(a7)
1350
   1305 FFFF1A04 E819                           ror.b   #4,d1
1351
   1306 FFFF1A06 6100 FFE0                      bsr             DisplayNybble
1352
   1307 FFFF1A0A E919                           rol.b   #4,d1
1353
   1308 FFFF1A0C 6100 FFDA                      bsr             DisplayNybble
1354
   1309 FFFF1A10 321F                           move.w  (a7)+,d1
1355
   1310 FFFF1A12 4E75                           rts
1356
 
1357
                                             ;------------------------------------------------------------------------------
1358
                                             ; Display the 32 bit word in D1.L
1359
                                             ;------------------------------------------------------------------------------
1360
                                             ;
1361
   1316 FFFF1A14                             DisplayWord:
1362
   1317 FFFF1A14 E199                           rol.l   #8,d1
1363
   1318 FFFF1A16 6100 FFEA                      bsr             DisplayByte
1364
   1319 FFFF1A1A E199                           rol.l   #8,d1
1365
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 23
1366
BOOTROM.x68
1367
   1320 FFFF1A1C 6100 FFE4                      bsr             DisplayByte
1368
   1321 FFFF1A20 E199                           rol.l   #8,d1
1369
   1322 FFFF1A22 6100 FFDE                      bsr             DisplayByte
1370
   1323 FFFF1A26 E199                           rol.l   #8,d1
1371
   1324 FFFF1A28 6100 FFD8                      bsr             DisplayByte
1372
   1325 FFFF1A2C 4E75                           rts
1373
 
1374
   1327 FFFF1A2E                             DisplayMem:
1375
   1328 FFFF1A2E 123C 003A                      move.b  #':',d1
1376
   1329 FFFF1A32 4EB9 FFFF 1732                 jsr             DisplayChar
1377
   1330 FFFF1A38 2208                           move.l  a0,d1
1378
   1331 FFFF1A3A 4EB9 FFFF 1A14                 jsr             DisplayWord
1379
   1332 FFFF1A40 7407                           moveq   #7,d2
1380
   1333 FFFF1A42                             dspmem1:
1381
   1334 FFFF1A42 123C 0020                      move.b  #' ',d1
1382
   1335 FFFF1A46 4EB9 FFFF 1732                 jsr             DisplayChar
1383
   1336 FFFF1A4C 1218                           move.b  (a0)+,d1
1384
   1337 FFFF1A4E 4EB9 FFFF 1A02                 jsr             DisplayByte
1385
   1338 FFFF1A54 51CA FFEC                      dbra    d2,dspmem1
1386
   1339 FFFF1A58 4EF9 FFFF 16EC                 jmp             CRLF
1387
 
1388
                                             ;==============================================================================
1389
                                             ; Monitor
1390
                                             ;==============================================================================
1391
                                             ;
1392
   1345 FFFF1A5E                             StartMon:
1393
   1346 FFFF1A5E 4E55 FFE8                      LINK    A5,#-PSIZ       ;RESERVE SPACE ON STACK FOR INPUT COMMAND LINE;
1394
   1347 FFFF1A62 41ED FFFA                       lea.l   -MLFLAG(A5),A0
1395
   1348 FFFF1A66 43ED FFFC                      LEA.L   -STATZ(A5),A1
1396
   1349 FFFF1A6A 3B7C 0000 FFFA                 MOVE.W  #EMPTY,-MLFLAG(A5)
1397
   1350 FFFF1A70 3B7C 0002 FFF8                 MOVE.W  #LETTE,-MXLTRS(A5)      ;SETUP FOR "LETTE" LETTERS (WAS 2);
1398
   1351 FFFF1A76 7048                           MOVE.L  #AOS_POSTBOX,D0
1399
   1352 FFFF1A78 4E41                           TRAP    #1                      ;POST MAILBOX;
1400
   1353 FFFF1A7A                             Monitor:
1401
                                             ;  lea             STACK,a7                ; reset the stack pointer
1402
   1355 FFFF1A7A 4278 041C                      clr.w   KeybdEcho               ; turn off keyboard echo
1403
   1356 FFFF1A7E                             PromptLn:
1404
   1357 FFFF1A7E 6100 FC6C                      bsr             CRLF
1405
   1358 FFFF1A82 123C 0024                      move.b  #'$',d1
1406
   1359 FFFF1A86 6100 FCAA                      bsr             DisplayChar
1407
 
1408
                                             ; Get characters until a CR is keyed
1409
                                             ;
1410
   1363 FFFF1A8A                             Prompt3:
1411
   1364 FFFF1A8A 6100 FBCC                      bsr             GetKey
1412
   1365 FFFF1A8E 0C01 000D                      cmpi.b  #CR,d1
1413
   1366 FFFF1A92 6706                           beq             Prompt1
1414
   1367 FFFF1A94 6100 FC9C                      bsr             DisplayChar
1415
   1368 FFFF1A98 60F0                           bra             Prompt3
1416
 
1417
                                             ; Process the screen line that the CR was keyed on
1418
                                             ;
1419
   1372 FFFF1A9A                             Prompt1:
1420
   1373 FFFF1A9A 4278 041A                      clr.w   CursorCol               ; go back to the start of the line
1421
   1374 FFFF1A9E 6100 FC66                      bsr             CalcScreenLoc   ; a0 = screen memory location
1422
   1375 FFFF1AA2 3218                           move.w  (a0)+,d1
1423
   1376 FFFF1AA4 6100 FF32                      bsr             ScreenToAscii
1424
   1377 FFFF1AA8 0C01 0024                      cmpi.b  #'$',d1                 ; skip over '$' prompt character
1425
   1378 FFFF1AAC 6606                           bne             Prompt2
1426
   1379 FFFF1AAE 3218                           move.w  (a0)+,d1
1427
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 24
1428
BOOTROM.x68
1429
   1380 FFFF1AB0 6100 FF26                      bsr             ScreenToAscii
1430
 
1431
                                             ; Dispatch based on command character
1432
                                             ;
1433
   1384 FFFF1AB4                             Prompt2:
1434
   1385 FFFF1AB4 0C01 003A                      cmpi.b  #':',d1                 ; $: - edit memory
1435
   1386 FFFF1AB8 6700 00FC                      beq             EditMem
1436
   1387 FFFF1ABC 0C01 0044                      cmpi.b  #'D',d1                 ; $D - dump memory
1437
   1388 FFFF1AC0 6700 0162                      beq             DumpMem
1438
   1389 FFFF1AC4 0C01 0042                      cmpi.b  #'B',d1                 ; $B - start tiny basic
1439
   1390 FFFF1AC8 6700 0936                      beq             START
1440
   1391 FFFF1ACC 0C01 004A                      cmpi.b  #'J',d1                 ; $J - execute code
1441
   1392 FFFF1AD0 6700 0142                      beq             ExecuteCode
1442
   1393 FFFF1AD4 0C01 004C                      cmpi.b  #'L',d1                 ; $L - load S19 file
1443
   1394 FFFF1AD8 6700 01EE                      beq             LoadS19
1444
   1395 FFFF1ADC 0C01 003F                      cmpi.b  #'?',d1                 ; $? - display help
1445
   1396 FFFF1AE0 672A                           beq             DisplayHelp
1446
   1397 FFFF1AE2 0C01 0043                      cmpi.b  #'C',d1                 ; $C - clear screen
1447
   1398 FFFF1AE6 6702                           beq             TestCLS
1448
   1399 FFFF1AE8 6090                           bra             Monitor
1449
 
1450
   1401 FFFF1AEA                             TestCLS:
1451
   1402 FFFF1AEA 3218                           move.w  (a0)+,d1
1452
   1403 FFFF1AEC 6100 FEEA                      bsr             ScreenToAscii
1453
   1404 FFFF1AF0 0C01 004C                      cmpi.b  #'L',d1
1454
   1405 FFFF1AF4 6684                           bne             Monitor
1455
   1406 FFFF1AF6 3218                           move.w  (a0)+,d1
1456
   1407 FFFF1AF8 6100 FEDE                      bsr             ScreenToAscii
1457
   1408 FFFF1AFC 0C01 0053                      cmpi.b  #'S',d1
1458
   1409 FFFF1B00 6600 FF78                      bne             Monitor
1459
   1410 FFFF1B04 6100 FDE2                      bsr             ClearScreen
1460
   1411 FFFF1B08 6000 FF70                      bra             Monitor
1461
 
1462
   1413 FFFF1B0C                             DisplayHelp:
1463
   1414 FFFF1B0C 43F9 FFFF 1B1C                 lea             HelpMsg,a1
1464
   1415 FFFF1B12 4EB9 FFFF 1858                 jsr             DisplayString
1465
   1416 FFFF1B18 6000 FF60                      bra             Monitor
1466
 
1467
   1418 FFFF1B1C                             HelpMsg:
1468
   1419 FFFF1B1C 3F 20 3D 20 44 69 73 70        dc.b    "? = Display help",CR,LF
1469
   1420 FFFF1B24 6C 61 79 20 68 65 6C 70
1470
   1421 FFFF1B2C 0D 0A
1471
   1422 FFFF1B2E 43 4C 53 20 3D 20 63 6C        dc.b    "CLS = clear screen",CR,LF
1472
   1423 FFFF1B36 65 61 72 20 73 63 72 65
1473
   1424 FFFF1B3E 65 6E 0D 0A
1474
   1425 FFFF1B42 3A 20 3D 20 45 64 69 74        dc.b    ": = Edit memory bytes",CR,LF
1475
   1426 FFFF1B4A 20 6D 65 6D 6F 72 79 20
1476
   1427 FFFF1B52 62 79 74 65 73 0D 0A
1477
   1428 FFFF1B59 4C 20 3D 20 4C 6F 61 64        dc.b    "L = Load S19 file",CR,LF
1478
   1429 FFFF1B61 20 53 31 39 20 66 69 6C
1479
   1430 FFFF1B69 65 0D 0A
1480
   1431 FFFF1B6C 44 20 3D 20 44 75 6D 70        dc.b    "D = Dump memory",CR,LF
1481
   1432 FFFF1B74 20 6D 65 6D 6F 72 79 0D
1482
   1433 FFFF1B7C 0A
1483
   1434 FFFF1B7D 42 20 3D 20 73 74 61 72        dc.b    "B = start tiny basic",CR,LF
1484
   1435 FFFF1B85 74 20 74 69 6E 79 20 62
1485
   1436 FFFF1B8D 61 73 69 63 0D 0A
1486
   1437 FFFF1B93 4A 20 3D 20 4A 75 6D 70        dc.b    "J = Jump to code",CR,LF,0
1487
   1438 FFFF1B9B 20 74 6F 20 63 6F 64 65
1488
   1439 FFFF1BA3 0D 0A 00
1489
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 25
1490
BOOTROM.x68
1491
                                                even
1492
 
1493
                                             ;------------------------------------------------------------------------------
1494
                                             ;------------------------------------------------------------------------------
1495
                                             ;
1496
   1445 FFFF1BA6                             ignBlanks:
1497
   1446 FFFF1BA6 3218                           move.w  (a0)+,d1
1498
   1447 FFFF1BA8 6100 FE2E                      bsr             ScreenToAscii
1499
   1448 FFFF1BAC 0C01 0020                      cmpi.b  #' ',d1
1500
   1449 FFFF1BB0 67F4                           beq             ignBlanks
1501
   1450 FFFF1BB2 5588                           subq    #2,a0
1502
   1451 FFFF1BB4 4E75                           rts
1503
 
1504
                                             ;------------------------------------------------------------------------------
1505
                                             ; Edit memory byte.
1506
                                             ;------------------------------------------------------------------------------
1507
                                             ;
1508
   1457 FFFF1BB6                             EditMem:
1509
   1458 FFFF1BB6 6100 FFEE                      bsr             ignBlanks
1510
   1459 FFFF1BBA 6100 009C                      bsr             GetHexNumber
1511
   1460 FFFF1BBE 2241                           move.l  d1,a1
1512
   1461 FFFF1BC0                             edtmem1:
1513
   1462 FFFF1BC0 6100 FFE4                      bsr             ignBlanks
1514
   1463 FFFF1BC4 6100 0092                      bsr             GetHexNumber
1515
   1464 FFFF1BC8 12C1                           move.b  d1,(a1)+
1516
   1465 FFFF1BCA 6100 FFDA                      bsr             ignBlanks
1517
   1466 FFFF1BCE 6100 0088                      bsr             GetHexNumber
1518
   1467 FFFF1BD2 12C1                           move.b  d1,(a1)+
1519
   1468 FFFF1BD4 6100 FFD0                      bsr             ignBlanks
1520
   1469 FFFF1BD8 6100 007E                      bsr             GetHexNumber
1521
   1470 FFFF1BDC 12C1                           move.b  d1,(a1)+
1522
   1471 FFFF1BDE 6100 FFC6                      bsr             ignBlanks
1523
   1472 FFFF1BE2 6100 0074                      bsr             GetHexNumber
1524
   1473 FFFF1BE6 12C1                           move.b  d1,(a1)+
1525
   1474 FFFF1BE8 6100 FFBC                      bsr             ignBlanks
1526
   1475 FFFF1BEC 6100 006A                      bsr             GetHexNumber
1527
   1476 FFFF1BF0 12C1                           move.b  d1,(a1)+
1528
   1477 FFFF1BF2 6100 FFB2                      bsr             ignBlanks
1529
   1478 FFFF1BF6 6100 0060                      bsr             GetHexNumber
1530
   1479 FFFF1BFA 12C1                           move.b  d1,(a1)+
1531
   1480 FFFF1BFC 6100 FFA8                      bsr             ignBlanks
1532
   1481 FFFF1C00 6100 0056                      bsr             GetHexNumber
1533
   1482 FFFF1C04 12C1                           move.b  d1,(a1)+
1534
   1483 FFFF1C06 6100 FF9E                      bsr             ignBlanks
1535
   1484 FFFF1C0A 6100 004C                      bsr             GetHexNumber
1536
   1485 FFFF1C0E 12C1                           move.b  d1,(a1)+
1537
   1486 FFFF1C10 6000 FE68                      bra             Monitor
1538
 
1539
                                             ;------------------------------------------------------------------------------
1540
                                             ; Execute code at the specified address.
1541
                                             ;------------------------------------------------------------------------------
1542
                                             ;
1543
   1492 FFFF1C14                             ExecuteCode:
1544
   1493 FFFF1C14 6100 FF90                      bsr             ignBlanks
1545
   1494 FFFF1C18 6100 003E                      bsr             GetHexNumber
1546
   1495 FFFF1C1C 2041                           move.l  d1,a0
1547
   1496 FFFF1C1E 4E90                           jsr             (a0)
1548
   1497 FFFF1C20 6000 FE58                      bra     Monitor
1549
 
1550
                                             ;------------------------------------------------------------------------------
1551
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 26
1552
BOOTROM.x68
1553
                                             ; Do a memory dump of the requested location.
1554
                                             ;------------------------------------------------------------------------------
1555
                                             ;
1556
   1503 FFFF1C24                             DumpMem:
1557
   1504 FFFF1C24 6100 FF80                      bsr             ignBlanks
1558
   1505 FFFF1C28 6100 002E                      bsr             GetHexNumber
1559
   1506 FFFF1C2C 2041                           move.l  d1,a0
1560
   1507 FFFF1C2E 4EB9 FFFF 16EC                 jsr             CRLF
1561
   1508 FFFF1C34 6100 FDF8                      bsr             DisplayMem
1562
   1509 FFFF1C38 6100 FDF4                      bsr             DisplayMem
1563
   1510 FFFF1C3C 6100 FDF0                      bsr             DisplayMem
1564
   1511 FFFF1C40 6100 FDEC                      bsr             DisplayMem
1565
   1512 FFFF1C44 6100 FDE8                      bsr             DisplayMem
1566
   1513 FFFF1C48 6100 FDE4                      bsr             DisplayMem
1567
   1514 FFFF1C4C 6100 FDE0                      bsr             DisplayMem
1568
   1515 FFFF1C50 6100 FDDC                      bsr             DisplayMem
1569
   1516 FFFF1C54 6000 FE24                      bra             Monitor
1570
 
1571
                                             ;------------------------------------------------------------------------------
1572
                                             ; Get a hexidecimal number. Maximum of eight digits.
1573
                                             ;------------------------------------------------------------------------------
1574
                                             ;
1575
   1522 FFFF1C58                             GetHexNumber:
1576
   1523 FFFF1C58 48E7 A000                      movem.l d0/d2,-(a7)
1577
   1524 FFFF1C5C 4282                           clr.l   d2
1578
   1525 FFFF1C5E 7007                           moveq   #7,d0
1579
   1526 FFFF1C60                             gthxn2:
1580
   1527 FFFF1C60 3218                           move.w  (a0)+,d1
1581
   1528 FFFF1C62 6100 FD74                      bsr             ScreenToAscii
1582
   1529 FFFF1C66 6100 001E                      bsr             AsciiToHexNybble
1583
   1530 FFFF1C6A B23C 00FF                      cmp.b   #0xff,d1
1584
   1531 FFFF1C6E 670E                           beq             gthxn1
1585
   1532 FFFF1C70 E98A                           lsl.l   #4,d2
1586
   1533 FFFF1C72 0281 0000 000F                 andi.l  #0x0f,d1
1587
   1534 FFFF1C78 8481                           or.l    d1,d2
1588
   1535 FFFF1C7A 51C8 FFE4                      dbra    d0,gthxn2
1589
   1536 FFFF1C7E                             gthxn1:
1590
   1537 FFFF1C7E 2202                           move.l  d2,d1
1591
   1538 FFFF1C80 4CDF 0005                      movem.l (a7)+,d0/d2
1592
   1539 FFFF1C84 4E75                           rts
1593
 
1594
                                             ;------------------------------------------------------------------------------
1595
                                             ; Convert ASCII character in the range '0' to '9', 'a' tr 'f' or 'A' to 'F'
1596
                                             ; to a hex nybble.
1597
                                             ;------------------------------------------------------------------------------
1598
                                             ;
1599
   1546 FFFF1C86                             AsciiToHexNybble:
1600
   1547 FFFF1C86 0C01 0030                      cmpi.b  #'0',d1
1601
   1548 FFFF1C8A 6538                           blo             gthx3
1602
   1549 FFFF1C8C 0C01 0039                      cmpi.b  #'9',d1
1603
   1550 FFFF1C90 6206                           bhi             gthx5
1604
   1551 FFFF1C92 0401 0030                      subi.b  #'0',d1
1605
   1552 FFFF1C96 4E75                           rts
1606
   1553 FFFF1C98                             gthx5:
1607
   1554 FFFF1C98 0C01 0041                      cmpi.b  #'A',d1
1608
   1555 FFFF1C9C 6526                           blo             gthx3
1609
   1556 FFFF1C9E 0C01 0046                      cmpi.b  #'F',d1
1610
   1557 FFFF1CA2 620A                           bhi             gthx6
1611
   1558 FFFF1CA4 0401 0041                      subi.b  #'A',d1
1612
   1559 FFFF1CA8 0601 000A                      addi.b  #10,d1
1613
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 27
1614
BOOTROM.x68
1615
   1560 FFFF1CAC 4E75                           rts
1616
   1561 FFFF1CAE                             gthx6:
1617
   1562 FFFF1CAE 0C01 0061                      cmpi.b  #'a',d1
1618
   1563 FFFF1CB2 6510                           blo             gthx3
1619
   1564 FFFF1CB4 0C01 0066                      cmpi.b  #'f',d1
1620
   1565 FFFF1CB8 620A                           bhi             gthx3
1621
   1566 FFFF1CBA 0401 0061                      subi.b  #'a',d1
1622
   1567 FFFF1CBE 0601 000A                      addi.b  #10,d1
1623
   1568 FFFF1CC2 4E75                           rts
1624
   1569 FFFF1CC4                             gthx3:
1625
   1570 FFFF1CC4 72FF                           moveq   #-1,d1          ; not a hex number
1626
   1571 FFFF1CC6 4E75                           rts
1627
 
1628
                                             ;==============================================================================
1629
                                             ; Load an S19 format file
1630
                                             ;==============================================================================
1631
                                             ;
1632
   1577 FFFF1CC8                             LoadS19:
1633
   1578 FFFF1CC8 600A                           bra             ProcessRec
1634
   1579 FFFF1CCA                             NextRec:
1635
   1580 FFFF1CCA 6100 0174                      bsr             sGetChar
1636
   1581 FFFF1CCE 0C00 000A                      cmpi.b  #LF,d0
1637
   1582 FFFF1CD2 66F6                           bne             NextRec
1638
   1583 FFFF1CD4                             ProcessRec
1639
   1584 FFFF1CD4 6100 016A                      bsr             sGetChar
1640
   1585 FFFF1CD8 1800                           move.b  d0,d4
1641
   1586 FFFF1CDA 0C04 001A                      cmpi.b  #26,d4          ; CTRL-Z ?
1642
   1587 FFFF1CDE 6700 FD9A                      beq             Monitor
1643
   1588 FFFF1CE2 0C04 0053                      cmpi.b  #'S',d4
1644
   1589 FFFF1CE6 66E2                           bne             NextRec
1645
   1590 FFFF1CE8 6100 0156                      bsr             sGetChar
1646
   1591 FFFF1CEC 1800                           move.b  d0,d4
1647
   1592 FFFF1CEE 0C04 0030                      cmpi.b  #'0',d4
1648
   1593 FFFF1CF2 65D6                           blo             NextRec
1649
   1594 FFFF1CF4 0C04 0039                      cmpi.b  #'9',d4         ; d4 = record type
1650
   1595 FFFF1CF8 62D0                           bhi             NextRec
1651
   1596 FFFF1CFA 6100 0144                      bsr             sGetChar
1652
   1597 FFFF1CFE 6100 FF86                      bsr             AsciiToHexNybble
1653
   1598 FFFF1D02 1401                           move.b  d1,d2
1654
   1599 FFFF1D04 6100 013A                      bsr             sGetChar
1655
   1600 FFFF1D08 6100 FF7C                      bsr             AsciiToHexNybble
1656
   1601 FFFF1D0C E90A                           lsl.b   #4,d2
1657
   1602 FFFF1D0E 8202                           or.b    d2,d1           ; d1 = byte count
1658
   1603 FFFF1D10 1601                           move.b  d1,d3           ; d3 = byte count
1659
   1604 FFFF1D12 0C04 0030                      cmpi.b  #'0',d4         ; manufacturer ID record, ignore
1660
   1605 FFFF1D16 67B2                           beq             NextRec
1661
   1606 FFFF1D18 0C04 0031                      cmpi.b  #'1',d4
1662
   1607 FFFF1D1C 676A                           beq             ProcessS1
1663
   1608 FFFF1D1E 0C04 0032                      cmpi.b  #'2',d4
1664
   1609 FFFF1D22 676A                           beq             ProcessS2
1665
   1610 FFFF1D24 0C04 0033                      cmpi.b  #'3',d4
1666
   1611 FFFF1D28 676A                           beq             ProcessS3
1667
   1612 FFFF1D2A 0C04 0035                      cmpi.b  #'5',d4         ; record count record, ignore
1668
   1613 FFFF1D2E 679A                           beq             NextRec
1669
   1614 FFFF1D30 0C04 0037                      cmpi.b  #'7',d4
1670
   1615 FFFF1D34 6764                           beq             ProcessS7
1671
   1616 FFFF1D36 0C04 0038                      cmpi.b  #'8',d4
1672
   1617 FFFF1D3A 676A                           beq             ProcessS8
1673
   1618 FFFF1D3C 0C04 0039                      cmpi.b  #'9',d4
1674
   1619 FFFF1D40 6770                           beq             ProcessS9
1675
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 28
1676
BOOTROM.x68
1677
   1620 FFFF1D42 6086                           bra             NextRec
1678
 
1679
   1622 FFFF1D44                             pcssxa
1680
   1623 FFFF1D44 0243 00FF                      andi.w  #0xff,d3
1681
   1624 FFFF1D48 5343                           subi.w  #1,d3                   ; one less for dbra
1682
   1625 FFFF1D4A                             pcss1a
1683
   1626 FFFF1D4A 4282                           clr.l   d2
1684
   1627 FFFF1D4C 6100 00F2                      bsr             sGetChar
1685
   1628 FFFF1D50 6100 FF34                      bsr             AsciiToHexNybble
1686
   1629 FFFF1D54 E98A                           lsl.l   #4,d2
1687
   1630 FFFF1D56 8401                           or.b    d1,d2
1688
   1631 FFFF1D58 6100 00E6                      bsr             sGetChar
1689
   1632 FFFF1D5C 6100 FF28                      bsr             AsciiToHexNybble
1690
   1633 FFFF1D60 E98A                           lsl.l   #4,d2
1691
   1634 FFFF1D62 8401                           or.b    d1,d2
1692
   1635 FFFF1D64 12C2                           move.b  d2,(a1)+
1693
   1636 FFFF1D66 51CB FFE2                      dbra    d3,pcss1a
1694
                                             ; Get the checksum byte
1695
   1638 FFFF1D6A 4282                           clr.l   d2
1696
   1639 FFFF1D6C 6100 00D2                      bsr             sGetChar
1697
   1640 FFFF1D70 6100 FF14                      bsr             AsciiToHexNybble
1698
   1641 FFFF1D74 E98A                           lsl.l   #4,d2
1699
   1642 FFFF1D76 8401                           or.b    d1,d2
1700
   1643 FFFF1D78 6100 00C6                      bsr             sGetChar
1701
   1644 FFFF1D7C 6100 FF08                      bsr             AsciiToHexNybble
1702
   1645 FFFF1D80 E98A                           lsl.l   #4,d2
1703
   1646 FFFF1D82 8401                           or.b    d1,d2
1704
   1647 FFFF1D84 6000 FF44                      bra             NextRec
1705
 
1706
   1649 FFFF1D88                             ProcessS1:
1707
   1650 FFFF1D88 6100 0034                      bsr             S19Get16BitAddress
1708
   1651 FFFF1D8C 60B6                           bra             pcssxa
1709
   1652 FFFF1D8E                             ProcessS2:
1710
   1653 FFFF1D8E 6100 003C                      bsr             S19Get24BitAddress
1711
   1654 FFFF1D92 60B0                           bra             pcssxa
1712
   1655 FFFF1D94                             ProcessS3:
1713
   1656 FFFF1D94 6100 0044                      bsr             S19Get32BitAddress
1714
   1657 FFFF1D98 60AA                           bra             pcssxa
1715
   1658 FFFF1D9A                             ProcessS7:
1716
   1659 FFFF1D9A 6100 003E                      bsr             S19Get32BitAddress
1717
   1660 FFFF1D9E 21C9 0800                      move.l  a1,S19StartAddress
1718
   1661 FFFF1DA2 6000 FCD6                      bra             Monitor
1719
   1662 FFFF1DA6                             ProcessS8:
1720
   1663 FFFF1DA6 6100 0024                      bsr             S19Get24BitAddress
1721
   1664 FFFF1DAA 21C9 0800                      move.l  a1,S19StartAddress
1722
   1665 FFFF1DAE 6000 FCCA                      bra             Monitor
1723
   1666 FFFF1DB2                             ProcessS9:
1724
   1667 FFFF1DB2 6100 000A                      bsr             S19Get16BitAddress
1725
   1668 FFFF1DB6 21C9 0800                      move.l  a1,S19StartAddress
1726
   1669 FFFF1DBA 6000 FCBE                      bra             Monitor
1727
 
1728
   1671 FFFF1DBE                             S19Get16BitAddress:
1729
   1672 FFFF1DBE 4282                           clr.l   d2
1730
   1673 FFFF1DC0 6100 007E                      bsr             sGetChar
1731
   1674 FFFF1DC4 6100 FEC0                      bsr             AsciiToHexNybble
1732
   1675 FFFF1DC8 1401                           move.b  d1,d2
1733
   1676 FFFF1DCA 604A                           bra             S1932b
1734
 
1735
   1678 FFFF1DCC                             S19Get24BitAddress:
1736
   1679 FFFF1DCC 4282                           clr.l   d2
1737
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 29
1738
BOOTROM.x68
1739
   1680 FFFF1DCE 6100 0070                      bsr             sGetChar
1740
   1681 FFFF1DD2 6100 FEB2                      bsr             AsciiToHexNybble
1741
   1682 FFFF1DD6 1401                           move.b  d1,d2
1742
   1683 FFFF1DD8 6024                           bra             S1932a
1743
 
1744
   1685 FFFF1DDA                             S19Get32BitAddress:
1745
   1686 FFFF1DDA 4282                           clr.l   d2
1746
   1687 FFFF1DDC 6100 0062                      bsr             sGetChar
1747
   1688 FFFF1DE0 6100 FEA4                      bsr             AsciiToHexNybble
1748
   1689 FFFF1DE4 1401                           move.b  d1,d2
1749
   1690 FFFF1DE6 6100 0058                      bsr             sGetChar
1750
   1691 FFFF1DEA 6100 FE9A                      bsr             AsciiToHexNybble
1751
   1692 FFFF1DEE E98A                           lsl.l   #4,d2
1752
   1693 FFFF1DF0 8401                           or.b    d1,d2
1753
   1694 FFFF1DF2 6100 004C                      bsr             sGetChar
1754
   1695 FFFF1DF6 6100 FE8E                      bsr             AsciiToHexNybble
1755
   1696 FFFF1DFA E98A                           lsl.l   #4,d2
1756
   1697 FFFF1DFC 8401                           or.b    d1,d2
1757
   1698 FFFF1DFE                             S1932a:
1758
   1699 FFFF1DFE 6100 0040                      bsr             sGetChar
1759
   1700 FFFF1E02 6100 FE82                      bsr             AsciiToHexNybble
1760
   1701 FFFF1E06 E98A                           lsl.l   #4,d2
1761
   1702 FFFF1E08 8401                           or.b    d1,d2
1762
   1703 FFFF1E0A 6100 0034                      bsr             sGetChar
1763
   1704 FFFF1E0E 6100 FE76                      bsr             AsciiToHexNybble
1764
   1705 FFFF1E12 E98A                           lsl.l   #4,d2
1765
   1706 FFFF1E14 8401                           or.b    d1,d2
1766
   1707 FFFF1E16                             S1932b:
1767
   1708 FFFF1E16 6100 0028                      bsr             sGetChar
1768
   1709 FFFF1E1A 6100 FE6A                      bsr             AsciiToHexNybble
1769
   1710 FFFF1E1E E98A                           lsl.l   #4,d2
1770
   1711 FFFF1E20 8401                           or.b    d1,d2
1771
   1712 FFFF1E22 6100 001C                      bsr             sGetChar
1772
   1713 FFFF1E26 6100 FE5E                      bsr             AsciiToHexNybble
1773
   1714 FFFF1E2A E98A                           lsl.l   #4,d2
1774
   1715 FFFF1E2C 8401                           or.b    d1,d2
1775
   1716 FFFF1E2E 6100 0010                      bsr             sGetChar
1776
   1717 FFFF1E32 6100 FE52                      bsr             AsciiToHexNybble
1777
   1718 FFFF1E36 E98A                           lsl.l   #4,d2
1778
   1719 FFFF1E38 8401                           or.b    d1,d2
1779
   1720 FFFF1E3A 4284                           clr.l   d4
1780
   1721 FFFF1E3C 2242                           move.l  d2,a1
1781
   1722 FFFF1E3E 4E75                           rts
1782
 
1783
                                             ;------------------------------------------------------------------------------
1784
                                             ; Get a character from auxillary input, checking the keyboard status for a
1785
                                             ; CTRL-C
1786
                                             ;------------------------------------------------------------------------------
1787
                                             ;
1788
   1729 FFFF1E40                             sGetChar:
1789
   1730 FFFF1E40 6100 F898                      bsr             CheckForKey
1790
   1731 FFFF1E44 670C                           beq             sgc1
1791
   1732 FFFF1E46 6100 F810                      bsr             GetKey
1792
   1733 FFFF1E4A 0C01 0003                      cmpi.b  #CTRLC,d1
1793
   1734 FFFF1E4E 6700 FC2A                      beq             Monitor
1794
   1735 FFFF1E52                             sgc1:
1795
   1736 FFFF1E52 6100 1288                      bsr             AUXIN
1796
   1737 FFFF1E56 67E8                           beq             sGetChar
1797
   1738 FFFF1E58 1200                           move.b  d0,d1
1798
   1739 FFFF1E5A 4E75                           rts
1799
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 30
1800
BOOTROM.x68
1801
 
1802
                                             ;==============================================================================
1803
                                             ;==============================================================================
1804
 
1805
                                             ;------------------------------------------------------------------------------
1806
                                             ; Sound a tone for a second.
1807
                                             ;------------------------------------------------------------------------------
1808
                                             ;
1809
   1748 FFFF1E5C                             Beep:
1810
   1749 FFFF1E5C 33FC 000F FFD4 0040            move.w  #15,PSG_MASTVOL                 ; set master volume
1811
   1750 FFFF1E64 33FC 411B FFD4 0000            move.w  #16667,PSG_FREQUENCY0   ; 1000 Hz
1812
   1751 FFFF1E6C 4279 FFD4 0002                 clr.w   PSG_PULSEWIDTH0                 ; not used
1813
   1752 FFFF1E72 4279 FFD4 0008                 clr.w   PSG_ATTACK0                             ; zero attack time
1814
   1753 FFFF1E78 4279 FFD4 000A                 clr.w   PSG_DECAY0                              ; zero decay time
1815
   1754 FFFF1E7E 33FC 00FF FFD4 000C            move.w  #255,PSG_SUSTAIN0               ; max sustain level
1816
   1755 FFFF1E86 4279 FFD4 000E                 clr.w   PSG_RELEASE0                    ; zero release time
1817
   1756 FFFF1E8C 33FC 1104 FFD4 0004            move.w  #0x1104,PSG_CTRL0               ; gate on, output enabled, triangle waveform
1818
 
1819
   1758 FFFF1E94 203C 007A 1200                 move.l  #8000000,d0                     ; delay a couple of seconds
1820
   1759 FFFF1E9A                             Beep1:
1821
   1760 FFFF1E9A 5380                           sub.l   #1,d0
1822
   1761 FFFF1E9C 66FC                           bne             Beep1
1823
   1762 FFFF1E9E 4279 FFD4 0004                 clr.w   PSG_CTRL0                               ; shut off the tone
1824
   1763 FFFF1EA4 33FC 0000 FFD4 0040            move.w  #0,PSG_MASTVOL
1825
   1764 FFFF1EAC 4E75                           rts
1826
 
1827
                                             ;------------------------------------------------------------------------------
1828
                                             ;------------------------------------------------------------------------------
1829
                                             ;
1830
   1769 FFFF1EAE                             ReadTemp:
1831
   1770 FFFF1EAE 303C 5151                      move.w  #0x5151,d0              ; start conversion command
1832
   1771 FFFF1EB2 33C0 FFDC 0300                 move.w  d0,TMPPMOD              ;
1833
   1772 FFFF1EB8                             rdtmp1:
1834
   1773 FFFF1EB8 0839 0007 FFDC 0303            btst    #7,TMPPMOD+3    ; is transfer done ?
1835
   1774 FFFF1EC0 66F6                           bne             rdtmp1
1836
 
1837
                                             ;  clr.l   d0
1838
                                             ;  move.l  d0,-(a7)                ; create a space for error code
1839
                                             ;  lea             (a7),a1
1840
                                             ;  move.l  #1000,d1                ; delay 1000 ms (1 s)
1841
                                             ;  move.l  #AOS_DELAY,d0
1842
                                             ;  trap    #1
1843
                                             ;  move.l  (a7)+,d0                ; pop error code
1844
 
1845
                                                ; delay 1 second
1846
   1785 FFFF1EC2 203C 007A 1200                 move.l  #8000000,d0
1847
   1786 FFFF1EC8                             rdtmp2:
1848
   1787 FFFF1EC8 5380                           subi.l  #1,d0
1849
   1788 FFFF1ECA 66FC                           bne             rdtmp2
1850
 
1851
   1790 FFFF1ECC 303C ACAC                      move.w  #0xACAC,d0              ; read config reg
1852
   1791 FFFF1ED0 33C0 FFDC 0300                 move.w  d0,TMPPMOD
1853
   1792 FFFF1ED6                             rdtmp4:
1854
   1793 FFFF1ED6 0839 0007 FFDC 0303            btst    #7,TMPPMOD+3
1855
   1794 FFFF1EDE 66F6                           bne             rdtmp4
1856
   1795 FFFF1EE0 3039 FFDC 0302                 move.w  TMPPMOD+2,d0
1857
   1796 FFFF1EE6 4840                           swap    d0
1858
 
1859
   1798 FFFF1EE8 303C AAAA                      move.w  #0xAAAA,d0              ; issue read temp command
1860
   1799 FFFF1EEC 33C0 FFDC 0300                 move.w  d0,TMPPMOD
1861
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 31
1862
BOOTROM.x68
1863
   1800 FFFF1EF2                             rdtmp3:
1864
   1801 FFFF1EF2 0839 0007 FFDC 0303            btst    #7,TMPPMOD+3    ; is transfer done ?
1865
   1802 FFFF1EFA 66F6                           bne             rdtmp3
1866
   1803 FFFF1EFC 3039 FFDC 0302                 move.w  TMPPMOD+2,d0    ; read the temp
1867
   1804 FFFF1F02 4E75                           rts
1868
 
1869
 
1870
   1807 FFFF1F04                             DisplayDecNumber:
1871
   1808 FFFF1F04 48E7 C044                      movem.l d0/d1/a1/a5,-(a7)
1872
   1809 FFFF1F08 2A7C 0000 0700                 move.l  #scratch1,a5
1873
   1810 FFFF1F0E 2001                           move.l  d1,d0
1874
   1811 FFFF1F10 6100 122C                      bsr             HEX2DEC
1875
   1812 FFFF1F14 227C 0000 0700                 move.l  #scratch1,a1
1876
   1813 FFFF1F1A 6100 F93C                      bsr     DisplayString
1877
   1814 FFFF1F1E 4CDF 2203                      movem.l (a7)+,d0/d1/a1/a5
1878
   1815 FFFF1F22 4E75                           rts
1879
 
1880
                                             ;------------------------------------------------------------------------------
1881
                                             ;------------------------------------------------------------------------------
1882
                                             ;
1883
   1820 FFFF1F24                             DisplayHexNumber:
1884
   1821 FFFF1F24 48E7 B000                      movem.l d0/d2/d3,-(a7)
1885
   1822 FFFF1F28 343C 0007                      move.w  #7,d2           ; number-1 of digits to display
1886
   1823 FFFF1F2C                             disphnum1:
1887
   1824 FFFF1F2C 1001                           move.b  d1,d0           ; get digit into d0.b
1888
   1825 FFFF1F2E 0240 000F                      andi.w  #0x0f,d0
1889
   1826 FFFF1F32 0C40 0009                      cmpi.w  #0x09,d0
1890
   1827 FFFF1F36 6302                           bls             disphnum2
1891
   1828 FFFF1F38 5E40                           addi.w  #0x7,d0
1892
   1829 FFFF1F3A                             disphnum2:
1893
   1830 FFFF1F3A 0640 0130                      addi.w  #0x130,d0       ; convert to display char
1894
   1831 FFFF1F3E 3602                           move.w  d2,d3           ; char count into d3
1895
   1832 FFFF1F40 E343                           asl.w   #1,d3           ; scale * 2
1896
   1833 FFFF1F42 3380 3000                      move.w  d0,(a1,d3.w)
1897
   1834 FFFF1F46 E899                           ror.l   #4,d1           ; rot to next digit
1898
   1835 FFFF1F48 57CA FFE2                      dbeq    d2,disphnum1
1899
   1836 FFFF1F4C 4CDF 000D                      movem.l (a7)+,d0/d2/d3
1900
   1837 FFFF1F50 4E75                           rts
1901
 
1902
                                             ;===============================================================================
1903
                                             ;    Perform ram test. (Uses checkerboard testing).
1904
                                             ;
1905
                                             ;    Return address must be stored in a3 since the stack cannot be used (it
1906
                                             ; would get overwritten in test). Note this routine uses no ram at all.
1907
                                             ;===============================================================================
1908
   1845 FFFF1F52                             ramtest:
1909
   1846 FFFF1F52 207C 0000 0008                      movea.l #8,a0
1910
   1847 FFFF1F58 203C AAAA 5555                      move.l #0xaaaa5555,d0
1911
                                             ;-----------------------------------------------------------
1912
                                             ;   Write checkerboard pattern to ram then read it back to
1913
                                             ; find the highest usable ram address (maybe). This address
1914
                                             ; must be lower than the start of the rom (0xe00000).
1915
                                             ;-----------------------------------------------------------
1916
   1853 FFFF1F5E 43F9 FFD0 0014                      lea                TEXTSCR+20,a1
1917
   1854 FFFF1F64                             ramtest1:
1918
   1855 FFFF1F64 2080                                move.l     d0,(a0)
1919
   1856 FFFF1F66 B098                                cmp.l      (a0)+,d0
1920
   1857 FFFF1F68 6614                                bne.s      ramtest6
1921
   1858 FFFF1F6A 2208                                move.l     a0,d1
1922
   1859 FFFF1F6C 4A41                                tst.w      d1
1923
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 32
1924
BOOTROM.x68
1925
   1860 FFFF1F6E 6606                                bne                rmtst1
1926
   1861 FFFF1F70 4EB9 FFFF 1F24                      jsr                DisplayHexNumber
1927
   1862 FFFF1F76                             rmtst1:
1928
   1863 FFFF1F76 B1FC 00FF FFFC                      cmpa.l     #0xFFFFFC,a0
1929
   1864 FFFF1F7C 65E6                                blo.s      ramtest1
1930
                                             ;------------------------------------------------------
1931
                                             ;   Save maximum useable address for later comparison.
1932
                                             ;------------------------------------------------------
1933
   1868 FFFF1F7E                             ramtest6:
1934
   1869 FFFF1F7E 2448                                movea.l a0,a2
1935
   1870 FFFF1F80 207C 0000 0008                      movea.l #8,a0
1936
                                             ;--------------------------------------------
1937
                                             ;   Read back checkerboard pattern from ram.
1938
                                             ;--------------------------------------------
1939
   1874 FFFF1F86                             ramtest2:
1940
   1875 FFFF1F86 2018                                move.l (a0)+,d0
1941
   1876 FFFF1F88 2208                                move.l     a0,d1
1942
   1877 FFFF1F8A 4A41                                tst.w      d1
1943
   1878 FFFF1F8C 6606                                bne                rmtst2
1944
   1879 FFFF1F8E 4EB9 FFFF 1F24                      jsr                DisplayHexNumber
1945
   1880 FFFF1F94                             rmtst2:
1946
   1881 FFFF1F94 0C80 AAAA 5555                      cmpi.l     #0xaaaa5555,d0
1947
   1882 FFFF1F9A 67EA                                beq.s      ramtest2
1948
                                             ;---------------------------------------
1949
                                             ;   Check for matching maximum address.
1950
                                             ;---------------------------------------
1951
   1886 FFFF1F9C B5C8                                cmpa.l a0,a2
1952
   1887 FFFF1F9E 6668                                bne.s ramtest7
1953
                                             ;---------------------------------------------------
1954
                                             ;   The following section does the same test except
1955
                                             ; with the checkerboard order switched around.
1956
                                             ;---------------------------------------------------
1957
   1892 FFFF1FA0                             ramtest3:
1958
   1893 FFFF1FA0 207C 0000 0008                      movea.l #8,a0
1959
   1894 FFFF1FA6 203C 5555 AAAA                      move.l     #0x5555aaaa,d0
1960
   1895 FFFF1FAC                             ramtest4:
1961
   1896 FFFF1FAC 2080                                move.l     d0,(a0)
1962
   1897 FFFF1FAE B098                                cmp.l      (a0)+,d0
1963
   1898 FFFF1FB0 6614                                bne.s      ramtest8
1964
   1899 FFFF1FB2 2208                                move.l     a0,d1
1965
   1900 FFFF1FB4 4A41                                tst.w      d1
1966
   1901 FFFF1FB6 6606                                bne     rmtst3
1967
   1902 FFFF1FB8 4EB9 FFFF 1F24                      jsr                DisplayHexNumber
1968
   1903 FFFF1FBE                             rmtst3:
1969
   1904 FFFF1FBE B1FC 00FF FFFC                      cmpa.l     #0xFFFFFC,a0
1970
   1905 FFFF1FC4 65E6                                blo.s      ramtest4
1971
   1906 FFFF1FC6                             ramtest8:
1972
   1907 FFFF1FC6 2448                                movea.l a0,a2
1973
   1908 FFFF1FC8 207C 0000 0008                      movea.l #8,a0
1974
   1909 FFFF1FCE                             ramtest5:
1975
   1910 FFFF1FCE 2018                                move.l     (a0)+,d0
1976
   1911 FFFF1FD0 2208                                move.l     a0,d1
1977
   1912 FFFF1FD2 4A41                                tst.w      d1
1978
   1913 FFFF1FD4 6606                                bne                rmtst4
1979
   1914 FFFF1FD6 4EB9 FFFF 1F24                      jsr                DisplayHexNumber
1980
   1915 FFFF1FDC                             rmtst4:
1981
   1916 FFFF1FDC 0C80 5555 AAAA                      cmpi.l     #0x5555aaaa,d0
1982
   1917 FFFF1FE2 67EA                                beq.s      ramtest5
1983
   1918 FFFF1FE4 B5C8                                cmpa.l     a0,a2
1984
   1919 FFFF1FE6 6620                                bne.s      ramtest7
1985
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 33
1986
BOOTROM.x68
1987
                                             ;---------------------------------------------------
1988
                                             ;   Save last ram address in end of memory pointer.
1989
                                             ;---------------------------------------------------
1990
   1923 FFFF1FE8 21C8 0500                           move.l a0,memend
1991
                                             ;-----------------------------------
1992
                                             ;   Create very first memory block.
1993
                                             ;-----------------------------------
1994
   1927 FFFF1FEC 91FC 0000 000C                      suba.l     #12,a0
1995
   1928 FFFF1FF2 21C8 0404                           move.l     a0,0x0404
1996
   1929 FFFF1FF6 21FC 4652 4545 0400                 move.l     #0x46524545,0x0400
1997
   1930 FFFF1FFE 21FC 0000 0408 0408                 move.l     #0x408,0x408                    ; point back-link to self
1998
   1931 FFFF2006 4ED3                                jmp        (a3)
1999
                                             ;----------------------------------
2000
                                             ; Error in ram - go no farther.
2001
                                             ;----------------------------------
2002
   1935 FFFF2008                             ramtest7:
2003
   1936 FFFF2008 4ED3                                   jmp     (a3)
2004
   1937 FFFF200A 60FC                                bra.s      ramtest7
2005
 
2006
   1939 FFFF200C                             AddressError:
2007
   1940 FFFF200C 48E7 F0C0                      movem.l a0/a1/d0/d1/d2/d3,-(a7)
2008
   1941 FFFF2010 43F9 FFFF 204E                 lea             MSG_ADDRESS_ERROR,a1
2009
   1942 FFFF2016 4EB9 FFFF 1858                 jsr             DisplayString
2010
   1943 FFFF201C 4CDF 030F                      movem.l (a7)+,a0/a1/d0/d1/d2/d3
2011
   1944 FFFF2020 4E73                           rte
2012
   1945 FFFF2022                             BusError:
2013
   1946 FFFF2022 48E7 F0C0                      movem.l a0/a1/d0/d1/d2/d3,-(a7)
2014
   1947 FFFF2026 43F9 FFFF 205C                 lea             MSG_BUS_ERROR,a1
2015
   1948 FFFF202C 4EB9 FFFF 1858                 jsr             DisplayString
2016
   1949 FFFF2032 4CDF 030F                      movem.l (a7)+,a0/a1/d0/d1/d2/d3
2017
   1950 FFFF2036 4E73                           rte
2018
   1951 FFFF2038                             IllegalInstruction:
2019
   1952 FFFF2038 48E7 F0C0                      movem.l a0/a1/d0/d1/d2/d3,-(a7)
2020
   1953 FFFF203C 43F9 FFFF 2066                 lea             MSG_ILLEGAL_INSN,a1
2021
   1954 FFFF2042 4EB9 FFFF 1858                 jsr             DisplayString
2022
   1955 FFFF2048 4CDF 030F                      movem.l (a7)+,a0/a1/d0/d1/d2/d3
2023
   1956 FFFF204C 4E73                           rte
2024
 
2025
   1958 FFFF204E                             MSG_ADDRESS_ERROR:
2026
   1959 FFFF204E 41 64 64 72 65 73 73 20        dc.b    "Address error",0
2027
   1960 FFFF2056 65 72 72 6F 72 00
2028
   1961 FFFF205C                             MSG_BUS_ERROR:
2029
   1962 FFFF205C 42 75 73 20 65 72 72 6F        dc.b    "Bus error",0
2030
   1963 FFFF2064 72 00
2031
   1964 FFFF2066                             MSG_ILLEGAL_INSN:
2032
   1965 FFFF2066 49 6C 6C 65 67 61 6C 20        dc.b    "Illegal instruction",0
2033
   1966 FFFF206E 69 6E 73 74 72 75 63 74
2034
   1967 FFFF2076 69 6F 6E 00
2035
   1968 FFFF207A                             MSG_DIVIDE_BY_ZERO:
2036
   1969 FFFF207A 44 69 76 69 64 65 20 62        dc.b    "Divide by zero",0
2037
   1970 FFFF2082 79 20 7A 65 72 6F 00
2038
                                             ;
2039
 
2040
                                             ;*****************************************************************
2041
                                             ;                                                           *
2042
                                             ;          Tiny BASIC for the Motorola MC68000              *
2043
                                             ;                                                           *
2044
                                             ; Derived from Palo Alto Tiny BASIC as published in the May 1976 *
2045
                                             ; issue of Dr. Dobb's Journal.  Adapted to the 68000 by:         *
2046
                                             ;  Gordon Brandly                                           *
2047
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 34
2048
BOOTROM.x68
2049
                                             ;  12147 - 51 Street                                        *
2050
                                             ;  Edmonton AB  T5W 3G8                                     *
2051
                                             ;  Canada                                                   *
2052
                                             ;  (updated mailing address for 1996)                       *
2053
                                             ;                                                           *
2054
                                             ; This version is for MEX68KECB Educational Computer Board I/O.  *
2055
                                             ;                                                           *
2056
                                             ;*****************************************************************
2057
                                             ;    Copyright (C) 1984 by Gordon Brandly. This program may be      *
2058
                                             ;    freely distributed for personal use only. All commercial       *
2059
                                             ;                 rights are reserved.                      *
2060
                                             ;*****************************************************************
2061
 
2062
                                             ; Vers. 1.0  1984/7/17     - Original version by Gordon Brandly
2063
                                             ;  1.1  1984/12/9  - Addition of '$' print term by Marvin Lipford
2064
                                             ;  1.2  1985/4/9   - Bug fix in multiply routine by Rick Murray
2065
 
2066
                                             ;  OPT     FRS,BRS         forward ref.'s & branches default to short
2067
 
2068
                                             BUFLEN     EQU     80      ;       length of keyboard input buffer
2069
 
2070
                                             ;*
2071
                                             ;* Internal variables follow:
2072
                                             ;*
2073
                                                BSS
2074
                                                ORG             0x600
2075
   2006 00000600                             RANPNT:
2076
   2007 00000600                                DC.L    START   ;       random number pointer
2077
   2008 00000604                             CURRNT:
2078
   2009 00000604                                DC.L    1               ;Current line pointer
2079
   2010 00000608                             STKGOS:
2080
   2011 00000608                                DC.L    1               ;Saves stack pointer in 'GOSUB'
2081
   2012 0000060C                             STKINP:
2082
   2013 0000060C                                DC.L    1               ;Saves stack pointer during 'INPUT'
2083
   2014 00000610                             LOPVAR:
2084
   2015 00000610                                DC.L    1               ;'FOR' loop save area
2085
   2016 00000614                             LOPINC:
2086
   2017 00000614                                DC.L    1               ;increment
2087
   2018 00000618                             LOPLMT:
2088
   2019 00000618                                DC.L    1               ;limit
2089
   2020 0000061C                             LOPLN:
2090
   2021 0000061C                                DC.L    1               ;line number
2091
   2022 00000620                             LOPPT:
2092
   2023 00000620                                DC.L    1               ;text pointer
2093
   2024 00000624                             TXTUNF:
2094
   2025 00000624                                DC.L    1               ;points to unfilled text area
2095
   2026 00000628                             VARBGN:
2096
   2027 00000628                                DC.L    1               ;points to variable area
2097
   2028 0000062C                             STKLMT:
2098
   2029 0000062C                                DC.L    1               ;holds lower limit for stack growth
2099
   2030 00000630                             BUFFER:
2100
   2031 00000630                                FILL.B  BUFLEN,0x00     ;       Keyboard input buffer
2101
 
2102
                                             TXT        EQU     $               ;Beginning of program area
2103
 
2104
                                                CODE
2105
   2036 FFFF2089 FF                             even
2106
   2037 FFFF208A FF FF FF FF FF FF FF FF        ORG     0xFFFF2400
2107
   2038 FFFF2092 FF FF FF FF FF FF FF FF
2108
   2039 FFFF209A FF FF FF FF FF FF FF FF
2109
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 35
2110
BOOTROM.x68
2111
   2040 FFFF20A2 FF FF FF FF FF FF FF FF
2112
   2041 FFFF20AA FF FF FF FF FF FF FF FF
2113
   2042 FFFF20B2 FF FF FF FF FF FF FF FF
2114
   2043 FFFF20BA FF FF FF FF FF FF FF FF
2115
   2044 FFFF20C2 FF FF FF FF FF FF FF FF
2116
   2045 FFFF20CA FF FF FF FF FF FF FF FF
2117
   2046 FFFF20D2 FF FF FF FF FF FF FF FF
2118
   2047 FFFF20DA FF FF FF FF FF FF FF FF
2119
   2048 FFFF20E2 FF FF FF FF FF FF FF FF
2120
   2049 FFFF20EA FF FF FF FF FF FF FF FF
2121
   2050 FFFF20F2 FF FF FF FF FF FF FF FF
2122
   2051 FFFF20FA FF FF FF FF FF FF FF FF
2123
   2052 FFFF2102 FF FF FF FF FF FF FF FF
2124
   2053 FFFF210A FF FF FF FF FF FF FF FF
2125
   2054 FFFF2112 FF FF FF FF FF FF FF FF
2126
   2055 FFFF211A FF FF FF FF FF FF FF FF
2127
   2056 FFFF2122 FF FF FF FF FF FF FF FF
2128
   2057 FFFF212A FF FF FF FF FF FF FF FF
2129
   2058 FFFF2132 FF FF FF FF FF FF FF FF
2130
   2059 FFFF213A FF FF FF FF FF FF FF FF
2131
   2060 FFFF2142 FF FF FF FF FF FF FF FF
2132
   2061 FFFF214A FF FF FF FF FF FF FF FF
2133
   2062 FFFF2152 FF FF FF FF FF FF FF FF
2134
   2063 FFFF215A FF FF FF FF FF FF FF FF
2135
   2064 FFFF2162 FF FF FF FF FF FF FF FF
2136
   2065 FFFF216A FF FF FF FF FF FF FF FF
2137
   2066 FFFF2172 FF FF FF FF FF FF FF FF
2138
   2067 FFFF217A FF FF FF FF FF FF FF FF
2139
   2068 FFFF2182 FF FF FF FF FF FF FF FF
2140
   2069 FFFF218A FF FF FF FF FF FF FF FF
2141
   2070 FFFF2192 FF FF FF FF FF FF FF FF
2142
   2071 FFFF219A FF FF FF FF FF FF FF FF
2143
   2072 FFFF21A2 FF FF FF FF FF FF FF FF
2144
   2073 FFFF21AA FF FF FF FF FF FF FF FF
2145
   2074 FFFF21B2 FF FF FF FF FF FF FF FF
2146
   2075 FFFF21BA FF FF FF FF FF FF FF FF
2147
   2076 FFFF21C2 FF FF FF FF FF FF FF FF
2148
   2077 FFFF21CA FF FF FF FF FF FF FF FF
2149
   2078 FFFF21D2 FF FF FF FF FF FF FF FF
2150
   2079 FFFF21DA FF FF FF FF FF FF FF FF
2151
   2080 FFFF21E2 FF FF FF FF FF FF FF FF
2152
   2081 FFFF21EA FF FF FF FF FF FF FF FF
2153
   2082 FFFF21F2 FF FF FF FF FF FF FF FF
2154
   2083 FFFF21FA FF FF FF FF FF FF FF FF
2155
   2084 FFFF2202 FF FF FF FF FF FF FF FF
2156
   2085 FFFF220A FF FF FF FF FF FF FF FF
2157
   2086 FFFF2212 FF FF FF FF FF FF FF FF
2158
   2087 FFFF221A FF FF FF FF FF FF FF FF
2159
   2088 FFFF2222 FF FF FF FF FF FF FF FF
2160
   2089 FFFF222A FF FF FF FF FF FF FF FF
2161
   2090 FFFF2232 FF FF FF FF FF FF FF FF
2162
   2091 FFFF223A FF FF FF FF FF FF FF FF
2163
   2092 FFFF2242 FF FF FF FF FF FF FF FF
2164
   2093 FFFF224A FF FF FF FF FF FF FF FF
2165
   2094 FFFF2252 FF FF FF FF FF FF FF FF
2166
   2095 FFFF225A FF FF FF FF FF FF FF FF
2167
   2096 FFFF2262 FF FF FF FF FF FF FF FF
2168
   2097 FFFF226A FF FF FF FF FF FF FF FF
2169
   2098 FFFF2272 FF FF FF FF FF FF FF FF
2170
   2099 FFFF227A FF FF FF FF FF FF FF FF
2171
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 36
2172
BOOTROM.x68
2173
   2100 FFFF2282 FF FF FF FF FF FF FF FF
2174
   2101 FFFF228A FF FF FF FF FF FF FF FF
2175
   2102 FFFF2292 FF FF FF FF FF FF FF FF
2176
   2103 FFFF229A FF FF FF FF FF FF FF FF
2177
   2104 FFFF22A2 FF FF FF FF FF FF FF FF
2178
   2105 FFFF22AA FF FF FF FF FF FF FF FF
2179
   2106 FFFF22B2 FF FF FF FF FF FF FF FF
2180
   2107 FFFF22BA FF FF FF FF FF FF FF FF
2181
   2108 FFFF22C2 FF FF FF FF FF FF FF FF
2182
   2109 FFFF22CA FF FF FF FF FF FF FF FF
2183
   2110 FFFF22D2 FF FF FF FF FF FF FF FF
2184
   2111 FFFF22DA FF FF FF FF FF FF FF FF
2185
   2112 FFFF22E2 FF FF FF FF FF FF FF FF
2186
   2113 FFFF22EA FF FF FF FF FF FF FF FF
2187
   2114 FFFF22F2 FF FF FF FF FF FF FF FF
2188
   2115 FFFF22FA FF FF FF FF FF FF FF FF
2189
   2116 FFFF2302 FF FF FF FF FF FF FF FF
2190
   2117 FFFF230A FF FF FF FF FF FF FF FF
2191
   2118 FFFF2312 FF FF FF FF FF FF FF FF
2192
   2119 FFFF231A FF FF FF FF FF FF FF FF
2193
   2120 FFFF2322 FF FF FF FF FF FF FF FF
2194
   2121 FFFF232A FF FF FF FF FF FF FF FF
2195
   2122 FFFF2332 FF FF FF FF FF FF FF FF
2196
   2123 FFFF233A FF FF FF FF FF FF FF FF
2197
   2124 FFFF2342 FF FF FF FF FF FF FF FF
2198
   2125 FFFF234A FF FF FF FF FF FF FF FF
2199
   2126 FFFF2352 FF FF FF FF FF FF FF FF
2200
   2127 FFFF235A FF FF FF FF FF FF FF FF
2201
   2128 FFFF2362 FF FF FF FF FF FF FF FF
2202
   2129 FFFF236A FF FF FF FF FF FF FF FF
2203
   2130 FFFF2372 FF FF FF FF FF FF FF FF
2204
   2131 FFFF237A FF FF FF FF FF FF FF FF
2205
   2132 FFFF2382 FF FF FF FF FF FF FF FF
2206
   2133 FFFF238A FF FF FF FF FF FF FF FF
2207
   2134 FFFF2392 FF FF FF FF FF FF FF FF
2208
   2135 FFFF239A FF FF FF FF FF FF FF FF
2209
   2136 FFFF23A2 FF FF FF FF FF FF FF FF
2210
   2137 FFFF23AA FF FF FF FF FF FF FF FF
2211
   2138 FFFF23B2 FF FF FF FF FF FF FF FF
2212
   2139 FFFF23BA FF FF FF FF FF FF FF FF
2213
   2140 FFFF23C2 FF FF FF FF FF FF FF FF
2214
   2141 FFFF23CA FF FF FF FF FF FF FF FF
2215
   2142 FFFF23D2 FF FF FF FF FF FF FF FF
2216
   2143 FFFF23DA FF FF FF FF FF FF FF FF
2217
   2144 FFFF23E2 FF FF FF FF FF FF FF FF
2218
   2145 FFFF23EA FF FF FF FF FF FF FF FF
2219
   2146 FFFF23F2 FF FF FF FF FF FF FF FF
2220
   2147 FFFF23FA FF FF FF FF FF FF
2221
                                             ;*
2222
                                             ;* Standard jump table. You can change these addresses if you are
2223
                                             ;* customizing this interpreter for a different environment.
2224
                                             ;*
2225
   2152 FFFF2400                             START:
2226
   2153 FFFF2400 6000 0022                              BRA.L   CSTART          ;Cold Start entry point
2227
   2154 FFFF2404 6000 005A                   GOWARM:    BRA.L   WSTART          ;Warm Start entry point
2228
   2155 FFFF2408 6000 0C96                   GOOUT:     BRA.L   OUTC            ;Jump to character-out routine
2229
   2156 FFFF240C 6000 0CA4                   GOIN:      BRA.L   INC             ;Jump to character-in routine
2230
   2157 FFFF2410 6000 0CB8                   GOAUXO:    BRA.L   AUXOUT          ;Jump to auxiliary-out routine
2231
   2158 FFFF2414 6000 0CC6                   GOAUXI:    BRA.L   AUXIN           ;Jump to auxiliary-in routine
2232
   2159 FFFF2418 6000 0CD8                   GOBYE:     BRA.L   BYEBYE          ;Jump to monitor, DOS, etc.
2233
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 37
2234
BOOTROM.x68
2235
                                             ;*
2236
                                             ;* Modifiable system constants:
2237
                                             ;*
2238
                                             ; Give Tiny Basic 3MB
2239
   2164 FFFF241C 00C00000                    TXTBGN     DC.L    0xC00000        ;beginning of program memory
2240
   2165 FFFF2420 00F00000                    ENDMEM     DC.L    0xF00000        ;       end of available memory
2241
                                             ;*
2242
                                             ;* The main interpreter starts here:
2243
                                             ;*
2244
   2169 FFFF2424                             CSTART:
2245
                                             ;  LINK    A5,#-PSIZ       ;RESERVE SPACE ON STACK FOR INPUT COMMAND LINE;
2246
                                             ;    lea.l   -MLFLAG(A5),A0
2247
                                             ;  LEA.L   -STATZ(A5),A1
2248
                                             ;  MOVE.W  #EMPTY,-MLFLAG(A5)
2249
                                             ;  MOVE.W  #LETTE,-MXLTRS(A5)      ;SETUP FOR "LETTE" LETTERS (WAS 2);
2250
                                             ;  MOVE.L  #AOS_POSTBOX,D0
2251
                                             ;  TRAP    #1                      ;POST MAILBOX;
2252
 
2253
   2178 FFFF2424 41F9 FFFF 2400                 LEA             START,A0
2254
   2179 FFFF242A 21C8 0600                      MOVE.L  A0,RANPNT
2255
   2180 FFFF242E 2E79 FFFF 2420                 MOVE.L  ENDMEM,SP       ;initialize stack pointer
2256
   2181 FFFF2434 4DF9 FFFF 30F8                 LEA             INITMSG,A6      ;tell who we are
2257
   2182 FFFF243A 6100 0C58                      BSR.L   PRMESG
2258
   2183 FFFF243E 21F9 FFFF 241C 0624            MOVE.L  TXTBGN,TXTUNF   ;init. end-of-program pointer
2259
   2184 FFFF2446 2039 FFFF 2420                 MOVE.L  ENDMEM,D0       ;get address of end of memory
2260
   2185 FFFF244C 0480 0000 0800                 SUB.L   #2048,D0        ;reserve 2K for the stack
2261
   2186 FFFF2452 21C0 062C                      MOVE.L  D0,STKLMT
2262
   2187 FFFF2456 0480 0000 1008                 SUB.L   #4104,D0        ;reserve variable area (27 long words)
2263
   2188 FFFF245C 21C0 0628                      MOVE.L  D0,VARBGN
2264
   2189 FFFF2460                             WSTART:
2265
   2190 FFFF2460 4280                           CLR.L   D0              ;initialize internal variables
2266
   2191 FFFF2462 21C0 0610                      MOVE.L  D0,LOPVAR
2267
   2192 FFFF2466 21C0 0608                      MOVE.L  D0,STKGOS
2268
   2193 FFFF246A 21C0 0604                      MOVE.L  D0,CURRNT       ;current line number pointer = 0
2269
   2194 FFFF246E 2E79 FFFF 2420                 MOVE.L  ENDMEM,SP       ;init S.P. again, just in case
2270
   2195 FFFF2474 4DF9 FFFF 311E                 LEA     OKMSG,A6        ;display "OK"
2271
   2196 FFFF247A 6100 0C18                      BSR.L   PRMESG
2272
   2197 FFFF247E                             ST3:
2273
   2198 FFFF247E 103C 003E                      MOVE.B  #'>',D0  ;       Monitor with a '>' and
2274
   2199 FFFF2482 6100 0976                      BSR.L   GETLN   ;       read a line.
2275
   2200 FFFF2486 6100 0BA8                      BSR.L   TOUPBUF ;       convert to upper case
2276
   2201 FFFF248A 2848                           MOVE.L  A0,A4   ;       save pointer to end of line
2277
   2202 FFFF248C 41F8 0630                      LEA     BUFFER,A0       ;point to the beginning of line
2278
   2203 FFFF2490 6100 0B5A                      BSR.L   TSTNUM  ;       is there a number there?
2279
   2204 FFFF2494 6100 0B8E                      BSR.L   IGNBLK  ;       skip trailing blanks
2280
   2205 FFFF2498 4A81                           TST     D1              ;does line no. exist? (or nonzero?)
2281
   2206 FFFF249A 6700 0152                      BEQ.L   DIRECT  ;       if not, it's a direct statement
2282
   2207 FFFF249E B2BC 0000 FFFF                 CMP.L   #0xFFFF,D1      ;see if line no. is <= 16 bits
2283
   2208 FFFF24A4 6400 094A                      BCC.L   QHOW            ;if not, we've overflowed
2284
   2209 FFFF24A8 1101                           MOVE.B  D1,-(A0)        ;store the binary line no.
2285
   2210 FFFF24AA E099                           ROR     #8,D1           ;(Kludge to store a word on a
2286
   2211 FFFF24AC 1101                           MOVE.B  D1,-(A0)        ;possible byte boundary)
2287
   2212 FFFF24AE E199                           ROL     #8,D1
2288
   2213 FFFF24B0 6100 09E8                      BSR.L   FNDLN   ;       find this line in save area
2289
   2214 FFFF24B4 2A49                           MOVE.L  A1,A5   ;       save possible line pointer
2290
   2215 FFFF24B6 6612                           BNE     ST4                             ;       if not found, insert
2291
   2216 FFFF24B8 6100 0A08                      BSR.L   FNDNXT          ;find the next line (into A1)
2292
   2217 FFFF24BC 244D                           MOVE.L  A5,A2           ;pointer to line to be deleted
2293
   2218 FFFF24BE 2678 0624                      MOVE.L  TXTUNF,A3       ;points to top of save area
2294
   2219 FFFF24C2 6100 0A08                      BSR.L   MVUP            ;move up to delete
2295
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 38
2296
BOOTROM.x68
2297
   2220 FFFF24C6 21CA 0624                      MOVE.L  A2,TXTUNF       ;update the end pointer
2298
   2221 FFFF24CA                             ST4:
2299
   2222 FFFF24CA 200C                           MOVE.L  A4,D0           ;calculate the length of new line
2300
   2223 FFFF24CC 9088                           SUB.L   A0,D0
2301
   2224 FFFF24CE B0BC 0000 0003                 CMP.L   #3,D0           ;is it just a line no. & CR?
2302
   2225 FFFF24D4 67A8                           BEQ     ST3                             ;if so, it was just a delete
2303
   2226 FFFF24D6 2678 0624                      MOVE.L  TXTUNF,A3       ;compute new end
2304
   2227 FFFF24DA 2C4B                           MOVE.L  A3,A6
2305
   2228 FFFF24DC D7C0                           ADD.L   D0,A3
2306
   2229 FFFF24DE 2038 0628                      MOVE.L  VARBGN,D0       ;see if there's enough room
2307
   2230 FFFF24E2 B08B                           CMP.L   A3,D0
2308
   2231 FFFF24E4 6300 0900                      BLS.L   QSORRY          ;if not, say so
2309
   2232 FFFF24E8 21CB 0624                      MOVE.L  A3,TXTUNF       ;if so, store new end position
2310
   2233 FFFF24EC 224E                           MOVE.L  A6,A1           ;points to old unfilled area
2311
   2234 FFFF24EE 244D                           MOVE.L  A5,A2           ;points to beginning of move area
2312
   2235 FFFF24F0 6100 09E4                      BSR.L   MVDOWN          ;move things out of the way
2313
   2236 FFFF24F4 2248                           MOVE.L  A0,A1           ;set up to do the insertion
2314
   2237 FFFF24F6 244D                           MOVE.L  A5,A2
2315
   2238 FFFF24F8 264C                           MOVE.L  A4,A3
2316
   2239 FFFF24FA 6100 09D0                      BSR.L   MVUP            ;do it
2317
   2240 FFFF24FE 6000 FF7E                      BRA     ST3             ;go back and get another line
2318
 
2319
                                             ;*
2320
                                             ;*******************************************************************
2321
                                             ;*
2322
                                             ;* *** Tables *** DIRECT *** EXEC ***
2323
                                             ;*
2324
                                             ;* This section of the code tests a string against a table. When
2325
                                             ;* a match is found, control is transferred to the section of
2326
                                             ;* code according to the table.
2327
                                             ;*
2328
                                             ;* At 'EXEC', A0 should point to the string, A1 should point to
2329
                                             ;* the character table, and A2 should point to the execution
2330
                                             ;* table. At 'DIRECT', A0 should point to the string, A1 and
2331
                                             ;* A2 will be set up to point to TAB1 and TAB1.1, which are
2332
                                             ;* the tables of all direct and statement commands.
2333
                                             ;*
2334
                                             ;* A '.' in the string will terminate the test and the partial
2335
                                             ;* match will be considered as a match, e.g. 'P.', 'PR.','PRI.',
2336
                                             ;* 'PRIN.', or 'PRINT' will all match 'PRINT'.
2337
                                             ;*
2338
                                             ;* There are two tables: the character table and the execution
2339
                                             ;* table. The character table consists of any number of text items.
2340
                                             ;* Each item is a string of characters with the last character's
2341
                                             ;* high bit set to one. The execution table holds a 16-bit
2342
                                             ;* execution addresses that correspond to each entry in the
2343
                                             ;* character table.
2344
                                             ;*
2345
                                             ;* The end of the character table is a 0 byte which corresponds
2346
                                             ;* to the default routine in the execution table, which is
2347
                                             ;* executed if none of the other table items are matched.
2348
                                             ;*
2349
                                             ;* Character-matching tables:
2350
   2273 FFFF2502                             TAB1:
2351
   2274 FFFF2502 4C 49 53 D4                    DC.B    'LIS',('T'+0x80) ;        Direct commands
2352
   2275 FFFF2506 4C 4F 41 C4                    DC.B    'LOA',('D'+0x80)
2353
   2276 FFFF250A 4E 45 D7                       DC.B    'NE',('W'+0x80)
2354
   2277 FFFF250D 52 55 CE                       DC.B    'RU',('N'+0x80)
2355
   2278 FFFF2510 53 41 56 C5                    DC.B    'SAV',('E'+0x80)
2356
   2279 FFFF2514 43 4C D3                       DC.B    'CL',('S'+0x80)
2357
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 39
2358
BOOTROM.x68
2359
   2280 FFFF2517                             TAB2:
2360
   2281 FFFF2517 4E 45 58 D4                    DC.B    'NEX',('T'+0x80)  ;       Direct / statement
2361
   2282 FFFF251B 4C 45 D4                       DC.B    'LE',('T'+0x80)
2362
   2283 FFFF251E 49 C6                          DC.B    'I',('F'+0x80)
2363
   2284 FFFF2520 47 4F 54 CF                    DC.B    'GOT',('O'+0x80)
2364
   2285 FFFF2524 47 4F 53 55 C2                 DC.B    'GOSU',('B'+0x80)
2365
   2286 FFFF2529 52 45 54 55 52 CE              DC.B    'RETUR',('N'+0x80)
2366
   2287 FFFF252F 52 45 CD                       DC.B    'RE',('M'+0x80)
2367
   2288 FFFF2532 46 4F D2                       DC.B    'FO',('R'+0x80)
2368
   2289 FFFF2535 49 4E 50 55 D4                 DC.B    'INPU',('T'+0x80)
2369
   2290 FFFF253A 50 52 49 4E D4                 DC.B    'PRIN',('T'+0x80)
2370
   2291 FFFF253F 50 4F 4B C5                    DC.B    'POK',('E'+0x80)
2371
   2292 FFFF2543 53 54 4F D0                    DC.B    'STO',('P'+0x80)
2372
   2293 FFFF2547 42 59 C5                       DC.B    'BY',('E'+0x80)
2373
   2294 FFFF254A 43 41 4C CC                    DC.B    'CAL',('L'+0x80)
2374
   2295 FFFF254E 4C 49 4E C5                    DC.B    'LIN',('E'+0x80)
2375
   2296 FFFF2552 50 4F 49 4E D4                 DC.B    'POIN',('T'+0x80)
2376
   2297 FFFF2557 50 45 4E 43 4F 4C 4F D2        DC.B    'PENCOLO',('R'+0x80)
2377
 
2378
   2299 FFFF255F 46 49 4C 4C 43 4F 4C 4F        DC.B    'FILLCOLO',('R'+0x80)
2379
   2300 FFFF2567 D2
2380
   2301 FFFF2568 00                             DC.B    0
2381
   2302 FFFF2569                             TAB4:
2382
   2303 FFFF2569 50 45 45 CB                    DC.B    'PEE',('K'+0x80)   ;      Functions
2383
   2304 FFFF256D 52 4E C4                       DC.B    'RN',('D'+0x80)
2384
   2305 FFFF2570 41 42 D3                       DC.B    'AB',('S'+0x80)
2385
   2306 FFFF2573 53 49 5A C5                    DC.B    'SIZ',('E'+0x80)
2386
   2307 FFFF2577 54 49 43 CB                    DC.B    'TIC',('K'+0x80)
2387
   2308 FFFF257B 54 45 4D D0                    DC.B    'TEM',('P'+0x80)
2388
   2309 FFFF257F 53 47 CE                       DC.B    'SG',('N'+0x80)
2389
   2310 FFFF2582 00                             DC.B    0
2390
   2311 FFFF2583                             TAB5:
2391
   2312 FFFF2583 54 CF                          DC.B    'T',('O'+0x80)      ;     "TO" in "FOR"
2392
   2313 FFFF2585 00                             DC.B    0
2393
   2314 FFFF2586                             TAB6:
2394
   2315 FFFF2586 53 54 45 D0                    DC.B    'STE',('P'+0x80)     ;    "STEP" in "FOR"
2395
   2316 FFFF258A 00                             DC.B    0
2396
   2317 FFFF258B                             TAB8:
2397
   2318 FFFF258B 3E BD                          DC.B    '>',('='+0x80)        ;   Relational operators
2398
   2319 FFFF258D 3C BE                          DC.B    '<',('>'+0x80)
2399
   2320 FFFF258F BE                             DC.B    ('>'+0x80)
2400
   2321 FFFF2590 BD                             DC.B    ('='+0x80)
2401
   2322 FFFF2591 3C BD                          DC.B    '<',('='+0x80)
2402
   2323 FFFF2593 BC                             DC.B    ('<'+0x80)
2403
   2324 FFFF2594 00                             DC.B    0
2404
                                             ;  DC.B    0        ;<- for aligning on a word boundary
2405
 
2406
   2327 FFFF2595 FF                             even
2407
 
2408
                                             ;* Execution address tables:
2409
   2330 FFFF2596                             TAB1_1:
2410
   2331 FFFF2596 26B4                           DC.W    LIST_                   ;Direct commands
2411
   2332 FFFF2598 28F6                           DC.W    LOAD
2412
   2333 FFFF259A 264E                           DC.W    NEW
2413
   2334 FFFF259C 2662                           DC.W    RUN
2414
   2335 FFFF259E 295A                           DC.W    SAVE
2415
   2336 FFFF25A0 263C                           DC.W    CLS
2416
   2337 FFFF25A2                             TAB2_1:
2417
   2338 FFFF25A2 2802                           DC.W    NEXT                    ;Direct / statement
2418
   2339 FFFF25A4 28E6                           DC.W    LET
2419
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 40
2420
BOOTROM.x68
2421
   2340 FFFF25A6 2852                           DC.W    IF
2422
   2341 FFFF25A8 26A0                           DC.W    GOTO
2423
   2342 FFFF25AA 274A                           DC.W    GOSUB
2424
   2343 FFFF25AC 2772                           DC.W    RETURN
2425
   2344 FFFF25AE 2850                           DC.W    REM
2426
   2345 FFFF25B0 2790                           DC.W    FOR
2427
   2346 FFFF25B2 2878                           DC.W    INPUT
2428
   2347 FFFF25B4 26E0                           DC.W    PRINT
2429
   2348 FFFF25B6 29DE                           DC.W    POKE
2430
   2349 FFFF25B8 265A                           DC.W    STOP_
2431
   2350 FFFF25BA 2418                           DC.W    GOBYE
2432
   2351 FFFF25BC 2A94                           DC.W    CALL
2433
   2352 FFFF25BE 2A32                           DC.W    LINE
2434
   2353 FFFF25C0 29FA                           DC.W    POINT
2435
   2354 FFFF25C2 2A16                           DC.W    PENCOLOR
2436
   2355 FFFF25C4 2A24                           DC.W    FILLCOLOR
2437
   2356 FFFF25C6 28E0                           DC.W    DEFLT
2438
   2357 FFFF25C8                             TAB4_1:
2439
   2358 FFFF25C8 2CEE                           DC.W    PEEK                    ;Functions
2440
   2359 FFFF25CA 2CFA                           DC.W    RND
2441
   2360 FFFF25CC 2D26                           DC.W    ABS
2442
   2361 FFFF25CE 2D48                           DC.W    SIZE_
2443
   2362 FFFF25D0 2D52                           DC.W    TICK
2444
   2363 FFFF25D2 2D58                           DC.W    TEMP
2445
   2364 FFFF25D4 2D36                           DC.W    SGN
2446
   2365 FFFF25D6 2BC8                           DC.W    XP40
2447
   2366 FFFF25D8                             TAB5_1:
2448
   2367 FFFF25D8 27AC                           DC.W    FR1             ;       "TO" in "FOR"
2449
   2368 FFFF25DA 2DA4                           DC.W    QWHAT
2450
   2369 FFFF25DC                             TAB6_1:
2451
   2370 FFFF25DC 27C4                           DC.W    FR2             ;       "STEP" in "FOR"
2452
   2371 FFFF25DE 27CA                           DC.W    FR3
2453
   2372 FFFF25E0                             TAB8_1:
2454
   2373 FFFF25E0 2AC0                           DC.W    XP11;   >=              Relational operators
2455
   2374 FFFF25E2 2AC8                           DC.W    XP12    ;<>
2456
   2375 FFFF25E4 2AD0                           DC.W    XP13    ;>
2457
   2376 FFFF25E6 2AE0                           DC.W    XP15    ;=
2458
   2377 FFFF25E8 2AD8                           DC.W    XP14    ;<=
2459
   2378 FFFF25EA 2AEA                           DC.W    XP16    ;<
2460
   2379 FFFF25EC 2AFC                           DC.W    XP17
2461
                                             ;*
2462
   2381 FFFF25EE                             DIRECT:
2463
   2382 FFFF25EE 43F9 FFFF 2502                 LEA     TAB1,A1
2464
   2383 FFFF25F4 45F9 FFFF 2596                 LEA     TAB1_1,A2
2465
   2384 FFFF25FA                             EXEC:
2466
   2385 FFFF25FA 6100 0A28                      BSR.L   IGNBLK;         ignore leading blanks
2467
   2386 FFFF25FE 2648                           MOVE.L  A0,A3           ;save the pointer
2468
   2387 FFFF2600 4202                           CLR.B   D2              ;clear match flag
2469
   2388 FFFF2602                             EXLP:
2470
   2389 FFFF2602 1018                           MOVE.B  (A0)+,D0;       get the program character
2471
   2390 FFFF2604 1211                           MOVE.B  (A1),D1         ;get the table character
2472
   2391 FFFF2606 6604                           BNE     EXNGO           ;If end of table,
2473
   2392 FFFF2608 204B                           MOVE.L  A3,A0   ;;      restore the text pointer and...
2474
   2393 FFFF260A 6024                           BRA     EXGO            ;execute the default.
2475
   2394 FFFF260C                             EXNGO:
2476
   2395 FFFF260C 1600                           MOVE.B  D0,D3   ;       Else check for period...
2477
   2396 FFFF260E C602                           AND.B   D2,D3           ;and a match.
2478
   2397 FFFF2610 B63C 002E                      CMP.B   #'.',D3
2479
   2398 FFFF2614 671A                           BEQ     EXGO            ;if so, execute
2480
   2399 FFFF2616 0201 007F                      AND.B   #0x7F,D1 ;      ignore the table's high bit
2481
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 41
2482
BOOTROM.x68
2483
   2400 FFFF261A B200                           CMP.B   D0,D1   ;       is there a match?
2484
   2401 FFFF261C 670C                           BEQ     EXMAT
2485
   2402 FFFF261E 548A                           ADDQ.L  #2,A2   ;       if not, try the next entry
2486
   2403 FFFF2620 204B                           MOVE.L  A3,A0   ;       reset the program pointer
2487
   2404 FFFF2622 4202                           CLR.B   D2              ;sorry, no match
2488
   2405 FFFF2624                             EX1:
2489
   2406 FFFF2624 4A19                           TST.B   (A1)+   ;       get to the end of the entry
2490
   2407 FFFF2626 6AFC                           BPL     EX1
2491
   2408 FFFF2628 60D8                           BRA     EXLP            ;back for more matching
2492
   2409 FFFF262A                             EXMAT:
2493
   2410 FFFF262A 74FF                           MOVEQ   #-1,D2;         we've got a match so far
2494
   2411 FFFF262C 4A19                           TST.B   (A1)+   ;       end of table entry?
2495
   2412 FFFF262E 6AD2                           BPL     EXLP            ;if not, go back for more
2496
   2413 FFFF2630                             EXGO:
2497
   2414 FFFF2630 47F9 FFFF 0000                 LEA             0xFFFF0000,A3   ;       execute the appropriate routine
2498
   2415 FFFF2636 3452                           move.w  (a2),a2
2499
   2416 FFFF2638 4EF3 A000                      JMP     (A3,A2.W)
2500
 
2501
   2418 FFFF263C                             CLS:
2502
   2419 FFFF263C 4EB9 FFFF 18E8                 jsr             ClearScreen
2503
   2420 FFFF2642 4278 0418                      clr.w   CursorRow
2504
   2421 FFFF2646 4278 041A                      clr.w   CursorCol
2505
   2422 FFFF264A 6000 FE14                      bra             WSTART
2506
                                             ;*
2507
                                             ;*******************************************************************
2508
                                             ;*
2509
                                             ;* What follows is the code to execute direct and statement
2510
                                             ;* commands. Control is transferred to these points via the command
2511
                                             ;* table lookup code of 'DIRECT' and 'EXEC' in the last section.
2512
                                             ;* After the command is executed, control is transferred to other
2513
                                             ;* sections as follows:
2514
                                             ;*
2515
                                             ;* For 'LIST', 'NEW', and 'STOP': go back to the warm start point.
2516
                                             ;* For 'RUN': go execute the first stored line if any; else go
2517
                                             ;* back to the warm start point.
2518
                                             ;* For 'GOTO' and 'GOSUB': go execute the target line.
2519
                                             ;* For 'RETURN' and 'NEXT'; go back to saved return line.
2520
                                             ;* For all others: if 'CURRNT' is 0, go to warm start; else go;
2521
                                             ;* execute next command. (This is done in 'FINISH'.)
2522
                                             ;*
2523
                                             ;*******************************************************************
2524
                                             ;*
2525
                                             ;* *** NEW *** STOP *** RUN (& friends) *** GOTO ***
2526
                                             ;*
2527
                                             ;* 'NEW' sets TXTUNF to point to TXTBGN
2528
                                             ;*
2529
                                             ;* 'STOP' goes back to WSTART
2530
                                             ;*
2531
                                             ;* 'RUN' finds the first stored line, stores its address
2532
                                             ;* in CURRNT, and starts executing it. Note that only those
2533
                                             ;* commands in TAB2 are legal for a stored program.
2534
                                             ;*
2535
                                             ;* There are 3 more entries in 'RUN':
2536
                                             ;* 'RUNNXL' finds next line, stores it's address and executes it.
2537
                                             ;* 'RUNTSL' stores the address of this line and executes it.
2538
                                             ;* 'RUNSML' continues the execution on same line.
2539
                                             ;*
2540
                                             ;* 'GOTO expr' evaluates the expression, finds the target
2541
                                             ;* line, and jumps to 'RUNTSL' to do it.
2542
                                             ;*
2543
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 42
2544
BOOTROM.x68
2545
   2460 FFFF264E                             NEW:
2546
   2461 FFFF264E 6100 0748                      BSR.L   ENDCHK
2547
   2462 FFFF2652 21F9 FFFF 241C 0624            MOVE.L  TXTBGN,TXTUNF   ;set the end pointer
2548
 
2549
   2464 FFFF265A                             STOP_:
2550
   2465 FFFF265A 6100 073C                      BSR.L   ENDCHK
2551
   2466 FFFF265E 6000 FE00                      BRA     WSTART
2552
 
2553
   2468 FFFF2662                             RUN:
2554
   2469 FFFF2662 6100 0734                      BSR.L   ENDCHK
2555
   2470 FFFF2666 2079 FFFF 241C                 MOVE.L  TXTBGN,A0       ;set pointer to beginning
2556
   2471 FFFF266C 21C8 0604                      MOVE.L  A0,CURRNT
2557
 
2558
   2473 FFFF2670                             RUNNXL:
2559
   2474 FFFF2670 4AB8 0604                      TST.L   CURRNT  ;       executing a program?
2560
   2475 FFFF2674 6700 FDEA                      BEQ.L   WSTART          ;if not, we've finished a direct stat.
2561
   2476 FFFF2678 4281                           CLR.L   D1              ;else find the next line number
2562
   2477 FFFF267A 2248                           MOVE.L  A0,A1
2563
   2478 FFFF267C 6100 082C                      BSR.L   FNDLNP
2564
   2479 FFFF2680 6500 FDDE                      BCS     WSTART          ;if we've fallen off the end, stop
2565
 
2566
   2481 FFFF2684                             RUNTSL:
2567
   2482 FFFF2684 21C9 0604                      MOVE.L  A1,CURRNT       ;set CURRNT to point to the line no.
2568
   2483 FFFF2688 2049                           MOVE.L  A1,A0           ;set the text pointer to
2569
   2484 FFFF268A 5488                           ADDQ.L  #2,A0           ;the start of the line text
2570
 
2571
   2486 FFFF268C                             RUNSML:
2572
   2487 FFFF268C 6100 09EE                      BSR.L   CHKIO   ;       see if a control-C was pressed
2573
   2488 FFFF2690 43F9 FFFF 2517                 LEA     TAB2,A1         ;find command in TAB2
2574
   2489 FFFF2696 45F9 FFFF 25A2                 LEA     TAB2_1,A2
2575
   2490 FFFF269C 6000 FF5C                      BRA     EXEC            ;and execute it
2576
 
2577
   2492 FFFF26A0                             GOTO:
2578
   2493 FFFF26A0 6100 0408                      BSR.L   EXPR    ;       evaluate the following expression
2579
   2494 FFFF26A4 6100 06F2                      BSR.L   ENDCHK          ;must find end of line
2580
   2495 FFFF26A8 2200                           MOVE.L  D0,D1
2581
   2496 FFFF26AA 6100 07EE                      BSR.L   FNDLN           ;find the target line
2582
   2497 FFFF26AE 6600 0740                      BNE.L   QHOW            ;no such line no.
2583
   2498 FFFF26B2 60D0                           BRA     RUNTSL          ;go do it
2584
 
2585
                                             ;*
2586
                                             ;*******************************************************************
2587
                                             ;*
2588
                                             ;* *** LIST *** PRINT ***
2589
                                             ;*
2590
                                             ;* LIST has two forms:
2591
                                             ;* 'LIST' lists all saved lines
2592
                                             ;* 'LIST #' starts listing at the line #
2593
                                             ;* Control-S pauses the listing, control-C stops it.
2594
                                             ;*
2595
                                             ;* PRINT command is 'PRINT ....:' or 'PRINT ....'
2596
                                             ;* where '....' is a list of expressions, formats, back-arrows,
2597
                                             ;* and strings.    These items a separated by commas.
2598
                                             ;*
2599
                                             ;* A format is a pound sign followed by a number.  It controls
2600
                                             ;* the number of spaces the value of an expression is going to
2601
                                             ;* be printed in.  It stays effective for the rest of the print
2602
                                             ;* command unless changed by another format.  If no format is
2603
                                             ;* specified, 11 positions will be used.
2604
                                             ;*
2605
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 43
2606
BOOTROM.x68
2607
                                             ;* A string is quoted in a pair of single- or double-quotes.
2608
                                             ;*
2609
                                             ;* An underline (back-arrow) means generate a  without a 
2610
                                             ;*
2611
                                             ;* A  is generated after the entire list has been printed
2612
                                             ;* or if the list is empty.  If the list ends with a semicolon,
2613
                                             ;* however, no  is generated.
2614
                                             ;*
2615
 
2616
   2529 FFFF26B4                             LIST_:
2617
   2530 FFFF26B4 6100 0936                      BSR.L   TSTNUM  ;       see if there's a line no.
2618
   2531 FFFF26B8 6100 06DE                      BSR.L   ENDCHK          ;if not, we get a zero
2619
   2532 FFFF26BC 6100 07DC                      BSR.L   FNDLN           ;find this or next line
2620
   2533 FFFF26C0                             LS1:
2621
   2534 FFFF26C0 6500 FD9E                      BCS     WSTART          ;warm start if we passed the end
2622
   2535 FFFF26C4 6100 08F0                      BSR.L   PRTLN   ;       print the line
2623
   2536 FFFF26C8 6100 09B2                      BSR.L   CHKIO   ;       check for listing halt request
2624
   2537 FFFF26CC 670C                           BEQ     LS3
2625
   2538 FFFF26CE B03C 0013                      CMP.B   #CTRLS,D0       ;pause the listing?
2626
   2539 FFFF26D2 6606                           BNE     LS3
2627
   2540 FFFF26D4                             LS2:
2628
   2541 FFFF26D4 6100 09A6                      BSR.L   CHKIO           ;if so, wait for another keypress
2629
   2542 FFFF26D8 67FA                           BEQ     LS2
2630
   2543 FFFF26DA                             LS3:
2631
   2544 FFFF26DA 6100 07CE                      BSR.L   FNDLNP          ;find the next line
2632
   2545 FFFF26DE 60E0                           BRA     LS1
2633
 
2634
   2547 FFFF26E0                             PRINT:
2635
   2548 FFFF26E0 780B                           MOVE    #11,D4  ;       D4 = number of print spaces
2636
   2549 FFFF26E2 6100 08EE                      BSR.L   TSTC            ;if null list and ":"
2637
   2550 FFFF26E6 3A 07                          DC.B    ':',PR2-$
2638
   2551 FFFF26E8 6100 09A4                      BSR.L   CRLF1           ;give CR-LF and continue
2639
   2552 FFFF26EC 609E                           BRA     RUNSML          ;execution on the same line
2640
   2553 FFFF26EE                             PR2:
2641
   2554 FFFF26EE 6100 08E2                      BSR.L   TSTC            ;if null list and 
2642
   2555 FFFF26F2 0D 09                          DC.B    CR,PR0-$
2643
   2556 FFFF26F4 6100 0998                      BSR.L   CRLF1           ;also give CR-LF and
2644
   2557 FFFF26F8 6000 FF76                      BRA     RUNNXL          ;execute the next line
2645
   2558 FFFF26FC                             PR0:
2646
   2559 FFFF26FC 6100 08D4                      BSR.L   TSTC            ;else is it a format?
2647
   2560 FFFF2700 23 09                          DC.B    '#',PR1-$
2648
   2561 FFFF2702 6100 03A6                      BSR.L   EXPR            ;yes, evaluate expression
2649
   2562 FFFF2706 2800                           MOVE    D0,D4           ;and save it as print width
2650
   2563 FFFF2708 6016                           BRA     PR3             ;look for more to print
2651
   2564 FFFF270A                             PR1:
2652
   2565 FFFF270A 6100 08C6                      BSR.L   TSTC            ;is character expression? (MRL)
2653
   2566 FFFF270E 24 0B                          DC.B    '$',PR4-$
2654
   2567 FFFF2710 6100 0398                      BSR.L   EXPR            ;yep. Evaluate expression (MRL)
2655
   2568 FFFF2714 6100 FCF2                      BSR     GOOUT           ;print low byte (MRL)
2656
   2569 FFFF2718 6006                           BRA     PR3             ;look for more. (MRL)
2657
   2570 FFFF271A                             PR4:
2658
   2571 FFFF271A 6100 081E                      BSR.L   QTSTG   ;       is it a string?
2659
   2572 FFFF271E 6012                           BRA.S   PR8             ;if not, must be an expression
2660
   2573 FFFF2720                             PR3:
2661
   2574 FFFF2720 6100 08B0                      BSR.L   TSTC    ;       if ",", go find next
2662
   2575 FFFF2724 2C 07                          DC.B    ',',PR6-$
2663
   2576 FFFF2726 6100 0656                      BSR.L   FIN             ;in the list.
2664
   2577 FFFF272A 60D0                           BRA     PR0
2665
   2578 FFFF272C                             PR6:
2666
   2579 FFFF272C 6100 0960                      BSR.L   CRLF1   ;       list ends here
2667
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 44
2668
BOOTROM.x68
2669
   2580 FFFF2730 6010                           BRA     FINISH
2670
   2581 FFFF2732                             PR8:
2671
   2582 FFFF2732 2F04                           MOVE    D4,-(SP)        ;save the width value
2672
   2583 FFFF2734 6100 0374                      BSR.L   EXPR            ;evaluate the expression
2673
   2584 FFFF2738 281F                           MOVE    (SP)+,D4        ;restore the width
2674
   2585 FFFF273A 2200                           MOVE.L  D0,D1
2675
   2586 FFFF273C 6100 083C                      BSR.L   PRTNUM          ;print its value
2676
   2587 FFFF2740 60DE                           BRA     PR3             ;more to print?
2677
 
2678
   2589 FFFF2742                             FINISH:
2679
   2590 FFFF2742 6100 063A                      BSR.L   FIN     ;       Check end of command
2680
   2591 FFFF2746 6000 065C                      BRA.L   QWHAT   ;       print "What?" if wrong
2681
 
2682
                                             ;*
2683
                                             ;*******************************************************************
2684
                                             ;*
2685
                                             ;* *** GOSUB *** & RETURN ***
2686
                                             ;*
2687
                                             ;* 'GOSUB expr:' or 'GOSUB expr' is like the 'GOTO' command,
2688
                                             ;* except that the current text pointer, stack pointer, etc. are
2689
                                             ;* saved so that execution can be continued after the subroutine
2690
                                             ;* 'RETURN's.  In order that 'GOSUB' can be nested (and even
2691
                                             ;* recursive), the save area must be stacked.  The stack pointer
2692
                                             ;* is saved in 'STKGOS'.  The old 'STKGOS' is saved on the stack.
2693
                                             ;* If we are in the main routine, 'STKGOS' is zero (this was done
2694
                                             ;* in the initialization section of the interpreter), but we still
2695
                                             ;* save it as a flag for no further 'RETURN's.
2696
                                             ;*
2697
                                             ;* 'RETURN' undoes everything that 'GOSUB' did, and thus
2698
                                             ;* returns the execution to the command after the most recent
2699
                                             ;* 'GOSUB'.  If 'STKGOS' is zero, it indicates that we never had
2700
                                             ;* a 'GOSUB' and is thus an error.
2701
                                             ;*
2702
   2613 FFFF274A                             GOSUB:
2703
   2614 FFFF274A 6100 07AC                      BSR.L   PUSHA   ;       save the current 'FOR' parameters
2704
   2615 FFFF274E 6100 035A                      BSR.L   EXPR            ;get line number
2705
   2616 FFFF2752 2F08                           MOVE.L  A0,-(SP)        ;save text pointer
2706
   2617 FFFF2754 2200                           MOVE.L  D0,D1
2707
   2618 FFFF2756 6100 0742                      BSR.L   FNDLN           ;find the target line
2708
   2619 FFFF275A 6600 0696                      BNE.L   AHOW            ;if not there, say "How?"
2709
   2620 FFFF275E 2F38 0604                      MOVE.L  CURRNT,-(SP)    ;found it, save old 'CURRNT'...
2710
   2621 FFFF2762 2F38 0608                      MOVE.L  STKGOS,-(SP)    ;and 'STKGOS'
2711
   2622 FFFF2766 42B8 0610                      CLR.L   LOPVAR          ;load new values
2712
   2623 FFFF276A 21CF 0608                      MOVE.L  SP,STKGOS
2713
   2624 FFFF276E 6000 FF14                      BRA     RUNTSL
2714
 
2715
   2626 FFFF2772                             RETURN:
2716
   2627 FFFF2772 6100 0624                      BSR.L   ENDCHK  ;       there should be just a 
2717
   2628 FFFF2776 2238 0608                      MOVE.L  STKGOS,D1       ;get old stack pointer
2718
   2629 FFFF277A 6700 0628                      BEQ.L   QWHAT           ;if zero, it doesn't exist
2719
   2630 FFFF277E 2E41                           MOVE.L  D1,SP           ;else restore it
2720
   2631 FFFF2780 21DF 0608                      MOVE.L  (SP)+,STKGOS    ;and the old 'STKGOS'
2721
   2632 FFFF2784 21DF 0604                      MOVE.L  (SP)+,CURRNT    ;and the old 'CURRNT'
2722
   2633 FFFF2788 205F                           MOVE.L  (SP)+,A0        ;and the old text pointer
2723
   2634 FFFF278A 6100 0752                      BSR.L   POPA            ;and the old 'FOR' parameters
2724
   2635 FFFF278E 60B2                           BRA     FINISH          ;and we are back home
2725
 
2726
                                             ;*
2727
                                             ;*******************************************************************
2728
                                             ;*
2729
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 45
2730
BOOTROM.x68
2731
                                             ;* *** FOR *** & NEXT ***
2732
                                             ;*
2733
                                             ;* 'FOR' has two forms:
2734
                                             ;* 'FOR var=exp1 TO exp2 STEP exp1' and 'FOR var=exp1 TO exp2'
2735
                                             ;* The second form means the same thing as the first form with a
2736
                                             ;* STEP of positive 1.  The interpreter will find the variable 'var'
2737
                                             ;* and set its value to the current value of 'exp1'.  It also
2738
                                             ;* evaluates 'exp2' and 'exp1' and saves all these together with
2739
                                             ;* the text pointer, etc. in the 'FOR' save area, which consisits of
2740
                                             ;* 'LOPVAR', 'LOPINC', 'LOPLMT', 'LOPLN', and 'LOPPT'.  If there is
2741
                                             ;* already something in the save area (indicated by a non-zero
2742
                                             ;* 'LOPVAR'), then the old save area is saved on the stack before
2743
                                             ;* the new values are stored.  The interpreter will then dig in the
2744
                                             ;* stack and find out if this same variable was used in another
2745
                                             ;* currently active 'FOR' loop.  If that is the case, then the old
2746
                                             ;* 'FOR' loop is deactivated. (i.e. purged from the stack)
2747
                                             ;*
2748
                                             ;* 'NEXT var' serves as the logical (not necessarily physical) end
2749
                                             ;* of the 'FOR' loop.  The control variable 'var' is checked with
2750
                                             ;* the 'LOPVAR'.  If they are not the same, the interpreter digs in
2751
                                             ;* the stack to find the right one and purges all those that didn't
2752
                                             ;* match.  Either way, it then adds the 'STEP' to that variable and
2753
                                             ;* checks the result with against the limit value.  If it is within
2754
                                             ;* the limit, control loops back to the command following the
2755
                                             ;* 'FOR'.  If it's outside the limit, the save area is purged and
2756
                                             ;* execution continues.
2757
                                             ;*
2758
   2667 FFFF2790                             FOR:
2759
   2668 FFFF2790 6100 0766                      BSR.L   PUSHA           ;save the old 'FOR' save area
2760
   2669 FFFF2794 6100 05CE                      BSR.L   SETVAL          ;set the control variable
2761
   2670 FFFF2798 21CE 0610                      MOVE.L  A6,LOPVAR       ;save its address
2762
   2671 FFFF279C 43F9 FFFF 2583                 LEA     TAB5,A1         ;use 'EXEC' to test for 'TO'
2763
   2672 FFFF27A2 45F9 FFFF 25D8                 LEA     TAB5_1,A2
2764
   2673 FFFF27A8 6000 FE50                      BRA     EXEC
2765
   2674 FFFF27AC                             FR1:
2766
   2675 FFFF27AC 6100 02FC                      BSR.L   EXPR            ;evaluate the limit
2767
   2676 FFFF27B0 21C0 0618                      MOVE.L  D0,LOPLMT       ;save that
2768
   2677 FFFF27B4 43F9 FFFF 2586                 LEA     TAB6,A1         ;use 'EXEC' to look for the
2769
   2678 FFFF27BA 45F9 FFFF 25DC                 LEA     TAB6_1,A2       ;word 'STEP'
2770
   2679 FFFF27C0 6000 FE38                      BRA     EXEC
2771
   2680 FFFF27C4                             FR2:
2772
   2681 FFFF27C4 6100 02E4                      BSR.L   EXPR    ;       found it, get the step value
2773
   2682 FFFF27C8 6002                           BRA     FR4
2774
   2683 FFFF27CA                             FR3:
2775
   2684 FFFF27CA 7001                           MOVEQ   #1,D0   ;       not found, step defaults to 1
2776
   2685 FFFF27CC                             FR4:
2777
   2686 FFFF27CC 21C0 0614                      MOVE.L  D0,LOPINC       ;save that too
2778
   2687 FFFF27D0                             FR5:
2779
   2688 FFFF27D0 21F8 0604 061C                 MOVE.L  CURRNT,LOPLN    ;save address of current line number
2780
   2689 FFFF27D6 21C8 0620                      MOVE.L  A0,LOPPT        ;and text pointer
2781
   2690 FFFF27DA 2C4F                           MOVE.L  SP,A6           ;dig into the stack to find 'LOPVAR'
2782
   2691 FFFF27DC 6006                           BRA     FR7
2783
   2692 FFFF27DE                             FR6:
2784
   2693 FFFF27DE DDFC 0000 0014                 ADD.L   #20,A6          ;look at next stack frame
2785
   2694 FFFF27E4                             FR7:
2786
   2695 FFFF27E4 2016                           MOVE.L  (A6),D0         ;is it zero?
2787
   2696 FFFF27E6 6716                           BEQ     FR8             ;if so, we're done
2788
   2697 FFFF27E8 B0B8 0610                      CMP.L   LOPVAR,D0       ;same as current LOPVAR?
2789
   2698 FFFF27EC 66F0                           BNE     FR6             ;nope, look some more
2790
   2699 FFFF27EE 244F                           MOVE.L  SP,A2   ;       Else remove 5 long words from...
2791
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 46
2792
BOOTROM.x68
2793
   2700 FFFF27F0 224E                           MOVE.L  A6,A1   ;       inside the stack.
2794
   2701 FFFF27F2 47F8 0014                      LEA     20,A3
2795
   2702 FFFF27F6 D7C9                           ADD.L   A1,A3
2796
   2703 FFFF27F8 6100 06DC                      BSR.L   MVDOWN
2797
   2704 FFFF27FC 2E4B                           MOVE.L  A3,SP   ;       set the SP 5 long words up
2798
   2705 FFFF27FE                             FR8:
2799
   2706 FFFF27FE 6000 FF42                      BRA     FINISH          ;and continue execution
2800
 
2801
   2708 FFFF2802                             NEXT:
2802
   2709 FFFF2802 6100 03F2                      BSR.L   TSTV;           get address of variable
2803
   2710 FFFF2806 6500 059C                      BCS.L   QWHAT   ;       if no variable, say "What?"
2804
   2711 FFFF280A 2240                           MOVE.L  D0,A1   ;       save variable's address
2805
   2712 FFFF280C                             NX0:
2806
   2713 FFFF280C 2038 0610                      MOVE.L  LOPVAR,D0;      If 'LOPVAR' is zero, we never...
2807
   2714 FFFF2810 6700 0592                      BEQ.L   QWHAT   ;       had a FOR loop, so say "What?"
2808
   2715 FFFF2814 B3C0                           CMP.L   D0,A1   ;;      else we check them
2809
   2716 FFFF2816 6706                           BEQ     NX3     ;       OK, they agree
2810
   2717 FFFF2818 6100 06C4                      BSR.L   POPA    ;       nope, let's see the next frame
2811
   2718 FFFF281C 60EE                           BRA     NX0
2812
   2719 FFFF281E                             NX3:
2813
   2720 FFFF281E 2011                           MOVE.L  (A1),D0 ;       get control variable's value
2814
   2721 FFFF2820 D0B8 0614                      ADD.L   LOPINC,D0;      add in loop increment
2815
   2722 FFFF2824 6900 05CA                      BVS.L   QHOW    ;       say "How?" for 32-bit overflow
2816
   2723 FFFF2828 2280                           MOVE.L  D0,(A1) ;       save control variable's new value
2817
   2724 FFFF282A 2238 0618                      MOVE.L  LOPLMT,D1;      get loop's limit value
2818
   2725 FFFF282E 4AB8 0614                      TST.L   LOPINC
2819
   2726 FFFF2832 6A02                           BPL     NX1     ;       branch if loop increment is positive
2820
   2727 FFFF2834 C141                           EXG     D0,D1
2821
   2728 FFFF2836                             NX1:
2822
   2729 FFFF2836 B280                           CMP.L   D0,D1;          test against limit
2823
   2730 FFFF2838 6D0E                           BLT     NX2;            branch if outside limit
2824
   2731 FFFF283A 21F8 061C 0604                 MOVE.L  LOPLN,CURRNT    ;Within limit, go back to the...
2825
   2732 FFFF2840 2078 0620                      MOVE.L  LOPPT,A0        ;saved 'CURRNT' and text pointer.
2826
   2733 FFFF2844 6000 FEFC                      BRA     FINISH
2827
   2734 FFFF2848                             NX2:
2828
   2735 FFFF2848 6100 0694                      BSR.L   POPA            ;purge this loop
2829
   2736 FFFF284C 6000 FEF4                      BRA     FINISH
2830
 
2831
                                             ;*
2832
                                             ;*******************************************************************
2833
                                             ;*
2834
                                             ;* *** REM *** IF *** INPUT *** LET (& DEFLT) ***
2835
                                             ;*
2836
                                             ;* 'REM' can be followed by anything and is ignored by the
2837
                                             ;* interpreter.
2838
                                             ;*
2839
                                             ;* 'IF' is followed by an expression, as a condition and one or
2840
                                             ;* more commands (including other 'IF's) separated by colons.
2841
                                             ;* Note that the word 'THEN' is not used.  The interpreter evaluates
2842
                                             ;* the expression.  If it is non-zero, execution continues.  If it
2843
                                             ;* is zero, the commands that follow are ignored and execution
2844
                                             ;* continues on the next line.
2845
                                             ;*
2846
                                             ;* 'INPUT' is like the 'PRINT' command, and is followed by a list
2847
                                             ;* of items.  If the item is a string in single or double quotes,
2848
                                             ;* or is an underline (back arrow), it has the same effect as in
2849
                                             ;* 'PRINT'.  If an item is a variable, this variable name is
2850
                                             ;* printed out followed by a colon, then the interpreter waits for
2851
                                             ;* an expression to be typed in.  The variable is then set to the
2852
                                             ;* value of this expression.  If the variable is preceeded by a
2853
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 47
2854
BOOTROM.x68
2855
                                             ;* string (again in single or double quotes), the string will be
2856
                                             ;* displayed followed by a colon.  The interpreter the waits for an
2857
                                             ;* expression to be entered and sets the variable equal to the
2858
                                             ;* expression's value.  If the input expression is invalid, the
2859
                                             ;* interpreter will print "What?", "How?", or "Sorry" and reprint
2860
                                             ;* the prompt and redo the input.  The execution will not terminate
2861
                                             ;* unless you press control-C.  This is handled in 'INPERR'.
2862
                                             ;*
2863
                                             ;* 'LET' is followed by a list of items separated by commas.
2864
                                             ;* Each item consists of a variable, an equals sign, and an
2865
                                             ;* expression.  The interpreter evaluates the expression and sets
2866
                                             ;* the variable to that value.  The interpreter will also handle
2867
                                             ;* 'LET' commands without the word 'LET'.  This is done by 'DEFLT'.
2868
                                             ;*
2869
   2774 FFFF2850                             REM:
2870
   2775 FFFF2850 600A                           BRA     IF2             ;skip the rest of the line
2871
 
2872
   2777 FFFF2852                             IF:
2873
   2778 FFFF2852 6100 0256                      BSR.L   EXPR    ;       evaluate the expression
2874
   2779 FFFF2856                             IF1:
2875
   2780 FFFF2856 4A80                           TST.L   D0              ;is it zero?
2876
   2781 FFFF2858 6600 FE32                      BNE     RUNSML          ;if not, continue
2877
   2782 FFFF285C                             IF2:
2878
   2783 FFFF285C 2248                           MOVE.L  A0,A1
2879
   2784 FFFF285E 4281                           CLR.L   D1
2880
   2785 FFFF2860 6100 0662                      BSR.L   FNDSKP  ;       if so, skip the rest of the line
2881
   2786 FFFF2864 6400 FE1E                      BCC     RUNTSL          ;and run the next line
2882
   2787 FFFF2868 6000 FBF6                      BRA.L   WSTART  ;       if no next line, do a warm start
2883
 
2884
   2789 FFFF286C                             INPERR:
2885
   2790 FFFF286C 2E78 060C                      MOVE.L  STKINP,SP;      restore the old stack pointer
2886
   2791 FFFF2870 21DF 0604                      MOVE.L  (SP)+,CURRNT;   and old 'CURRNT'
2887
   2792 FFFF2874 588F                           ADDQ.L  #4,SP
2888
   2793 FFFF2876 205F                           MOVE.L  (SP)+,A0        ;and old text pointer
2889
 
2890
   2795 FFFF2878                             INPUT:
2891
   2796 FFFF2878 2F08                           MOVE.L  A0,-(SP);       save in case of error
2892
   2797 FFFF287A 6100 06BE                      BSR.L   QTSTG           ;is next item a string?
2893
   2798 FFFF287E 600A                           BRA.S   IP2             ;nope
2894
   2799 FFFF2880 6100 0374                      BSR.L   TSTV    ;       yes, but is it followed by a variable?
2895
   2800 FFFF2884 654C                           BCS     IP4             ;if not, branch
2896
   2801 FFFF2886 2440                           MOVE.L  D0,A2   ;       put away the variable's address
2897
   2802 FFFF2888 601A                           BRA     IP3             ;if so, input to variable
2898
   2803 FFFF288A                             IP2:
2899
   2804 FFFF288A 2F08                           MOVE.L  A0,-(SP);       save for 'PRTSTG'
2900
   2805 FFFF288C 6100 0368                      BSR.L   TSTV    ;       must be a variable now
2901
   2806 FFFF2890 6500 0512                      BCS.L   QWHAT   ;       "What?" it isn't?
2902
   2807 FFFF2894 2440                           MOVE.L  D0,A2   ;       put away the variable's address
2903
   2808 FFFF2896 1410                           MOVE.B  (A0),D2 ;       get ready for 'PRTSTG'
2904
   2809 FFFF2898 4200                           CLR.B   D0
2905
   2810 FFFF289A 1080                           MOVE.B  D0,(A0)
2906
   2811 FFFF289C 225F                           MOVE.L  (SP)+,A1
2907
   2812 FFFF289E 6100 067E                      BSR.L   PRTSTG  ;       print string as prompt
2908
   2813 FFFF28A2 1082                           MOVE.B  D2,(A0) ;       restore text
2909
   2814 FFFF28A4                             IP3:
2910
   2815 FFFF28A4 2F08                           MOVE.L  A0,-(SP);       save in case of error
2911
   2816 FFFF28A6 2F38 0604                      MOVE.L  CURRNT,-(SP)    ;also save 'CURRNT'
2912
   2817 FFFF28AA 21FC FFFF FFFF 0604            MOVE.L  #-1,CURRNT      ;flag that we are in INPUT
2913
   2818 FFFF28B2 21CF 060C                      MOVE.L  SP,STKINP       ;save the stack pointer too
2914
   2819 FFFF28B6 2F0A                           MOVE.L  A2,-(SP)        ;save the variable address
2915
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 48
2916
BOOTROM.x68
2917
   2820 FFFF28B8 103C 003A                      MOVE.B  #':',D0     ;    print a colon first
2918
   2821 FFFF28BC 6100 053C                      BSR.L   GETLN           ;then get an input line
2919
   2822 FFFF28C0 41F8 0630                      LEA     BUFFER,A0       ;point to the buffer
2920
   2823 FFFF28C4 6100 01E4                      BSR.L   EXPR    ;       evaluate the input
2921
   2824 FFFF28C8 245F                           MOVE.L  (SP)+,A2        ;restore the variable address
2922
   2825 FFFF28CA 2480                           MOVE.L  D0,(A2)         ;save value in variable
2923
   2826 FFFF28CC 21DF 0604                      MOVE.L  (SP)+,CURRNT    ;restore old 'CURRNT'
2924
   2827 FFFF28D0 205F                           MOVE.L  (SP)+,A0;       and the old text pointer
2925
   2828 FFFF28D2                             IP4:
2926
   2829 FFFF28D2 588F                           ADDQ.L  #4,SP   ;       clean up the stack
2927
   2830 FFFF28D4 6100 06FC                      BSR.L   TSTC    ;       is the next thing a comma?
2928
   2831 FFFF28D8 2C 03                          DC.B    ',',IP5-$
2929
   2832 FFFF28DA 609C                           BRA     INPUT   ;       yes, more items
2930
   2833 FFFF28DC                             IP5:
2931
   2834 FFFF28DC 6000 FE64                      BRA     FINISH
2932
 
2933
   2836 FFFF28E0                             DEFLT:
2934
   2837 FFFF28E0 0C10 000D                      CMP.B   #CR,(A0);       empty line is OK
2935
   2838 FFFF28E4 670C                           BEQ     LT1             ;else it is 'LET'
2936
 
2937
   2840 FFFF28E6                             LET:
2938
   2841 FFFF28E6 6100 047C                      BSR.L   SETVAL          ;do the assignment
2939
   2842 FFFF28EA 6100 06E6                      BSR.L   TSTC            ;check for more 'LET' items
2940
   2843 FFFF28EE 2C 03                          DC.B    ',',LT1-$
2941
   2844 FFFF28F0 60F4                           BRA     LET
2942
   2845 FFFF28F2                             LT1:
2943
   2846 FFFF28F2 6000 FE4E                      BRA     FINISH          ;until we are finished.
2944
 
2945
                                             ;*
2946
                                             ;*******************************************************************
2947
                                             ;*
2948
                                             ;* *** LOAD *** & SAVE ***
2949
                                             ;*
2950
                                             ;* These two commands transfer a program to/from an auxiliary
2951
                                             ;* device such as a cassette, another computer, etc.  The program
2952
                                             ;* is converted to an easily-stored format: each line starts with
2953
                                             ;* a colon, the line no. as 4 hex digits, and the rest of the line.
2954
                                             ;* At the end, a line starting with an '@' sign is sent.  This
2955
                                             ;* format can be read back with a minimum of processing time by
2956
                                             ;* the 68000.
2957
                                             ;*
2958
   2861 FFFF28F6                             LOAD:
2959
   2862 FFFF28F6 2079 FFFF 241C                 MOVE.L  TXTBGN,A0       ;set pointer to start of prog. area
2960
   2863 FFFF28FC 103C 000D                      MOVE.B  #CR,D0          ;For a CP/M host, tell it we're ready...
2961
   2864 FFFF2900 6100 FB0E                      BSR     GOAUXO          ;by sending a CR to finish PIP command.
2962
   2865 FFFF2904                             LOD1:
2963
   2866 FFFF2904 6100 FB0E                      BSR     GOAUXI  ;       look for start of line
2964
   2867 FFFF2908 67FA                           BEQ     LOD1
2965
   2868 FFFF290A B03C 0040                      CMP.B   #'@',D0  ;       end of program?
2966
   2869 FFFF290E 6722                           BEQ     LODEND
2967
   2870 FFFF2910 B03C 003A                      CMP.B   #':',D0   ;      if not, is it start of line?
2968
   2871 FFFF2914 66EE                           BNE     LOD1                    ;if not, wait for it
2969
   2872 FFFF2916 6100 0022                      BSR     GBYTE                   ;get first byte of line no.
2970
   2873 FFFF291A 10C1                           MOVE.B  D1,(A0)+        ;store it
2971
   2874 FFFF291C 6100 001C                      BSR     GBYTE                   ;get 2nd bye of line no.
2972
   2875 FFFF2920 10C1                           MOVE.B  D1,(A0)+        ;       store that, too
2973
   2876 FFFF2922                             LOD2:
2974
   2877 FFFF2922 6100 FAF0                      BSR     GOAUXI  ;       get another text char.
2975
   2878 FFFF2926 67FA                           BEQ     LOD2
2976
   2879 FFFF2928 10C0                           MOVE.B  D0,(A0)+        ;store it
2977
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 49
2978
BOOTROM.x68
2979
   2880 FFFF292A B03C 000D                      CMP.B   #CR,D0          ;is it the end of the line?
2980
   2881 FFFF292E 66F2                           BNE     LOD2            ;if not, go back for more
2981
   2882 FFFF2930 60D2                           BRA     LOD1            ;if so, start a new line
2982
   2883 FFFF2932                             LODEND:
2983
   2884 FFFF2932 21C8 0624                      MOVE.L  A0,TXTUNF       ;set end-of program pointer
2984
   2885 FFFF2936 6000 FB28                      BRA     WSTART          ;back to direct mode
2985
 
2986
   2887 FFFF293A                             GBYTE:
2987
   2888 FFFF293A 7401                           MOVEQ   #1,D2   ;               get two hex characters from auxiliary
2988
   2889 FFFF293C 4281                           CLR     D1                      ;and store them as a byte in D1
2989
   2890 FFFF293E                             GBYTE1:
2990
   2891 FFFF293E 6100 FAD4                      BSR     GOAUXI          ;       get a char.
2991
   2892 FFFF2942 67FA                           BEQ     GBYTE1
2992
   2893 FFFF2944 B03C 0041                      CMP.B   #'A',D0
2993
   2894 FFFF2948 6502                           BCS     GBYTE2
2994
   2895 FFFF294A 5F00                           SUBQ.B  #7,D0   ;       if greater than 9, adjust
2995
   2896 FFFF294C                             GBYTE2:
2996
   2897 FFFF294C 0200 000F                      AND.B   #0xF,D0         ;strip ASCII
2997
   2898 FFFF2950 E909                           LSL.B   #4,D1           ;put nybble into the result
2998
   2899 FFFF2952 8200                           OR.B    D0,D1
2999
   2900 FFFF2954 51CA FFE8                      DBRA    D2,GBYTE1       ;get another char.
3000
   2901 FFFF2958 4E75                           RTS
3001
 
3002
   2903 FFFF295A                             SAVE:
3003
   2904 FFFF295A 2079 FFFF 241C                 MOVE.L  TXTBGN,A0;      set pointer to start of prog. area
3004
   2905 FFFF2960 2278 0624                      MOVE.L  TXTUNF,A1       ;set pointer to end of prog. area
3005
   2906 FFFF2964                             SAVE1:
3006
   2907 FFFF2964 103C 000D                      MOVE.B  #CR,D0  ;       send out a CR & LF (CP/M likes this)
3007
   2908 FFFF2968 6100 FAA6                      BSR     GOAUXO
3008
   2909 FFFF296C 103C 000A                      MOVE.B  #LF,D0
3009
   2910 FFFF2970 6100 FA9E                      BSR     GOAUXO
3010
   2911 FFFF2974 B3C8                           CMP.L   A0,A1           ;are we finished?
3011
   2912 FFFF2976 6322                           BLS     SAVEND
3012
   2913 FFFF2978 103C 003A                      MOVE.B  #':',D0      ;   if not, start a line
3013
   2914 FFFF297C 6100 FA92                      BSR     GOAUXO
3014
   2915 FFFF2980 1218                           MOVE.B  (A0)+,D1        ;send first half of line no.
3015
   2916 FFFF2982 6100 003A                      BSR     PBYTE
3016
   2917 FFFF2986 1218                           MOVE.B  (A0)+,D1        ;and send 2nd half
3017
   2918 FFFF2988 6100 0034                      BSR     PBYTE
3018
   2919 FFFF298C                             SAVE2:
3019
   2920 FFFF298C 1018                           MOVE.B  (A0)+,D0;       get a text char.
3020
   2921 FFFF298E B03C 000D                      CMP.B   #CR,D0          ;is it the end of the line?
3021
   2922 FFFF2992 67D0                           BEQ     SAVE1           ;if so, send CR & LF and start new line
3022
   2923 FFFF2994 6100 FA7A                      BSR     GOAUXO          ;send it out
3023
   2924 FFFF2998 60F2                           BRA     SAVE2           ;go back for more text
3024
   2925 FFFF299A                             SAVEND:
3025
   2926 FFFF299A 103C 0040                      MOVE.B  #'@',D0 ;        send end-of-program indicator
3026
   2927 FFFF299E 6100 FA70                      BSR     GOAUXO
3027
   2928 FFFF29A2 103C 000D                      MOVE.B  #CR,D0  ;       followed by a CR & LF
3028
   2929 FFFF29A6 6100 FA68                      BSR     GOAUXO
3029
   2930 FFFF29AA 103C 000A                      MOVE.B  #LF,D0
3030
   2931 FFFF29AE 6100 FA60                      BSR     GOAUXO
3031
   2932 FFFF29B2 103C 001A                      MOVE.B  #0x1A,D0        ;and a control-Z to end the CP/M file
3032
   2933 FFFF29B6 6100 FA58                      BSR     GOAUXO
3033
   2934 FFFF29BA 6000 FAA4                      BRA     WSTART          ;then go do a warm start
3034
 
3035
   2936 FFFF29BE                             PBYTE:
3036
   2937 FFFF29BE 7401                           MOVEQ   #1,D2   ;       send two hex characters from D1's low byte
3037
   2938 FFFF29C0                             PBYTE1:
3038
   2939 FFFF29C0 E919                           ROL.B   #4,D1   ;       get the next nybble
3039
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 50
3040
BOOTROM.x68
3041
   2940 FFFF29C2 1001                           MOVE.B  D1,D0
3042
   2941 FFFF29C4 0200 000F                      AND.B   #0xF,D0 ;       strip off garbage
3043
   2942 FFFF29C8 0600 0030                      ADD.B   #'0',D0   ;      make it into ASCII
3044
   2943 FFFF29CC B03C 0039                      CMP.B   #'9',D0
3045
   2944 FFFF29D0 6302                           BLS     PBYTE2
3046
   2945 FFFF29D2 5E00                           ADDQ.B  #7,D0           ;adjust if greater than 9
3047
   2946 FFFF29D4                             PBYTE2:
3048
   2947 FFFF29D4 6100 FA3A                      BSR     GOAUXO          ;send it out
3049
   2948 FFFF29D8 51CA FFE6                      DBRA    D2,PBYTE1       ;then send the next nybble
3050
   2949 FFFF29DC 4E75                           RTS
3051
 
3052
                                             ;*
3053
                                             ;*******************************************************************
3054
                                             ;*
3055
                                             ;* *** POKE *** & CALL ***
3056
                                             ;*
3057
                                             ;* 'POKE expr1,expr2' stores the byte from 'expr2' into the memory
3058
                                             ;* address specified by 'expr1'.
3059
                                             ;*
3060
                                             ;* 'CALL expr' jumps to the machine language subroutine whose
3061
                                             ;* starting address is specified by 'expr'.  The subroutine can use
3062
                                             ;* all registers but must leave the stack the way it found it.
3063
                                             ;* The subroutine returns to the interpreter by executing an RTS.
3064
                                             ;*
3065
   2964 FFFF29DE                             POKE:
3066
   2965 FFFF29DE 6100 00CA                      BSR     EXPR            ;get the memory address
3067
   2966 FFFF29E2 6100 05EE                      BSR.L   TSTC            ;it must be followed by a comma
3068
   2967 FFFF29E6 2C 0F                          DC.B    ',',PKER-$
3069
   2968 FFFF29E8 2F00                           MOVE.L  D0,-(SP)        ;save the address
3070
   2969 FFFF29EA 6100 00BE                      BSR     EXPR            ;get the byte to be POKE'd
3071
   2970 FFFF29EE 225F                           MOVE.L  (SP)+,A1        ;get the address back
3072
   2971 FFFF29F0 1280                           MOVE.B  D0,(A1)         ;store the byte in memory
3073
   2972 FFFF29F2 6000 FD4E                      BRA     FINISH
3074
   2973 FFFF29F6                             PKER:
3075
   2974 FFFF29F6 6000 03AC                      BRA.L   QWHAT   ;       if no comma, say "What?"
3076
 
3077
   2976 FFFF29FA                             POINT:
3078
   2977 FFFF29FA 6100 00AE                      BSR EXPR
3079
   2978 FFFF29FE 6100 05D2                      BSR     TSTC
3080
   2979 FFFF2A02 2C F3                          DC.B    ',',PKER-$
3081
   2980 FFFF2A04 2F00                           MOVE.L  D0,-(SP)
3082
   2981 FFFF2A06 6100 00A2                      BSR     EXPR
3083
   2982 FFFF2A0A 221F                           MOVE.L  (SP)+,D1
3084
   2983 FFFF2A0C 2400                           MOVE.L  D0,D2
3085
   2984 FFFF2A0E 6100 EAEE                      BSR DrawPixel
3086
   2985 FFFF2A12 6000 FD2E                      BRA FINISH
3087
 
3088
   2987 FFFF2A16                             PENCOLOR:
3089
   2988 FFFF2A16 6100 0092                      BSR     EXPR
3090
   2989 FFFF2A1A 23C0 FFDA E000                 MOVE.L  d0,GRAPHICS
3091
   2990 FFFF2A20 6000 FD20                      BRA FINISH
3092
   2991 FFFF2A24                             FILLCOLOR:
3093
   2992 FFFF2A24 6100 0084                      BSR     EXPR
3094
   2993 FFFF2A28 23C0 FFDA E004                 MOVE.L  d0,GRAPHICS+4
3095
   2994 FFFF2A2E 6000 FD12                      BRA FINISH
3096
 
3097
   2996 FFFF2A32                             LINE:
3098
   2997 FFFF2A32 6100 0076                      BSR     EXPR
3099
   2998 FFFF2A36 6100 059A                      BSR     TSTC
3100
   2999 FFFF2A3A 2C 49                          DC.B    ',',LINEERR1-$
3101
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 51
3102
BOOTROM.x68
3103
   3000 FFFF2A3C 2F00                           MOVE.L  D0,-(SP)
3104
   3001 FFFF2A3E 6100 006A                      BSR     EXPR
3105
   3002 FFFF2A42 6100 058E                      BSR     TSTC
3106
   3003 FFFF2A46 2C 41                          DC.B    ',',LINEERR2-$
3107
   3004 FFFF2A48 2F00                           MOVE.L  D0,-(SP)
3108
   3005 FFFF2A4A 6100 005E                      BSR     EXPR
3109
   3006 FFFF2A4E 6100 0582                      BSR     TSTC
3110
   3007 FFFF2A52 2C 3B                          DC.B    ',',LINEERR3-$
3111
   3008 FFFF2A54 2F00                           MOVE.L  D0,-(SP)
3112
   3009 FFFF2A56 6100 0052                      BSR     EXPR
3113
                                             ;  MOVE.L  D0,D4
3114
                                             ;  MOVE.L  (SP)+,D3
3115
                                             ;  MOVE.L  (SP)+,D2
3116
                                             ;  MOVE.L  (SP)+,D1
3117
                                             ;  BSR             DrawLine
3118
   3015 FFFF2A5A 33C0 FFDA E00E                 MOVE.W  d0,GRAPHICS+14
3119
   3016 FFFF2A60 201F                           MOVE.L  (SP)+,d0
3120
   3017 FFFF2A62 33C0 FFDA E00C                 MOVE.W  d0,GRAPHICS+12
3121
   3018 FFFF2A68 201F                           MOVE.L  (SP)+,d0
3122
   3019 FFFF2A6A 33C0 FFDA E00A                 MOVE.W  d0,GRAPHICS+10
3123
   3020 FFFF2A70 201F                           MOVE.L  (SP)+,d0
3124
   3021 FFFF2A72 33C0 FFDA E008                 MOVE.W  d0,GRAPHICS+8
3125
   3022 FFFF2A78 33FC 0002 FFDA E01E            MOVE.W  #G_DRAWLINE,GRAPHICS+30
3126
   3023 FFFF2A80 6000 FCC0                      BRA             FINISH
3127
 
3128
   3025 FFFF2A84                             LINEERR1:
3129
   3026 FFFF2A84 6000 031E                      BRA.L   QWHAT
3130
   3027 FFFF2A88                             LINEERR2:
3131
   3028 FFFF2A88 588F                           ADDQ    #4,SP
3132
   3029 FFFF2A8A 6000 0318                      BRA.L   QWHAT
3133
   3030 FFFF2A8E                             LINEERR3:
3134
   3031 FFFF2A8E 508F                           ADD.L   #8,SP
3135
   3032 FFFF2A90 6000 0312                      BRA.L   QWHAT
3136
 
3137
   3034 FFFF2A94                             CALL:
3138
   3035 FFFF2A94 6100 0014                      BSR     EXPR            ;get the subroutine's address
3139
   3036 FFFF2A98 4A80                           TST.L   D0              ;make sure we got a valid address
3140
   3037 FFFF2A9A 6700 0354                      BEQ.L   QHOW    ;       if not, say "How?"
3141
   3038 FFFF2A9E 2F08                           MOVE.L  A0,-(SP);       save the text pointer
3142
   3039 FFFF2AA0 2240                           MOVE.L  D0,A1
3143
   3040 FFFF2AA2 4E91                           JSR     (A1)            ;jump to the subroutine
3144
   3041 FFFF2AA4 205F                           MOVE.L  (SP)+,A0        ;restore the text pointer
3145
   3042 FFFF2AA6 6000 FC9A                      BRA     FINISH
3146
                                             ;*
3147
                                             ;*******************************************************************
3148
                                             ;*
3149
                                             ;* *** EXPR ***
3150
                                             ;*
3151
                                             ;* 'EXPR' evaluates arithmetical or logical expressions.
3152
                                             ;* ::=
3153
                                             ;*    
3154
                                             ;* where  is one of the operators in TAB8 and the result
3155
                                             ;* of these operations is 1 if true and 0 if false.
3156
                                             ;* ::=(+,-,&,|)(+,-,&,|)(...
3157
                                             ;* where () are optional and (... are optional repeats.
3158
                                             ;* ::=( <* or /> )(...
3159
                                             ;* ::=
3160
                                             ;*     
3161
                                             ;*     ()
3162
                                             ;*  is recursive so that the variable '@' can have an 
3163
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 52
3164
BOOTROM.x68
3165
                                             ;* as an index, functions can have an  as arguments, and
3166
                                             ;*  can be an  in parenthesis.
3167
                                             ;*
3168
   3063 FFFF2AAA                             EXPR:
3169
   3064 FFFF2AAA 6100 0066                      BSR     EXPR2
3170
   3065 FFFF2AAE 2F00                           MOVE.L  D0,-(SP);       save  value
3171
   3066 FFFF2AB0 43F9 FFFF 258B                 LEA     TAB8,A1         ;look up a relational operator
3172
   3067 FFFF2AB6 45F9 FFFF 25E0                 LEA     TAB8_1,A2
3173
   3068 FFFF2ABC 6000 FB3C                      BRA     EXEC            ;go do it
3174
 
3175
   3070 FFFF2AC0                             XP11:
3176
   3071 FFFF2AC0 6100 003E                      BSR     XP18    ;       is it ">="?
3177
   3072 FFFF2AC4 6D2E                           BLT     XPRT0           ;no, return D0=0
3178
   3073 FFFF2AC6 6030                           BRA     XPRT1           ;else return D0=1
3179
 
3180
   3075 FFFF2AC8                             XP12:
3181
   3076 FFFF2AC8 6100 0036                      BSR     XP18    ;       is it "<>"?
3182
   3077 FFFF2ACC 6726                           BEQ     XPRT0           ;no, return D0=0
3183
   3078 FFFF2ACE 6028                           BRA     XPRT1           ;else return D0=1
3184
 
3185
   3080 FFFF2AD0                             XP13:
3186
   3081 FFFF2AD0 6100 002E                      BSR     XP18    ;       is it ">"?
3187
   3082 FFFF2AD4 6F1E                           BLE     XPRT0           ;no, return D0=0
3188
   3083 FFFF2AD6 6020                           BRA     XPRT1           ;else return D0=1
3189
 
3190
   3085 FFFF2AD8                             XP14:
3191
   3086 FFFF2AD8 6100 0026                      BSR     XP18    ;       is it "<="?
3192
   3087 FFFF2ADC 6E16                           BGT     XPRT0           ;no, return D0=0
3193
   3088 FFFF2ADE 6018                           BRA     XPRT1           ;else return D0=1
3194
 
3195
   3090 FFFF2AE0                             XP15:
3196
   3091 FFFF2AE0 6100 001E                      BSR     XP18    ;       is it "="?
3197
   3092 FFFF2AE4 660E                           BNE     XPRT0           ;if not, return D0=0
3198
   3093 FFFF2AE6 6010                           BRA     XPRT1           ;else return D0=1
3199
   3094 FFFF2AE8                             XP15RT:
3200
   3095 FFFF2AE8 4E75                           RTS
3201
 
3202
   3097 FFFF2AEA                             XP16:
3203
   3098 FFFF2AEA 6100 0014                      BSR     XP18    ;       is it "<"?
3204
   3099 FFFF2AEE 6C04                           BGE     XPRT0           ;if not, return D0=0
3205
   3100 FFFF2AF0 6006                           BRA     XPRT1           ;else return D0=1
3206
   3101 FFFF2AF2                             XP16RT:
3207
   3102 FFFF2AF2 4E75                           RTS
3208
 
3209
   3104 FFFF2AF4                             XPRT0:
3210
   3105 FFFF2AF4 4280                           CLR.L   D0      ;       return D0=0 (false)
3211
   3106 FFFF2AF6 4E75                           RTS
3212
 
3213
   3108 FFFF2AF8                             XPRT1:
3214
   3109 FFFF2AF8 7001                           MOVEQ   #1,D0;          return D0=1 (true)
3215
   3110 FFFF2AFA 4E75                           RTS
3216
 
3217
   3112 FFFF2AFC                             XP17:
3218
   3113 FFFF2AFC 201F                           MOVE.L  (SP)+,D0        ;it's not a rel. operator
3219
   3114 FFFF2AFE 4E75                           RTS                     ;return D0=
3220
 
3221
   3116 FFFF2B00                             XP18:
3222
   3117 FFFF2B00 201F                           MOVE.L  (SP)+,D0        ;reverse the top two stack items
3223
   3118 FFFF2B02 221F                           MOVE.L  (SP)+,D1
3224
   3119 FFFF2B04 2F00                           MOVE.L  D0,-(SP)
3225
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 53
3226
BOOTROM.x68
3227
   3120 FFFF2B06 2F01                           MOVE.L  D1,-(SP)
3228
   3121 FFFF2B08 6100 0008                      BSR     EXPR2           ;do second 
3229
   3122 FFFF2B0C 221F                           MOVE.L  (SP)+,D1
3230
   3123 FFFF2B0E B280                           CMP.L   D0,D1   ;       compare with the first result
3231
   3124 FFFF2B10 4E75                           RTS                     ;return the result
3232
 
3233
   3126 FFFF2B12                             EXPR2:
3234
   3127 FFFF2B12 6100 04BE                      BSR.L   TSTC            ;negative sign?
3235
   3128 FFFF2B16 2D 05                          DC.B    '-',XP20-$
3236
   3129 FFFF2B18 4280                           CLR.L   D0      ;       yes, fake '0-'
3237
   3130 FFFF2B1A 603C                           BRA     XP26
3238
   3131 FFFF2B1C                             XP20:
3239
   3132 FFFF2B1C 6100 04B4                      BSR.L   TSTC
3240
   3133 FFFF2B20 21 11                          DC.B    '!',XP21-$
3241
   3134 FFFF2B22 4280                           CLR.L   D0
3242
   3135 FFFF2B24 2F00                           MOVE.L  D0,-(SP)
3243
   3136 FFFF2B26 6100 0062                      BSR             EXPR3
3244
   3137 FFFF2B2A 4680                           NOT.L   D0
3245
   3138 FFFF2B2C 4EF9 FFFF 2B48                 JMP             XP24
3246
   3139 FFFF2B32                             XP21:
3247
   3140 FFFF2B32 6100 049E                      BSR.L   TSTC    ;       positive sign? ignore it
3248
   3141 FFFF2B36 2B 01                          DC.B    '+',XP22-$
3249
   3142 FFFF2B38                             XP22:
3250
   3143 FFFF2B38 6100 0050                      BSR     EXPR3           ;first 
3251
   3144 FFFF2B3C                             XP23:
3252
   3145 FFFF2B3C 6100 0494                      BSR.L   TSTC    ;       add?
3253
   3146 FFFF2B40 2B 11                          DC.B    '+',XP25-$
3254
   3147 FFFF2B42 2F00                           MOVE.L  D0,-(SP)        ;yes, save the value
3255
   3148 FFFF2B44 6100 0044                      BSR     EXPR3           ;get the second 
3256
   3149 FFFF2B48                             XP24:
3257
   3150 FFFF2B48 221F                           MOVE.L  (SP)+,D1
3258
   3151 FFFF2B4A D081                           ADD.L   D1,D0   ;       add it to the first 
3259
   3152 FFFF2B4C 6900 02A2                      BVS.L   QHOW    ;       branch if there's an overflow
3260
   3153 FFFF2B50 60EA                           BRA     XP23    ;       else go back for more operations
3261
   3154 FFFF2B52                             XP25:
3262
   3155 FFFF2B52 6100 047E                      BSR.L   TSTC            ;subtract?
3263
   3156 FFFF2B56 2D 0F                          DC.B    '-',XP27-$      ; was XP42-$
3264
   3157 FFFF2B58                             XP26:
3265
   3158 FFFF2B58 2F00                           MOVE.L  D0,-(SP)        ;yes, save the result of 1st 
3266
   3159 FFFF2B5A 6100 002E                      BSR     EXPR3           ;get second 
3267
   3160 FFFF2B5E 4480                           NEG.L   D0              ;change its sign
3268
   3161 FFFF2B60 4EF9 FFFF 2B48                 JMP     XP24            ;and do an addition
3269
   3162 FFFF2B66                             XP27:
3270
   3163 FFFF2B66 6100 046A                      BSR.L   TSTC
3271
   3164 FFFF2B6A 26 0D                          DC.B    '&',XP28-$
3272
   3165 FFFF2B6C 2F00                           MOVE.L  D0,-(SP)
3273
   3166 FFFF2B6E 6100 001A                      BSR     EXPR3
3274
   3167 FFFF2B72 221F                           MOVE.L  (SP)+,D1
3275
   3168 FFFF2B74 C081                           AND.L   D1,D0
3276
   3169 FFFF2B76 60C4                           BRA             XP23
3277
   3170 FFFF2B78                             XP28:
3278
   3171 FFFF2B78 6100 0458                      BSR.L   TSTC
3279
   3172 FFFF2B7C 7C 73                          DC.B    '|',XP42-$
3280
   3173 FFFF2B7E 2F00                           MOVE.L  D0,-(SP)
3281
   3174 FFFF2B80 6100 0008                      BSR     EXPR3
3282
   3175 FFFF2B84 221F                           MOVE.L  (SP)+,D1
3283
   3176 FFFF2B86 8081                           OR.L    D1,D0
3284
   3177 FFFF2B88 60B2                           BRA             XP23
3285
 
3286
   3179 FFFF2B8A                             EXPR3:
3287
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 54
3288
BOOTROM.x68
3289
   3180 FFFF2B8A 6100 002C                      BSR     EXPR4           ;get first 
3290
   3181 FFFF2B8E                             XP31:
3291
   3182 FFFF2B8E 6100 0442                      BSR.L   TSTC    ;       multiply?
3292
   3183 FFFF2B92 2A 0F                          DC.B    '*',XP34-$
3293
   3184 FFFF2B94 2F00                           MOVE.L  D0,-(SP);       yes, save that first result
3294
   3185 FFFF2B96 6100 0020                      BSR     EXPR4           ;get second 
3295
   3186 FFFF2B9A 221F                           MOVE.L  (SP)+,D1
3296
   3187 FFFF2B9C 6100 00D2                      BSR.L   MULT32  ;       multiply the two
3297
   3188 FFFF2BA0 60EC                           BRA     XP31            ;then look for more terms
3298
   3189 FFFF2BA2                             XP34:
3299
   3190 FFFF2BA2 6100 042E                      BSR.L   TSTC;           divide?
3300
   3191 FFFF2BA6 2F 49                          DC.B    '/',XP42-$
3301
   3192 FFFF2BA8 2F00                           MOVE.L  D0,-(SP);       save result of 1st 
3302
   3193 FFFF2BAA 6100 000C                      BSR     EXPR4           ;get second 
3303
   3194 FFFF2BAE 221F                           MOVE.L  (SP)+,D1
3304
   3195 FFFF2BB0 C141                           EXG     D0,D1
3305
   3196 FFFF2BB2 6100 00FE                      BSR.L   DIV32   ;       do the division
3306
   3197 FFFF2BB6 60D6                           BRA     XP31            ;go back for any more terms
3307
 
3308
   3199 FFFF2BB8                             EXPR4:
3309
   3200 FFFF2BB8 43F9 FFFF 2569                 LEA     TAB4,A1 ;       find possible function
3310
   3201 FFFF2BBE 45F9 FFFF 25C8                 LEA     TAB4_1,A2
3311
   3202 FFFF2BC4 6000 FA34                      BRA     EXEC
3312
   3203 FFFF2BC8                             XP40:
3313
   3204 FFFF2BC8 6100 002C                      BSR     TSTV    ;       nope, not a function
3314
   3205 FFFF2BCC 6508                           BCS     XP41            ;nor a variable
3315
   3206 FFFF2BCE 2240                           MOVE.L  D0,A1
3316
   3207 FFFF2BD0 4280                           CLR.L   D0
3317
   3208 FFFF2BD2 2011                           MOVE.L  (A1),D0 ;       if a variable, return its value in D0
3318
   3209 FFFF2BD4                             EXP4RT:
3319
   3210 FFFF2BD4 4E75                           RTS
3320
   3211 FFFF2BD6                             XP41:
3321
   3212 FFFF2BD6 6100 0414                      BSR.L   TSTNUM  ;       or is it a number?
3322
   3213 FFFF2BDA 2001                           MOVE.L  D1,D0
3323
   3214 FFFF2BDC 4A82                           TST     D2              ;(if not, # of digits will be zero)
3324
   3215 FFFF2BDE 66F4                           BNE     EXP4RT  ;       if so, return it in D0
3325
   3216 FFFF2BE0                             PARN:
3326
   3217 FFFF2BE0 6100 03F0                      BSR.L   TSTC    ;       else look for ( EXPR )
3327
   3218 FFFF2BE4 28 0D                          DC.B    '(',XP43-$
3328
   3219 FFFF2BE6 6100 FEC2                      BSR     EXPR
3329
   3220 FFFF2BEA 6100 03E6                      BSR.L   TSTC
3330
   3221 FFFF2BEE 29 03                          DC.B    ')',XP43-$
3331
   3222 FFFF2BF0                             XP42:
3332
   3223 FFFF2BF0 4E75                           RTS
3333
   3224 FFFF2BF2                             XP43:
3334
   3225 FFFF2BF2 6000 01B0                      BRA.L   QWHAT   ;       else say "What?"
3335
 
3336
                                             ;*
3337
                                             ;* ===== Test for a valid variable name.  Returns Carry=1 if not
3338
                                             ;* found, else returns Carry=0 and the address of the
3339
                                             ;* variable in D0.
3340
 
3341
   3232 FFFF2BF6                             TSTV:
3342
   3233 FFFF2BF6 6100 042C                      BSR.L   IGNBLK
3343
   3234 FFFF2BFA 4280                           CLR.L   D0
3344
   3235 FFFF2BFC 1010                           MOVE.B  (A0),D0 ;       look at the program text
3345
   3236 FFFF2BFE 0400 0040                      SUB.B   #'@',D0
3346
   3237 FFFF2C02 6554                           BCS     TSTVRT  ;       C=1: not a variable
3347
   3238 FFFF2C04 6628                           BNE     TV1             ;branch if not "@" array
3348
   3239 FFFF2C06 5288                           ADDQ    #1,A0   ;       If it is, it should be
3349
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 55
3350
BOOTROM.x68
3351
   3240 FFFF2C08 6100 FFD6                      BSR     PARN            ;followed by (EXPR) as its index.
3352
   3241 FFFF2C0C D080                           ADD.L   D0,D0
3353
   3242 FFFF2C0E 6500 01E0                      BCS.L   QHOW    ;       say "How?" if index is too big
3354
   3243 FFFF2C12 D080                           ADD.L   D0,D0
3355
   3244 FFFF2C14 6500 01DA                      BCS.L   QHOW
3356
   3245 FFFF2C18 2F00                           MOVE.L  D0,-(SP)        ;save the index
3357
   3246 FFFF2C1A 6100 012C                      BSR.L   SIZE_           ;get amount of free memory
3358
   3247 FFFF2C1E 221F                           MOVE.L  (SP)+,D1        ;get back the index
3359
   3248 FFFF2C20 B081                           CMP.L   D1,D0           ;see if there's enough memory
3360
   3249 FFFF2C22 6300 01C2                      BLS.L   QSORRY          ;if not, say "Sorry"
3361
   3250 FFFF2C26 2038 0628                      MOVE.L  VARBGN,D0       ;put address of array element...
3362
   3251 FFFF2C2A 9081                           SUB.L   D1,D0           ;into D0
3363
   3252 FFFF2C2C 4E75                           RTS
3364
   3253 FFFF2C2E                             TV1:
3365
   3254 FFFF2C2E B03C 001B                      CMP.B   #27,D0          ;if not @, is it A through Z?
3366
   3255 FFFF2C32 0A3C 0001                      EOR     #1,CCR
3367
   3256 FFFF2C36 6520                           BCS     TSTVRT          ;if not, set Carry and return
3368
   3257 FFFF2C38 5288                           ADDQ    #1,A0   ;       else bump the text pointer
3369
                                             ;
3370
   3259 FFFF2C3A 4281                           CLR.L   D1
3371
   3260 FFFF2C3C 1210                           MOVE.B  (a0),D1
3372
   3261 FFFF2C3E 6100 001A                      BSR             CVT26
3373
   3262 FFFF2C42 0C01 00FF                      cmpi.b  #0xff,d1
3374
   3263 FFFF2C46 6706                           beq             tv2
3375
   3264 FFFF2C48 5288                           ADDQ    #1,A0   ; bump text pointer
3376
   3265 FFFF2C4A EB81                           asl.l   #5,D1
3377
   3266 FFFF2C4C D081                           ADD.L   D1,D0
3378
   3267 FFFF2C4E                             tv2:
3379
   3268 FFFF2C4E D080                           ADD     D0,D0           ;compute the variable's address
3380
   3269 FFFF2C50 D080                           ADD     D0,D0
3381
   3270 FFFF2C52 2238 0628                      MOVE.L  VARBGN,D1
3382
   3271 FFFF2C56 D081                           ADD     D1,D0           ;and return it in D0 with Carry=0
3383
   3272 FFFF2C58                             TSTVRT:
3384
   3273 FFFF2C58 4E75                           RTS
3385
 
3386
   3275 FFFF2C5A                             CVT26:
3387
   3276 FFFF2C5A 0C01 0041                      cmpi.b  #'A',d1
3388
   3277 FFFF2C5E 650C                           blo             CVT26a
3389
   3278 FFFF2C60 0C01 005A                      cmpi.b  #'Z',d1
3390
   3279 FFFF2C64 6206                           bhi             CVT26a
3391
   3280 FFFF2C66 0401 0041                      subi.b  #'A',d1
3392
   3281 FFFF2C6A 4E75                           rts
3393
   3282 FFFF2C6C                             CVT26a:
3394
   3283 FFFF2C6C 72FF                           moveq   #-1,d1
3395
   3284 FFFF2C6E 4E75                           rts
3396
                                             ;*
3397
                                             ;* ===== Multiplies the 32 bit values in D0 and D1, returning
3398
                                             ;* the 32 bit result in D0.
3399
                                             ;*
3400
   3289 FFFF2C70                             MULT32:
3401
   3290 FFFF2C70 2801                           MOVE.L  D1,D4
3402
   3291 FFFF2C72 B184                           EOR.L   D0,D4   ;       see if the signs are the same
3403
   3292 FFFF2C74 4A80                           TST.L   D0              ;take absolute value of D0
3404
   3293 FFFF2C76 6A02                           BPL     MLT1
3405
   3294 FFFF2C78 4480                           NEG.L   D0
3406
   3295 FFFF2C7A                             MLT1:
3407
   3296 FFFF2C7A 4A81                           TST.L   D1      ;       take absolute value of D1
3408
   3297 FFFF2C7C 6A02                           BPL     MLT2
3409
   3298 FFFF2C7E 4481                           NEG.L   D1
3410
   3299 FFFF2C80                             MLT2:
3411
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 56
3412
BOOTROM.x68
3413
   3300 FFFF2C80 B2BC 0000 FFFF                 CMP.L   #0xFFFF,D1      ;is second argument <= 16 bits?
3414
   3301 FFFF2C86 630C                           BLS     MLT3    ;       OK, let it through
3415
   3302 FFFF2C88 C141                           EXG     D0,D1   ;       else swap the two arguments
3416
   3303 FFFF2C8A B2BC 0000 FFFF                 CMP.L   #0xFFFF,D1      ;and check 2nd argument again
3417
   3304 FFFF2C90 6200 015E                      BHI.L   QHOW            ;one of them MUST be 16 bits
3418
   3305 FFFF2C94                             MLT3:
3419
   3306 FFFF2C94 2400                           MOVE    D0,D2   ;       prepare for 32 bit X 16 bit multiply
3420
   3307 FFFF2C96 C4C1                           MULU    D1,D2           ;multiply low word
3421
   3308 FFFF2C98 4840                           SWAP    D0
3422
   3309 FFFF2C9A C0C1                           MULU    D1,D0           ;multiply high word
3423
   3310 FFFF2C9C 4840                           SWAP    D0
3424
                                             ;*** Rick Murray's bug correction follows:
3425
   3312 FFFF2C9E 4A80                           TST     D0              ;if lower word not 0, then overflow
3426
   3313 FFFF2CA0 6600 014E                      BNE.L   QHOW    ;       if overflow, say "How?"
3427
   3314 FFFF2CA4 D082                           ADD.L   D2,D0   ;       D0 now holds the product
3428
   3315 FFFF2CA6 6B00 0148                      BMI.L   QHOW    ;       if sign bit set, it's an overflow
3429
   3316 FFFF2CAA 4A84                           TST.L   D4              ;were the signs the same?
3430
   3317 FFFF2CAC 6A02                           BPL     MLTRET
3431
   3318 FFFF2CAE 4480                           NEG.L   D0              ;if not, make the result negative
3432
   3319 FFFF2CB0                             MLTRET:
3433
   3320 FFFF2CB0 4E75                           RTS
3434
 
3435
                                             ;*
3436
                                             ;* ===== Divide the 32 bit value in D0 by the 32 bit value in D1.
3437
                                             ;* Returns the 32 bit quotient in D0, remainder in D1.
3438
                                             ;*
3439
   3326 FFFF2CB2                             DIV32:
3440
   3327 FFFF2CB2 4A81                           TST.L   D1              ;check for divide-by-zero
3441
   3328 FFFF2CB4 6700 013A                      BEQ.L   QHOW            ;if so, say "How?"
3442
   3329 FFFF2CB8 2401                           MOVE.L  D1,D2
3443
   3330 FFFF2CBA 2801                           MOVE.L  D1,D4
3444
   3331 FFFF2CBC B184                           EOR.L   D0,D4           ;see if the signs are the same
3445
   3332 FFFF2CBE 4A80                           TST.L   D0              ;take absolute value of D0
3446
   3333 FFFF2CC0 6A02                           BPL     DIV1
3447
   3334 FFFF2CC2 4480                           NEG.L   D0
3448
   3335 FFFF2CC4                             DIV1:
3449
   3336 FFFF2CC4 4A81                           TST.L   D1      ;       take absolute value of D1
3450
   3337 FFFF2CC6 6A02                           BPL     DIV2
3451
   3338 FFFF2CC8 4481                           NEG.L   D1
3452
   3339 FFFF2CCA                             DIV2:
3453
   3340 FFFF2CCA 761F                           MOVEQ   #31,D3  ;       iteration count for 32 bits
3454
   3341 FFFF2CCC 2200                           MOVE.L  D0,D1
3455
   3342 FFFF2CCE 4280                           CLR.L   D0
3456
   3343 FFFF2CD0                             DIV3:
3457
   3344 FFFF2CD0 D281                           ADD.L   D1,D1   ;       (This algorithm was translated from
3458
   3345 FFFF2CD2 D180                           ADDX.L  D0,D0           ;the divide routine in Ron Cain's
3459
   3346 FFFF2CD4 6708                           BEQ     DIV4            ;Small-C run time library.)
3460
   3347 FFFF2CD6 B082                           CMP.L   D2,D0
3461
   3348 FFFF2CD8 6B04                           BMI     DIV4
3462
   3349 FFFF2CDA 5281                           ADDQ.L  #1,D1
3463
   3350 FFFF2CDC 9082                           SUB.L   D2,D0
3464
   3351 FFFF2CDE                             DIV4:
3465
   3352 FFFF2CDE 51CB FFF0                      DBRA    D3,DIV3
3466
   3353 FFFF2CE2 C141                           EXG     D0,D1   ;       put rem. & quot. in proper registers
3467
   3354 FFFF2CE4 4A84                           TST.L   D4      ;       were the signs the same?
3468
   3355 FFFF2CE6 6A04                           BPL     DIVRT
3469
   3356 FFFF2CE8 4480                           NEG.L   D0      ;       if not, results are negative
3470
   3357 FFFF2CEA 4481                           NEG.L   D1
3471
   3358 FFFF2CEC                             DIVRT:
3472
   3359 FFFF2CEC 4E75                           RTS
3473
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 57
3474
BOOTROM.x68
3475
 
3476
                                             ;*
3477
                                             ;* ===== The PEEK function returns the byte stored at the address
3478
                                             ;* contained in the following expression.
3479
                                             ;*
3480
   3365 FFFF2CEE                             PEEK:
3481
   3366 FFFF2CEE 6100 FEF0                      BSR     PARN    ;       get the memory address
3482
   3367 FFFF2CF2 2240                           MOVE.L  D0,A1
3483
   3368 FFFF2CF4 4280                           CLR.L   D0              ;upper 3 bytes will be zero
3484
   3369 FFFF2CF6 1011                           MOVE.B  (A1),D0 ;       get the addressed byte
3485
   3370 FFFF2CF8 4E75                           RTS                     ;and return it
3486
 
3487
                                             ;*
3488
                                             ;* ===== The RND function returns a random number from 1 to
3489
                                             ;* the value of the following expression in D0.
3490
                                             ;*
3491
   3376 FFFF2CFA                             RND:
3492
   3377 FFFF2CFA 6100 FEE4                      BSR     PARN    ;       get the upper limit
3493
   3378 FFFF2CFE 4A80                           TST.L   D0      ;       it must be positive and non-zero
3494
   3379 FFFF2D00 6700 00EE                      BEQ.L   QHOW
3495
   3380 FFFF2D04 6B00 00EA                      BMI.L   QHOW
3496
 
3497
                                             ;  move.l  d0,-(a7)
3498
                                             ;  move.l  RANPNT,D1
3499
                                             ;  move.l  #16807,d0
3500
                                             ;  bsr             MULT32
3501
                                             ;  move.l  d0,RANPNT
3502
                                             ;  move.l  (a7)+,d1
3503
   3388 FFFF2D08 2200                           MOVE.L  D0,D1
3504
   3389 FFFF2D0A 3039 FFDC 0C02                 MOVE.W  RANDOM+2,D0
3505
   3390 FFFF2D10 4840                           SWAP    D0
3506
   3391 FFFF2D12 3039 FFDC 0C00                 MOVE.W  RANDOM,D0
3507
 
3508
                                             ;  MOVE.L  D0,D1
3509
                                             ;  MOVE.L  RANPNT,A1       ;get memory as a random number
3510
                                             ;  CMP.L   #LSTROM,A1
3511
                                             ;  BCS     RA1
3512
                                             ;  LEA     START,A1        ;wrap around if end of program
3513
                                             ;RA1:
3514
                                             ;  MOVE.L  (A1)+,D0;       get the slightly random number
3515
   3400 FFFF2D18 0880 001F                      BCLR    #31,D0  ;       make sure it's positive
3516
                                             ;  MOVE.L  A1,RANPNT       ;(even I can do better than this!)
3517
   3402 FFFF2D1C 6100 FF94                      BSR     DIV32           ;RND(n)=MOD(number,n)+1
3518
   3403 FFFF2D20 2001                           MOVE.L  D1,D0   ;       MOD is the remainder of the div.
3519
   3404 FFFF2D22 5280                           ADDQ.L  #1,D0
3520
   3405 FFFF2D24 4E75                           RTS
3521
 
3522
                                             ;*
3523
                                             ;* ===== The ABS function returns an absolute value in D0.
3524
                                             ;*
3525
   3410 FFFF2D26                             ABS:
3526
   3411 FFFF2D26 6100 FEB8                      BSR     PARN            ;get the following expr.'s value
3527
   3412 FFFF2D2A 4A80                           TST.L   D0
3528
   3413 FFFF2D2C 6A06                           BPL     ABSRT
3529
   3414 FFFF2D2E 4480                           NEG.L   D0              ;if negative, complement it
3530
   3415 FFFF2D30 6B00 00BE                      BMI.L   QHOW    ;       if still negative, it was too big
3531
   3416 FFFF2D34                             ABSRT:
3532
   3417 FFFF2D34 4E75                           RTS
3533
 
3534
                                             ;* RTF
3535
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 58
3536
BOOTROM.x68
3537
                                             ;* ===== The SGN function returns the sign value in D0.
3538
                                             ;*
3539
   3422 FFFF2D36                             SGN:
3540
   3423 FFFF2D36 6100 FEA8                      BSR             PARN    ;get the following expr.'s value
3541
   3424 FFFF2D3A 4A80                           TST.L   D0
3542
   3425 FFFF2D3C 6704                           BEQ             SGNRT
3543
   3426 FFFF2D3E 6B04                           BMI             SGNMI
3544
   3427 FFFF2D40 7001                           MOVEQ   #1,d0
3545
   3428 FFFF2D42                             SGNRT:
3546
   3429 FFFF2D42 4E75                           RTS
3547
   3430 FFFF2D44                             SGNMI:
3548
   3431 FFFF2D44 70FF                           MOVEQ   #-1,d0
3549
   3432 FFFF2D46 4E75                           RTS
3550
 
3551
                                             ;*
3552
                                             ;* ===== The SIZE function returns the size of free memory in D0.
3553
                                             ;*
3554
   3437 FFFF2D48                             SIZE_:
3555
   3438 FFFF2D48 2038 0628                      MOVE.L  VARBGN,D0       ;get the number of free bytes...
3556
   3439 FFFF2D4C 90B8 0624                      SUB.L   TXTUNF,D0       ;between 'TXTUNF' and 'VARBGN'
3557
   3440 FFFF2D50 4E75                           RTS                     ;return the number in D0
3558
 
3559
                                             ;* RTF
3560
                                             ;* ===== return the millisecond time value
3561
                                             ;*
3562
   3445 FFFF2D52                             TICK:
3563
   3446 FFFF2D52 2038 0400                      move.l  Milliseconds,d0
3564
   3447 FFFF2D56 4E75                           rts
3565
 
3566
   3449 FFFF2D58                             TEMP:
3567
   3450 FFFF2D58 6100 F154                      bsr             ReadTemp
3568
   3451 FFFF2D5C 0280 0000 FFFF                 andi.l  #0xffff,d0
3569
   3452 FFFF2D62 4E75                           rts
3570
 
3571
                                             ;*
3572
                                             ;*******************************************************************
3573
                                             ;*
3574
                                             ;* *** SETVAL *** FIN *** ENDCHK *** ERROR (& friends) ***
3575
                                             ;*
3576
                                             ;* 'SETVAL' expects a variable, followed by an equal sign and then
3577
                                             ;* an expression.  It evaluates the expression and sets the variable
3578
                                             ;* to that value.
3579
                                             ;*
3580
                                             ;* 'FIN' checks the end of a command.  If it ended with ":",
3581
                                             ;* execution continues.    If it ended with a CR, it finds the
3582
                                             ;* the next line and continues from there.
3583
                                             ;*
3584
                                             ;* 'ENDCHK' checks if a command is ended with a CR. This is
3585
                                             ;* required in certain commands, such as GOTO, RETURN, STOP, etc.
3586
                                             ;*
3587
                                             ;* 'ERROR' prints the string pointed to by A0. It then prints the
3588
                                             ;* line pointed to by CURRNT with a "?" inserted at where the
3589
                                             ;* old text pointer (should be on top of the stack) points to.
3590
                                             ;* Execution of Tiny BASIC is stopped and a warm start is done.
3591
                                             ;* If CURRNT is zero (indicating a direct command), the direct
3592
                                             ;* command is not printed. If CURRNT is -1 (indicating
3593
                                             ;* 'INPUT' command in progress), the input line is not printed
3594
                                             ;* and execution is not terminated but continues at 'INPERR'.
3595
                                             ;*
3596
                                             ;* Related to 'ERROR' are the following:
3597
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 59
3598
BOOTROM.x68
3599
                                             ;* 'QWHAT' saves text pointer on stack and gets "What?" message.
3600
                                             ;* 'AWHAT' just gets the "What?" message and jumps to 'ERROR'.
3601
                                             ;* 'QSORRY' and 'ASORRY' do the same kind of thing.
3602
                                             ;* 'QHOW' and 'AHOW' also do this for "How?".
3603
                                             ;*
3604
   3485 FFFF2D64                             SETVAL:
3605
   3486 FFFF2D64 6100 FE90                      BSR     TSTV    ;       variable name?
3606
   3487 FFFF2D68 653A                           BCS     QWHAT           ;if not, say "What?"
3607
   3488 FFFF2D6A 2F00                           MOVE.L  D0,-(SP);       save the variable's address
3608
   3489 FFFF2D6C 6100 0264                      BSR.L   TSTC    ;       get past the "=" sign
3609
   3490 FFFF2D70 3D 0B                          DC.B    '=',SV1-$
3610
   3491 FFFF2D72 6100 FD36                      BSR     EXPR    ;       evaluate the expression
3611
   3492 FFFF2D76 2C5F                           MOVE.L  (SP)+,A6
3612
   3493 FFFF2D78 2C80                           MOVE.L  D0,(A6) ;       and save its value in the variable
3613
   3494 FFFF2D7A 4E75                           RTS
3614
   3495 FFFF2D7C                             SV1:
3615
   3496 FFFF2D7C 6026                           BRA     QWHAT   ;       if no "=" sign
3616
 
3617
   3498 FFFF2D7E                             FIN:
3618
   3499 FFFF2D7E 6100 0252                      BSR.L   TSTC    ;       *** FIN ***
3619
   3500 FFFF2D82 3A 07                          DC.B    ':',FI1-$
3620
   3501 FFFF2D84 588F                           ADDQ.L  #4,SP   ;       if ":", discard return address
3621
   3502 FFFF2D86 6000 F904                      BRA     RUNSML  ;       continue on the same line
3622
   3503 FFFF2D8A                             FI1:
3623
   3504 FFFF2D8A 6100 0246                      BSR.L   TSTC    ;       not ":", is it a CR?
3624
   3505 FFFF2D8E 0D 07                          DC.B    CR,FI2-$
3625
   3506 FFFF2D90 588F                           ADDQ.L  #4,SP   ;       yes, purge return address
3626
   3507 FFFF2D92 6000 F8DC                      BRA     RUNNXL          ;execute the next line
3627
   3508 FFFF2D96                             FI2:
3628
   3509 FFFF2D96 4E75                           RTS                     ;else return to the caller
3629
 
3630
   3511 FFFF2D98                             ENDCHK:
3631
   3512 FFFF2D98 6100 028A                      BSR.L   IGNBLK
3632
   3513 FFFF2D9C 0C10 000D                      CMP.B   #CR,(A0);       does it end with a CR?
3633
   3514 FFFF2DA0 6602                           BNE     QWHAT   ;       if not, say "WHAT?"
3634
   3515 FFFF2DA2 4E75                           RTS
3635
 
3636
   3517 FFFF2DA4                             QWHAT:
3637
   3518 FFFF2DA4 2F08                           MOVE.L  A0,-(SP)
3638
   3519 FFFF2DA6                             AWHAT:
3639
   3520 FFFF2DA6 4DF9 FFFF 312C                 LEA     WHTMSG,A6
3640
   3521 FFFF2DAC                             ERROR:
3641
   3522 FFFF2DAC 6100 02E6                      BSR.L   PRMESG  ;       display the error message
3642
   3523 FFFF2DB0 205F                           MOVE.L  (SP)+,A0        ;restore the text pointer
3643
   3524 FFFF2DB2 2038 0604                      MOVE.L  CURRNT,D0       ;get the current line number
3644
   3525 FFFF2DB6 6700 F6A8                      BEQ     WSTART          ;if zero, do a warm start
3645
   3526 FFFF2DBA B0BC FFFF FFFF                 CMP.L   #-1,D0          ;is the line no. pointer = -1?
3646
   3527 FFFF2DC0 6700 FAAA                      BEQ     INPERR          ;if so, redo input
3647
   3528 FFFF2DC4 1F10                           MOVE.B  (A0),-(SP)      ;save the char. pointed to
3648
   3529 FFFF2DC6 4210                           CLR.B   (A0)            ;put a zero where the error is
3649
   3530 FFFF2DC8 2278 0604                      MOVE.L  CURRNT,A1       ;point to start of current line
3650
   3531 FFFF2DCC 6100 01E8                      BSR.L   PRTLN           ;display the line in error up to the 0
3651
   3532 FFFF2DD0 109F                           MOVE.B  (SP)+,(A0)      ;restore the character
3652
   3533 FFFF2DD2 103C 003F                      MOVE.B  #'?',D0     ;    display a "?"
3653
   3534 FFFF2DD6 6100 F630                      BSR     GOOUT
3654
   3535 FFFF2DDA 4280                           CLR     D0
3655
   3536 FFFF2DDC 5389                           SUBQ.L  #1,A1           ;point back to the error char.
3656
   3537 FFFF2DDE 6100 013E                      BSR.L   PRTSTG          ;display the rest of the line
3657
   3538 FFFF2DE2 6000 F67C                      BRA     WSTART          ;and do a warm start
3658
   3539 FFFF2DE6                             QSORRY:
3659
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 60
3660
BOOTROM.x68
3661
   3540 FFFF2DE6 2F08                           MOVE.L  A0,-(SP)
3662
   3541 FFFF2DE8                             ASORRY:
3663
   3542 FFFF2DE8 4DF9 FFFF 3134                 LEA     SRYMSG,A6
3664
   3543 FFFF2DEE 60BC                           BRA     ERROR
3665
   3544 FFFF2DF0                             QHOW:
3666
   3545 FFFF2DF0 2F08                           MOVE.L  A0,-(SP)        ;Error: "How?"
3667
   3546 FFFF2DF2                             AHOW:
3668
   3547 FFFF2DF2 4DF9 FFFF 3125                 LEA     HOWMSG,A6
3669
   3548 FFFF2DF8 60B2                           BRA     ERROR
3670
                                             ;*
3671
                                             ;*******************************************************************
3672
                                             ;*
3673
                                             ;* *** GETLN *** FNDLN (& friends) ***
3674
                                             ;*
3675
                                             ;* 'GETLN' reads in input line into 'BUFFER'. It first prompts with
3676
                                             ;* the character in D0 (given by the caller), then it fills the
3677
                                             ;* buffer and echos. It ignores LF's but still echos
3678
                                             ;* them back. Control-H is used to delete the last character
3679
                                             ;* entered (if there is one), and control-X is used to delete the
3680
                                             ;* whole line and start over again. CR signals the end of a line,
3681
                                             ;* and causes 'GETLN' to return.
3682
                                             ;*
3683
   3562 FFFF2DFA                             GETLN:
3684
   3563 FFFF2DFA 6100 F60C                      BSR     GOOUT           ;display the prompt
3685
   3564 FFFF2DFE 103C 0020                      MOVE.B  #' ',D0      ;   and a space
3686
   3565 FFFF2E02 6100 F604                      BSR     GOOUT
3687
   3566 FFFF2E06 41F8 0630                      LEA     BUFFER,A0;      A0 is the buffer pointer
3688
   3567 FFFF2E0A                             GL1:
3689
   3568 FFFF2E0A 6100 0270                      BSR.L   CHKIO;          check keyboard
3690
   3569 FFFF2E0E 67FA                           BEQ     GL1     ;       wait for a char. to come in
3691
   3570 FFFF2E10 B03C 0008                      CMP.B   #CTRLH,D0       ;delete last character?
3692
   3571 FFFF2E14 6726                           BEQ     GL3     ;       if so
3693
   3572 FFFF2E16 B03C 0018                      CMP.B   #CTRLX,D0;      delete the whole line?
3694
   3573 FFFF2E1A 6744                           BEQ     GL4     ;       if so
3695
   3574 FFFF2E1C B03C 000D                      CMP.B   #CR,D0  ;       accept a CR
3696
   3575 FFFF2E20 6706                           BEQ     GL2
3697
   3576 FFFF2E22 B03C 0020                      CMP.B   #' ',D0  ;       if other control char., discard it
3698
   3577 FFFF2E26 65E2                           BCS     GL1
3699
   3578 FFFF2E28                             GL2:
3700
   3579 FFFF2E28 10C0                           MOVE.B  D0,(A0)+;       save the char.
3701
   3580 FFFF2E2A 6100 F5DC                      BSR     GOOUT           ;echo the char back out
3702
   3581 FFFF2E2E B03C 000D                      CMP.B   #CR,D0  ;       if it's a CR, end the line
3703
   3582 FFFF2E32 675C                           BEQ     GL7
3704
   3583 FFFF2E34 B1FC 0000 067F                 CMP.L   #(BUFFER+BUFLEN-1),A0   ;any more room?
3705
   3584 FFFF2E3A 65CE                           BCS     GL1     ;       yes: get some more, else delete last char.
3706
   3585 FFFF2E3C                             GL3:
3707
   3586 FFFF2E3C 103C 0008                      MOVE.B  #CTRLH,D0       ;delete a char. if possible
3708
   3587 FFFF2E40 6100 F5C6                      BSR     GOOUT
3709
   3588 FFFF2E44 103C 0020                      MOVE.B  #' ',D0
3710
   3589 FFFF2E48 6100 F5BE                      BSR     GOOUT
3711
   3590 FFFF2E4C B1FC 0000 0630                 CMP.L   #BUFFER,A0      ;any char.'s left?
3712
   3591 FFFF2E52 63B6                           BLS     GL1             ;if not
3713
   3592 FFFF2E54 103C 0008                      MOVE.B  #CTRLH,D0;      if so, finish the BS-space-BS sequence
3714
   3593 FFFF2E58 6100 F5AE                      BSR     GOOUT
3715
   3594 FFFF2E5C 5388                           SUBQ.L  #1,A0   ;       decrement the text pointer
3716
   3595 FFFF2E5E 60AA                           BRA     GL1             ;back for more
3717
   3596 FFFF2E60                             GL4:
3718
   3597 FFFF2E60 2208                           MOVE.L  A0,D1   ;       delete the whole line
3719
   3598 FFFF2E62 0481 0000 0630                 SUB.L   #BUFFER,D1;     figure out how many backspaces we need
3720
   3599 FFFF2E68 671E                           BEQ     GL6             ;if none needed, branch
3721
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 61
3722
BOOTROM.x68
3723
   3600 FFFF2E6A 5381                           SUBQ    #1,D1   ;       adjust for DBRA
3724
   3601 FFFF2E6C                             GL5:
3725
   3602 FFFF2E6C 103C 0008                      MOVE.B  #CTRLH,D0       ;and display BS-space-BS sequences
3726
   3603 FFFF2E70 6100 F596                      BSR     GOOUT
3727
   3604 FFFF2E74 103C 0020                      MOVE.B  #' ',D0
3728
   3605 FFFF2E78 6100 F58E                      BSR     GOOUT
3729
   3606 FFFF2E7C 103C 0008                      MOVE.B  #CTRLH,D0
3730
   3607 FFFF2E80 6100 F586                      BSR     GOOUT
3731
   3608 FFFF2E84 51C9 FFE6                      DBRA    D1,GL5
3732
   3609 FFFF2E88                             GL6:
3733
   3610 FFFF2E88 41F8 0630                      LEA     BUFFER,A0       ;reinitialize the text pointer
3734
   3611 FFFF2E8C 6000 FF7C                      BRA     GL1             ;and go back for more
3735
   3612 FFFF2E90                             GL7:
3736
   3613 FFFF2E90 103C 000A                      MOVE.B  #LF,D0  ;       echo a LF for the CR
3737
   3614 FFFF2E94 6100 F572                      BSR     GOOUT
3738
   3615 FFFF2E98 4E75                           RTS
3739
 
3740
                                             ;*
3741
                                             ;*******************************************************************
3742
                                             ;*
3743
                                             ;* *** FNDLN (& friends) ***
3744
                                             ;*
3745
                                             ;* 'FNDLN' finds a line with a given line no. (in D1) in the
3746
                                             ;* text save area.  A1 is used as the text pointer. If the line
3747
                                             ;* is found, A1 will point to the beginning of that line
3748
                                             ;* (i.e. the high byte of the line no.), and flags are NC & Z.
3749
                                             ;* If that line is not there and a line with a higher line no.
3750
                                             ;* is found, A1 points there and flags are NC & NZ. If we reached
3751
                                             ;* the end of the text save area and cannot find the line, flags
3752
                                             ;* are C & NZ.
3753
                                             ;* 'FNDLN' will initialize A1 to the beginning of the text save
3754
                                             ;* area to start the search. Some other entries of this routine
3755
                                             ;* will not initialize A1 and do the search.
3756
                                             ;* 'FNDLNP' will start with A1 and search for the line no.
3757
                                             ;* 'FNDNXT' will bump A1 by 2, find a CR and then start search.
3758
                                             ;* 'FNDSKP' uses A1 to find a CR, and then starts the search.
3759
                                             ;*
3760
   3637 FFFF2E9A                             FNDLN:
3761
   3638 FFFF2E9A B2BC 0000 FFFF                 CMP.L   #0xFFFF,D1      ;line no. must be < 65535
3762
   3639 FFFF2EA0 6400 FF4E                      BCC     QHOW
3763
   3640 FFFF2EA4 2279 FFFF 241C                 MOVE.L  TXTBGN,A1       ;init. the text save pointer
3764
 
3765
   3642 FFFF2EAA                             FNDLNP:
3766
   3643 FFFF2EAA 2478 0624                      MOVE.L  TXTUNF,A2       ;check if we passed the end
3767
   3644 FFFF2EAE 538A                           SUBQ.L  #1,A2
3768
   3645 FFFF2EB0 B5C9                           CMPA.L  A1,A2
3769
   3646 FFFF2EB2 650C                           BCS     FNDRET  ;       if so, return with Z=0 & C=1
3770
   3647 FFFF2EB4 1411                           MOVE.B  (A1),D2 ;if not, get a line no.
3771
   3648 FFFF2EB6 E14A                           LSL.W   #8,D2
3772
   3649 FFFF2EB8 1429 0001                      MOVE.B  1(A1),D2
3773
   3650 FFFF2EBC B441                           CMP.W   D1,D2           ;is this the line we want?
3774
   3651 FFFF2EBE 6502                           BCS     FNDNXT          ;no, not there yet
3775
   3652 FFFF2EC0                             FNDRET:
3776
   3653 FFFF2EC0 4E75                           RTS                     ;return the cond. codes
3777
 
3778
   3655 FFFF2EC2                             FNDNXT:
3779
   3656 FFFF2EC2 5489                           ADDQ.L  #2,A1;          find the next line
3780
 
3781
   3658 FFFF2EC4                             FNDSKP:
3782
   3659 FFFF2EC4 0C19 000D                      CMP.B   #CR,(A1)+       ;try to find a CR
3783
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 62
3784
BOOTROM.x68
3785
   3660 FFFF2EC8 66FA                           BNE     FNDSKP          ;keep looking
3786
   3661 FFFF2ECA 60DE                           BRA     FNDLNP          ;check if end of text
3787
 
3788
                                             ;*
3789
                                             ;*******************************************************************
3790
                                             ;*
3791
                                             ;* *** MVUP *** MVDOWN *** POPA *** PUSHA ***
3792
                                             ;*
3793
                                             ;* 'MVUP' moves a block up from where A1 points to where A2 points
3794
                                             ;* until A1=A3
3795
                                             ;*
3796
                                             ;* 'MVDOWN' moves a block down from where A1 points to where A3
3797
                                             ;* points until A1=A2
3798
                                             ;*
3799
                                             ;* 'POPA' restores the 'FOR' loop variable save area from the stack
3800
                                             ;*
3801
                                             ;* 'PUSHA' stacks for 'FOR' loop variable save area onto the stack
3802
                                             ;*
3803
   3678 FFFF2ECC                             MVUP:
3804
   3679 FFFF2ECC B7C9                           CMP.L   A1,A3   ;       see the above description
3805
   3680 FFFF2ECE 6704                           BEQ     MVRET
3806
   3681 FFFF2ED0 14D9                           MOVE.B  (A1)+,(A2)+
3807
   3682 FFFF2ED2 60F8                           BRA     MVUP
3808
   3683 FFFF2ED4                             MVRET:
3809
   3684 FFFF2ED4 4E75                           RTS
3810
 
3811
   3686 FFFF2ED6                             MVDOWN:
3812
   3687 FFFF2ED6 B5C9                           CMP.L   A1,A2   ;       see the above description
3813
   3688 FFFF2ED8 67FA                           BEQ     MVRET
3814
   3689 FFFF2EDA 1721                           MOVE.B  -(A1),-(A3)
3815
   3690 FFFF2EDC 60F8                           BRA     MVDOWN
3816
 
3817
   3692 FFFF2EDE                             POPA:
3818
   3693 FFFF2EDE 2C5F                           MOVE.L  (SP)+,A6        ;A6 = return address
3819
   3694 FFFF2EE0 21DF 0610                      MOVE.L  (SP)+,LOPVAR    ;restore LOPVAR, but zero means no more
3820
   3695 FFFF2EE4 6710                           BEQ     PP1
3821
   3696 FFFF2EE6 21DF 0614                      MOVE.L  (SP)+,LOPINC    ;if not zero, restore the rest
3822
   3697 FFFF2EEA 21DF 0618                      MOVE.L  (SP)+,LOPLMT
3823
   3698 FFFF2EEE 21DF 061C                      MOVE.L  (SP)+,LOPLN
3824
   3699 FFFF2EF2 21DF 0620                      MOVE.L  (SP)+,LOPPT
3825
   3700 FFFF2EF6                             PP1:
3826
   3701 FFFF2EF6 4ED6                           JMP     (A6)    ;       return
3827
 
3828
   3703 FFFF2EF8                             PUSHA:
3829
   3704 FFFF2EF8 2238 062C                      MOVE.L  STKLMT,D1       ;Are we running out of stack room?
3830
   3705 FFFF2EFC 928F                           SUB.L   SP,D1
3831
   3706 FFFF2EFE 6400 FEE6                      BCC             QSORRY          ;if so, say we're sorry
3832
   3707 FFFF2F02 2C5F                           MOVE.L  (SP)+,A6        ;else get the return address
3833
   3708 FFFF2F04 2238 0610                      MOVE.L  LOPVAR,D1       ;save loop variables
3834
   3709 FFFF2F08 6710                           BEQ             PU1             ;if LOPVAR is zero, that's all
3835
   3710 FFFF2F0A 2F38 0620                      MOVE.L  LOPPT,-(SP)     ;else save all the others
3836
   3711 FFFF2F0E 2F38 061C                      MOVE.L  LOPLN,-(SP)
3837
   3712 FFFF2F12 2F38 0618                      MOVE.L  LOPLMT,-(SP)
3838
   3713 FFFF2F16 2F38 0614                      MOVE.L  LOPINC,-(SP)
3839
   3714 FFFF2F1A                             PU1:
3840
   3715 FFFF2F1A 2F01                           MOVE.L  D1,-(SP)
3841
   3716 FFFF2F1C 4ED6                           JMP     (A6)            ;return
3842
 
3843
                                             ;*
3844
                                             ;*******************************************************************
3845
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 63
3846
BOOTROM.x68
3847
                                             ;*
3848
                                             ;* *** PRTSTG *** QTSTG *** PRTNUM *** PRTLN ***
3849
                                             ;*
3850
                                             ;* 'PRTSTG' prints a string pointed to by A1. It stops printing
3851
                                             ;* and returns to the caller when either a CR is printed or when
3852
                                             ;* the next byte is the same as what was passed in D0 by the
3853
                                             ;* caller.
3854
                                             ;*
3855
                                             ;* 'QTSTG' looks for an underline (back-arrow on some systems),
3856
                                             ;* single-quote, or double-quote.  If none of these are found, returns
3857
                                             ;* to the caller.  If underline, outputs a CR without a LF.  If single
3858
                                             ;* or double quote, prints the quoted string and demands a matching
3859
                                             ;* end quote.  After the printing, the next 2 bytes of the caller are
3860
                                             ;* skipped over (usually a short branch instruction).
3861
                                             ;*
3862
                                             ;* 'PRTNUM' prints the 32 bit number in D1, leading blanks are added if
3863
                                             ;* needed to pad the number of spaces to the number in D4.
3864
                                             ;* However, if the number of digits is larger than the no. in
3865
                                             ;* D4, all digits are printed anyway. Negative sign is also
3866
                                             ;* printed and counted in, positive sign is not.
3867
                                             ;*
3868
                                             ;* 'PRTLN' prints the saved text line pointed to by A1
3869
                                             ;* with line no. and all.
3870
                                             ;*
3871
   3744 FFFF2F1E                             PRTSTG:
3872
   3745 FFFF2F1E 1200                           MOVE.B  D0,D1   ;       save the stop character
3873
   3746 FFFF2F20                             PS1:
3874
   3747 FFFF2F20 1019                           MOVE.B  (A1)+,D0        ;get a text character
3875
   3748 FFFF2F22 B200                           CMP.B   D0,D1           ;same as stop character?
3876
   3749 FFFF2F24 6712                           BEQ             PRTRET          ;if so, return
3877
   3750 FFFF2F26 6100 F4E0                      BSR             GOOUT           ;display the char.
3878
   3751 FFFF2F2A B03C 000D                      CMP.B   #CR,D0          ;;is it a C.R.?
3879
   3752 FFFF2F2E 66F0                           BNE             PS1             ;no, go back for more
3880
   3753 FFFF2F30 103C 000A                      MOVE.B  #LF,D0  ;       yes, add a L.F.
3881
   3754 FFFF2F34 6100 F4D2                      BSR             GOOUT
3882
   3755 FFFF2F38                             PRTRET:
3883
   3756 FFFF2F38 4E75                           RTS                     ;then return
3884
 
3885
   3758 FFFF2F3A                             QTSTG:
3886
   3759 FFFF2F3A 6100 0096                      BSR.L   TSTC;           *** QTSTG ***
3887
   3760 FFFF2F3E 22 1B                          DC.B    '"',QT3-$
3888
   3761 FFFF2F40 103C 0022                      MOVE.B  #'"',D0  ;       it is a "
3889
   3762 FFFF2F44                             QT1:
3890
   3763 FFFF2F44 2248                           MOVE.L  A0,A1
3891
   3764 FFFF2F46 6100 FFD6                      BSR     PRTSTG          ;print until another
3892
   3765 FFFF2F4A 2049                           MOVE.L  A1,A0
3893
   3766 FFFF2F4C 225F                           MOVE.L  (SP)+,A1;       pop return address
3894
   3767 FFFF2F4E B03C 000A                      CMP.B   #LF,D0  ;       was last one a CR?
3895
   3768 FFFF2F52 6700 F71C                      BEQ     RUNNXL          ;if so, run next line
3896
   3769 FFFF2F56                             QT2:
3897
   3770 FFFF2F56 5489                           ADDQ.L  #2,A1   ;       skip 2 bytes on return
3898
   3771 FFFF2F58 4ED1                           JMP     (A1)            ;return
3899
   3772 FFFF2F5A                             QT3:
3900
   3773 FFFF2F5A 6100 0076                      BSR.L   TSTC    ;       is it a single quote?
3901
   3774 FFFF2F5E 27 07                          DC.B    '\'',QT4-$
3902
   3775 FFFF2F60 103C 0027                      MOVE.B  #'''',D0  ;      if so, do same as above
3903
   3776 FFFF2F64 60DE                           BRA     QT1
3904
   3777 FFFF2F66                             QT4:
3905
   3778 FFFF2F66 6100 006A                      BSR.L   TSTC            ;is it an underline?
3906
   3779 FFFF2F6A 5F 0D                          DC.B    '_',QT5-$
3907
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 64
3908
BOOTROM.x68
3909
   3780 FFFF2F6C 103C 000D                      MOVE.B  #CR,D0          ;if so, output a CR without LF
3910
   3781 FFFF2F70 6100 F496                      BSR.L   GOOUT
3911
   3782 FFFF2F74 225F                           MOVE.L  (SP)+,A1        ;pop return address
3912
   3783 FFFF2F76 60DE                           BRA     QT2
3913
   3784 FFFF2F78                             QT5:
3914
   3785 FFFF2F78 4E75                           RTS                     ;none of the above
3915
 
3916
   3787 FFFF2F7A                             PRTNUM:
3917
   3788 FFFF2F7A 48E7 C844                      movem.l d0/d1/d4/a1/a5,-(a7)
3918
   3789 FFFF2F7E 4BF8 0700                      lea             scratch1,a5
3919
   3790 FFFF2F82 2001                           move.l  d1,d0
3920
   3791 FFFF2F84 4EB9 FFFF 313E                 jsr             HEX2DEC
3921
   3792 FFFF2F8A 4BF8 0700                      lea             scratch1,a5
3922
   3793 FFFF2F8E                             PN8:
3923
   3794 FFFF2F8E 101D                           move.b  (a5)+,d0
3924
   3795 FFFF2F90 6704                           beq             PN7
3925
   3796 FFFF2F92 51CC FFFA                      dbra    d4,PN8
3926
   3797 FFFF2F96                             PN7:
3927
   3798 FFFF2F96 4A44                           tst.w   d4
3928
   3799 FFFF2F98 6B0C                           bmi             PN9
3929
   3800 FFFF2F9A 103C 0020                      MOVE.B  #' ',D0  ;       display the required leading spaces
3930
   3801 FFFF2F9E 6100 F468                      BSR             GOOUT
3931
   3802 FFFF2FA2 51CC FFF2                      DBRA    D4,PN7
3932
   3803 FFFF2FA6                             PN9:
3933
   3804 FFFF2FA6 43F8 0700                      lea             scratch1,a1
3934
   3805 FFFF2FAA 4EB9 FFFF 1858                 jsr             DisplayString
3935
   3806 FFFF2FB0 4CDF 2213                      movem.l (a7)+,d0/d1/d4/a1/a5
3936
   3807 FFFF2FB4 4E75                           rts
3937
 
3938
                                             ;PRTNUM
3939
                                             ;  MOVE.L  D1,D3   ;       save the number for later
3940
                                             ;  MOVE.L  D4,-(SP)        ;save the width value
3941
                                             ;  MOVE.W  #0xFFFF,-(SP)   ;flag for end of digit string
3942
                                             ;  TST.L   D1              ;is it negative?
3943
                                             ;  BPL     PN1             ;if not
3944
                                             ;  NEG.L   D1      ;       else make it positive
3945
                                             ;  SUBQ    #1,D4   ;       one less for width count
3946
                                             ;PN1:
3947
                                             ;  DIVU    #10,D1  ;       get the next digit
3948
                                             ;  BVS     PNOV    ;       overflow flag set?
3949
                                             ;  MOVE.L  D1,D0   ;       if not, save remainder
3950
                                             ;  AND.L   #0xFFFF,D1      ;strip the remainder
3951
                                             ;  BRA     TOASCII         ;skip the overflow stuff
3952
                                             ;PNOV:
3953
                                             ;  MOVE    D1,D0   ;       prepare for long word division
3954
                                             ;  CLR.W   D1              ;zero out low word
3955
                                             ;  SWAP    D1              ;high word into low
3956
                                             ;  DIVU    #10,D1  ;       divide high word
3957
                                             ;  MOVE    D1,D2   ;       save quotient
3958
                                             ;  MOVE    D0,D1   ;       low word into low
3959
                                             ;  DIVU    #10,D1  ;       divide low word
3960
                                             ;  MOVE.L  D1,D0   ;       D0 = remainder
3961
                                             ;  SWAP    D1              ;       R/Q becomes Q/R
3962
                                             ;  MOVE    D2,D1   ;       D1 is low/high
3963
                                             ;  SWAP    D1              ;       D1 is finally high/low
3964
                                             ;TOASCII:
3965
                                             ;  SWAP    D0              ;       get remainder
3966
                                             ;  MOVE.W  D0,-(SP);       stack it as a digit
3967
                                             ;  SWAP    D0
3968
                                             ;  SUBQ    #1,D4   ;       decrement width count
3969
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 65
3970
BOOTROM.x68
3971
                                             ;  TST.L   D1              ;if quotient is zero, we're done
3972
                                             ;  BNE     PN1
3973
                                             ;  SUBQ    #1,D4   ;       adjust padding count for DBRA
3974
                                             ;  BMI     PN4             ;skip padding if not needed
3975
                                             ;PN3:
3976
                                             ;  MOVE.B  #' ',D0  ;       display the required leading spaces
3977
                                             ;  BSR     GOOUT
3978
                                             ;  DBRA    D4,PN3
3979
                                             ;PN4:
3980
                                             ;  TST.L   D3              ;is number negative?
3981
                                             ;  BPL     PN5
3982
                                             ;  MOVE.B  #'-',D0  ;       if so, display the sign
3983
                                             ;  BSR     GOOUT
3984
                                             ;PN5:
3985
                                             ;  MOVE.W  (SP)+,D0        ;now unstack the digits and display
3986
                                             ;  BMI     PNRET           ;until the flag code is reached
3987
                                             ;  ADD.B   #'0',D0   ;      make into ASCII
3988
                                             ;  BSR     GOOUT
3989
                                             ;  BRA     PN5
3990
                                             ;PNRET:
3991
                                             ;  MOVE.L  (SP)+,D4        ;restore width value
3992
                                             ;  RTS
3993
 
3994
   3863 FFFF2FB6                             PRTLN:
3995
   3864 FFFF2FB6 4281                           CLR.L   D1
3996
   3865 FFFF2FB8 1219                           MOVE.B  (A1)+,D1        ;get the binary line number
3997
   3866 FFFF2FBA E189                           LSL     #8,D1
3998
   3867 FFFF2FBC 1219                           MOVE.B  (A1)+,D1
3999
   3868 FFFF2FBE 7805                           MOVEQ   #5,D4           ;display a 5 digit line no.
4000
   3869 FFFF2FC0 6100 FFB8                      BSR     PRTNUM
4001
   3870 FFFF2FC4 103C 0020                      MOVE.B  #' ',D0      ;   followed by a blank
4002
   3871 FFFF2FC8 6100 F43E                      BSR     GOOUT
4003
   3872 FFFF2FCC 4280                           CLR     D0              ;stop char. is a zero
4004
   3873 FFFF2FCE 6000 FF4E                      BRA     PRTSTG  ;       display the rest of the line
4005
 
4006
                                             ;*
4007
                                             ;* ===== Test text byte following the call to this subroutine. If it
4008
                                             ;* equals the byte pointed to by A0, return to the code following
4009
                                             ;* the call. If they are not equal, branch to the point
4010
                                             ;* indicated by the offset byte following the text byte.
4011
                                             ;*
4012
   3881 FFFF2FD2                             TSTC:
4013
   3882 FFFF2FD2 6100 0050                      BSR     IGNBLK          ;ignore leading blanks
4014
   3883 FFFF2FD6 225F                           MOVE.L  (SP)+,A1        ;get the return address
4015
   3884 FFFF2FD8 1219                           MOVE.B  (A1)+,D1        ;get the byte to compare
4016
   3885 FFFF2FDA B210                           CMP.B   (A0),D1         ;is it = to what A0 points to?
4017
   3886 FFFF2FDC 6708                           BEQ     TC1             ;if so
4018
   3887 FFFF2FDE 4281                           CLR.L   D1              ;If not, add the second
4019
   3888 FFFF2FE0 1211                           MOVE.B  (A1),D1 ;       byte following the call to
4020
   3889 FFFF2FE2 D3C1                           ADD.L   D1,A1   ;       the return address.
4021
   3890 FFFF2FE4 4ED1                           JMP     (A1)            ;jump to the routine
4022
   3891 FFFF2FE6                             TC1:
4023
   3892 FFFF2FE6 5288                           ADDQ.L  #1,A0   ;       if equal, bump text pointer
4024
   3893 FFFF2FE8 5289                           ADDQ.L  #1,A1   ;       Skip the 2 bytes following
4025
   3894 FFFF2FEA 4ED1                           JMP     (A1)            ;the call and continue.
4026
 
4027
                                             ;*
4028
                                             ;* ===== See if the text pointed to by A0 is a number. If so,
4029
                                             ;* return the number in D1 and the number of digits in D2,
4030
                                             ;* else return zero in D1 and D2.
4031
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 66
4032
BOOTROM.x68
4033
                                             ;*
4034
   3901 FFFF2FEC                             TSTNUM:
4035
   3902 FFFF2FEC 4281                           CLR.L   D1              ;initialize return parameters
4036
   3903 FFFF2FEE 4282                           CLR     D2
4037
   3904 FFFF2FF0 6100 0032                      BSR     IGNBLK          ;skip over blanks
4038
   3905 FFFF2FF4                             TN1:
4039
   3906 FFFF2FF4 0C10 0030                      CMP.B   #'0',(A0) ;      is it less than zero?
4040
   3907 FFFF2FF8 6528                           BCS     TSNMRET         ;if so, that's all
4041
   3908 FFFF2FFA 0C10 0039                      CMP.B   #'9',(A0) ;      is it greater than nine?
4042
   3909 FFFF2FFE 6222                           BHI     TSNMRET         ;if so, return
4043
   3910 FFFF3000 B2BC 0CCC CCCC                 CMP.L   #214748364,D1   ;see if there's room for new digit
4044
   3911 FFFF3006 6400 FDE8                      BCC     QHOW            ;if not, we've overflowd
4045
   3912 FFFF300A 2001                           MOVE.L  D1,D0   ;       quickly multiply result by 10
4046
   3913 FFFF300C D281                           ADD.L   D1,D1
4047
   3914 FFFF300E D281                           ADD.L   D1,D1
4048
   3915 FFFF3010 D280                           ADD.L   D0,D1
4049
   3916 FFFF3012 D281                           ADD.L   D1,D1
4050
   3917 FFFF3014 1018                           MOVE.B  (A0)+,D0        ;add in the new digit
4051
   3918 FFFF3016 0280 0000 000F                 AND.L   #0xF,D0
4052
   3919 FFFF301C D280                           ADD.L   D0,D1
4053
   3920 FFFF301E 5282                           ADDQ    #1,D2           ;increment the no. of digits
4054
   3921 FFFF3020 60D2                           BRA     TN1
4055
   3922 FFFF3022                             TSNMRET:
4056
   3923 FFFF3022 4E75                           RTS
4057
 
4058
                                             ;*
4059
                                             ;* ===== Skip over blanks in the text pointed to by A0.
4060
                                             ;*
4061
   3928 FFFF3024                             IGNBLK:
4062
   3929 FFFF3024 0C10 0020                      CMP.B   #' ',(A0)   ;    see if it's a space
4063
   3930 FFFF3028 6604                           BNE     IGBRET          ;if so, swallow it
4064
   3931 FFFF302A                             IGB1:
4065
   3932 FFFF302A 5288                           ADDQ.L  #1,A0   ;       increment the text pointer
4066
   3933 FFFF302C 60F6                           BRA     IGNBLK
4067
   3934 FFFF302E                             IGBRET:
4068
   3935 FFFF302E 4E75                           RTS
4069
 
4070
                                             ;*
4071
                                             ;* ===== Convert the line of text in the input buffer to upper
4072
                                             ;* case (except for stuff between quotes).
4073
                                             ;*
4074
   3941 FFFF3030                             TOUPBUF:
4075
   3942 FFFF3030 41F8 0630                      LEA     BUFFER,A0       ;set up text pointer
4076
   3943 FFFF3034 4201                           CLR.B   D1              ;clear quote flag
4077
   3944 FFFF3036                             TOUPB1:
4078
   3945 FFFF3036 1018                           MOVE.B  (A0)+,D0        ;get the next text char.
4079
   3946 FFFF3038 B03C 000D                      CMP.B   #CR,D0          ;is it end of line?
4080
   3947 FFFF303C 671A                           BEQ     TOUPBRT         ;if so, return
4081
   3948 FFFF303E B03C 0022                      CMP.B   #'"',D0  ;       a double quote?
4082
   3949 FFFF3042 6716                           BEQ     DOQUO
4083
   3950 FFFF3044 B03C 0027                      CMP.B   #'''',D0  ;      or a single quote?
4084
   3951 FFFF3048 6710                           BEQ     DOQUO
4085
   3952 FFFF304A 4A01                           TST.B   D1              ;inside quotes?
4086
   3953 FFFF304C 66E8                           BNE     TOUPB1          ;if so, do the next one
4087
   3954 FFFF304E 6100 001A                      BSR     TOUPPER         ;convert to upper case
4088
   3955 FFFF3052 1100                           MOVE.B  D0,-(A0);       store it
4089
   3956 FFFF3054 5288                           ADDQ.L  #1,A0
4090
   3957 FFFF3056 60DE                           BRA     TOUPB1          ;and go back for more
4091
   3958 FFFF3058                             TOUPBRT:
4092
   3959 FFFF3058 4E75                           RTS
4093
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 67
4094
BOOTROM.x68
4095
 
4096
   3961 FFFF305A                             DOQUO:
4097
   3962 FFFF305A 4A01                           TST.B   D1      ;       are we inside quotes?
4098
   3963 FFFF305C 6604                           BNE     DOQUO1
4099
   3964 FFFF305E 1200                           MOVE.B  D0,D1   ;       if not, toggle inside-quotes flag
4100
   3965 FFFF3060 60D4                           BRA     TOUPB1
4101
   3966 FFFF3062                             DOQUO1:
4102
   3967 FFFF3062 B200                           CMP.B   D0,D1   ;       make sure we're ending proper quote
4103
   3968 FFFF3064 66D0                           BNE     TOUPB1          ;if not, ignore it
4104
   3969 FFFF3066 4201                           CLR.B   D1              ;else clear quote flag
4105
   3970 FFFF3068 60CC                           BRA     TOUPB1
4106
 
4107
                                             ;*
4108
                                             ;* ===== Convert the character in D0 to upper case
4109
                                             ;*
4110
   3975 FFFF306A                             TOUPPER:
4111
   3976 FFFF306A B03C 0061                      CMP.B   #'a',D0   ;      is it < 'a'?
4112
   3977 FFFF306E 650A                           BCS     TOUPRET
4113
   3978 FFFF3070 B03C 007A                      CMP.B   #'z',D0        ; or > 'z'?
4114
   3979 FFFF3074 6204                           BHI     TOUPRET
4115
   3980 FFFF3076 0400 0020                      SUB.B   #32,D0          ;if not, make it upper case
4116
   3981 FFFF307A                             TOUPRET:
4117
   3982 FFFF307A 4E75                           RTS
4118
 
4119
                                             ;*
4120
                                             ;* 'CHKIO' checks the input. If there's no input, it will return
4121
                                             ;* to the caller with the Z flag set. If there is input, the Z
4122
                                             ;* flag is cleared and the input byte is in D0. However, if a
4123
                                             ;* control-C is read, 'CHKIO' will warm-start BASIC and will not
4124
                                             ;* return to the caller.
4125
                                             ;*
4126
   3991 FFFF307C                             CHKIO:
4127
   3992 FFFF307C 6100 F38E                      BSR.L   GOIN    ;       get input if possible
4128
   3993 FFFF3080 670A                           BEQ     CHKRET          ;if Zero, no input
4129
   3994 FFFF3082 B03C 0003                      CMP.B   #CTRLC,D0       ;is it control-C?
4130
   3995 FFFF3086 6604                           BNE     CHKRET          ;if not
4131
   3996 FFFF3088 6000 F3D6                      BRA.L   WSTART          ;if so, do a warm start
4132
   3997 FFFF308C                             CHKRET:
4133
   3998 FFFF308C 4E75                           RTS
4134
 
4135
                                             ;*
4136
                                             ;* ===== Display a CR-LF sequence
4137
                                             ;*
4138
   4003 FFFF308E                             CRLF1:
4139
   4004 FFFF308E 4DF9 FFFF 313A                 LEA     CLMSG,A6
4140
 
4141
                                             ;*
4142
                                             ;* ===== Display a zero-ended string pointed to by register A6
4143
                                             ;*
4144
   4009 FFFF3094                             PRMESG:
4145
   4010 FFFF3094 101E                           MOVE.B  (A6)+,D0        ;get the char.
4146
   4011 FFFF3096 6706                           BEQ     PRMRET          ;if it's zero, we're done
4147
   4012 FFFF3098 6100 F36E                      BSR     GOOUT           ;else display it
4148
   4013 FFFF309C 60F6                           BRA     PRMESG
4149
   4014 FFFF309E                             PRMRET:
4150
   4015 FFFF309E 4E75                           RTS
4151
 
4152
                                             ;******************************************************
4153
                                             ;* The following routines are the only ones that need *
4154
                                             ;* to be changed for a different I/O environment.     *
4155
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 68
4156
BOOTROM.x68
4157
                                             ;******************************************************
4158
 
4159
                                             ;UART              EQU             0xFFDC0A00
4160
                                             ;UART_LS           EQU             UART+1
4161
                                             ;UART_CTRL EQU             UART+7
4162
                                             ;KEYBD             EQU             0xFFDC0000
4163
 
4164
 
4165
                                             ;*
4166
                                             ;* ===== Output character to the console (Port 1) from register D0
4167
                                             ;* (Preserves all registers.)
4168
                                             ;*
4169
   4032 FFFF30A0                             OUTC:
4170
   4033 FFFF30A0 48E7 C000                      MOVEM.L D0/D1,-(SP)
4171
   4034 FFFF30A4 2200                           MOVE.L  D0,D1
4172
   4035 FFFF30A6 4EB9 FFFF 1732                 JSR             DisplayChar
4173
   4036 FFFF30AC 4CDF 0003                      MOVEM.L (SP)+,D0/D1
4174
   4037 FFFF30B0 4E75                           RTS
4175
 
4176
                                             ;*
4177
                                             ;* ===== Input a character from the console into register D0 (or
4178
                                             ;* return Zero status if there's no character available).
4179
                                             ;*
4180
   4043 FFFF30B2                             INC:
4181
   4044 FFFF30B2 3039 FFDC 0000                 MOVE.W  KEYBD,D0        ;is character ready?
4182
   4045 FFFF30B8 6A0C                           BPL             INCRET0         ;if not, return Zero status
4183
   4046 FFFF30BA 4279 FFDC 0002                 CLR.W   KEYBD+2         ; clear keyboard strobe line
4184
   4047 FFFF30C0 0240 00FF                      AND.W   #0xFF,D0        ;zero out the high bit
4185
   4048 FFFF30C4 4E75                           RTS
4186
   4049 FFFF30C6                             INCRET0
4187
   4050 FFFF30C6 7000                           MOVEQ   #0,D0
4188
   4051 FFFF30C8 4E75                           RTS
4189
 
4190
                                             ;*
4191
                                             ;* ===== Output character to the host (Port 2) from register D0
4192
                                             ;* (Preserves all registers.)
4193
                                             ;*
4194
   4057 FFFF30CA                             AUXOUT:
4195
   4058 FFFF30CA 0839 0005 FFDC 0A01            BTST    #5,UART_LS      ;is port ready for a character?
4196
   4059 FFFF30D2 67F6                           BEQ             AUXOUT          ;if not, wait for it
4197
   4060 FFFF30D4 13C0 FFDC 0A00                 MOVE.B  D0,UART         ;out it goes.
4198
   4061 FFFF30DA 4E75                           RTS
4199
 
4200
                                             ;*
4201
                                             ;* ===== Input a character from the host into register D0 (or
4202
                                             ;* return Zero status if there's no character available).
4203
                                             ;*
4204
   4067 FFFF30DC                             AUXIN:
4205
   4068 FFFF30DC 0839 0000 FFDC 0A01            BTST    #0,UART_LS      ;is character ready?
4206
   4069 FFFF30E4 670A                           BEQ             AXIRET          ;if not, return Zero status
4207
   4070 FFFF30E6 1039 FFDC 0A00                 MOVE.B  UART,D0         ;else get the character
4208
   4071 FFFF30EC 0200 007F                      AND.B   #0x7F,D0        ;zero out the high bit
4209
   4072 FFFF30F0                             AXIRET:
4210
   4073 FFFF30F0 4E75                           RTS
4211
 
4212
                                             ;*
4213
                                             ;* ===== Return to the resident monitor, operating system, etc.
4214
                                             ;*
4215
   4078 FFFF30F2                             BYEBYE:
4216
   4079 FFFF30F2 4EF9 FFFF 1A7A                 JMP             Monitor
4217
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 69
4218
BOOTROM.x68
4219
                                             ;    MOVE.B        #228,D7         ;return to Tutor
4220
                                             ;  TRAP    #14
4221
 
4222
   4083 FFFF30F8                             INITMSG:
4223
   4084 FFFF30F8 0D 0A 47 6F 72 64 6F 27        DC.B    CR,LF,'Gordo\'s MC68000 Tiny BASIC, v1.3',CR,LF,LF,0
4224
   4085 FFFF3100 73 20 4D 43 36 38 30 30
4225
   4086 FFFF3108 30 20 54 69 6E 79 20 42
4226
   4087 FFFF3110 41 53 49 43 2C 20 76 31
4227
   4088 FFFF3118 2E 33 0D 0A 0A 00
4228
   4089 FFFF311E                             OKMSG:
4229
   4090 FFFF311E 0D 0A 4F 4B 0D 0A 00           DC.B    CR,LF,'OK',CR,LF,0
4230
   4091 FFFF3125                             HOWMSG:
4231
   4092 FFFF3125 48 6F 77 3F 0D 0A 00           DC.B    'How?',CR,LF,0
4232
   4093 FFFF312C                             WHTMSG:
4233
   4094 FFFF312C 57 68 61 74 3F 0D 0A 00        DC.B    'What?',CR,LF,0
4234
 
4235
   4096 FFFF3134                             SRYMSG:
4236
   4097 FFFF3134 53 6F 72 72 79 2E              DC.B    'Sorry.'
4237
   4098 FFFF313A                             CLMSG:
4238
   4099 FFFF313A 0D 0A 00                       DC.B    CR,LF,0
4239
                                             ;  DC.B    0        ;<- for aligning on a word boundary
4240
   4101 FFFF313D FF                             even
4241
 
4242
                                             LSTROM     EQU             $
4243
                                                ;       end of possible ROM area
4244
 
4245
                                             ;**************************************************************************
4246
                                             ; The portion of code within STAR lines are modified from Tutor source code
4247
                                             ;
4248
                                             ;
4249
                                             ; HEX2DEC   HEX2DEC convert hex to decimal
4250
                                             ; CONVERT BINARY TO DECIMAL  REG D0 PUT IN (A5) BUFFER AS ASCII
4251
 
4252
   4113 FFFF313E 48 E77F 00                  HEX2DEC  MOVEM.L D1/D2/D3/D4/D5/D6/D7,-(SP)   ;SAVE REGISTERS
4253
   4114 FFFF3142 2E00                                 MOVE.L  D0,D7               ;SAVE IT HERE
4254
   4115 FFFF3144 6A08                                 BPL.S   HX2DC
4255
   4116 FFFF3146 4487                                 NEG.L   D7             ;CHANGE TO POSITIVE
4256
   4117 FFFF3148 6B4E                                 BMI.S   HX2DC57        ;SPECIAL CASE (-0)
4257
   4118 FFFF314A 1AFC 002D                            MOVE.B  #'-',(A5)+     ;PUT IN NEG SIGN
4258
   4119 FFFF314E 4244                        HX2DC    CLR.W   D4             ;FOR ZERO SURPRESS
4259
   4120 FFFF3150 7C0A                                 MOVEQ.L   #10,D6         ;COUNTER
4260
   4121 FFFF3152 7401                        HX2DC0   MOVEQ.L   #1,D2          ;VALUE TO SUB
4261
   4122 FFFF3154 2206                                 MOVE.L  D6,D1          ;COUNTER
4262
   4123 FFFF3156 5381                                 SUBQ.L  #1,D1          ;ADJUST - FORM POWER OF TEN
4263
   4124 FFFF3158 671A                                 BEQ.S   HX2DC2         ;IF POWER IS ZERO
4264
   4125 FFFF315A 3602                        HX2DC1   MOVE.W  D2,D3          ;D3=LOWER WORD
4265
   4126 FFFF315C C6FC 000A                            MULU.W    #10,D3
4266
   4127 FFFF3160 4842                                 SWAP.W    D2             ;D2=UPPER WORD
4267
   4128 FFFF3162 C4FC 000A                            MULU.W    #10,D2
4268
   4129 FFFF3166 4843                                 SWAP.W    D3             ;ADD UPPER TO UPPER
4269
   4130 FFFF3168 D443                                 ADD.W   D3,D2
4270
   4131 FFFF316A 4842                                 SWAP.W    D2             ;PUT UPPER IN UPPER
4271
   4132 FFFF316C 4843                                 SWAP.W    D3             ;PUT LOWER IN LOWER
4272
   4133 FFFF316E 3403                                 MOVE.W  D3,D2          ;D2=UPPER & LOWER
4273
   4134 FFFF3170 5381                                 SUBQ.L  #1,D1
4274
   4135 FFFF3172 66E6                                 BNE     HX2DC1
4275
   4136 FFFF3174 4280                        HX2DC2   CLR.L   D0             ;HOLDS SUB AMT
4276
   4137 FFFF3176 BE82                        HX2DC22  CMP.L   D2,D7
4277
   4138 FFFF3178 6D06                                 BLT.S   HX2DC3         ;IF NO MORE SUB POSSIBLE
4278
   4139 FFFF317A 5280                                 ADDQ.L  #1,D0          ;BUMP SUBS
4279
FPGAfield asm68 assembler    version 5.1   Fri Sep 23 07:24:21 2011     Page 70
4280
BOOTROM.x68
4281
   4140 FFFF317C 9E82                                 SUB.L   D2,D7          ;COUNT DOWN BY POWERS OF TEN
4282
   4141 FFFF317E 60F6                                 BRA.S   HX2DC22        ;DO MORE
4283
   4142 FFFF3180 4A00                        HX2DC3   TST.B   D0             ;ANY VALUE?
4284
   4143 FFFF3182 6604                                 BNE.S   HX2DC4
4285
   4144 FFFF3184 4A44                                 TST.W   D4             ;ZERO SURPRESS
4286
   4145 FFFF3186 6708                                 BEQ.S   HX2DC5
4287
   4146 FFFF3188 0600 0030                   HX2DC4   ADDI.B  #0x30,D0        ;BINARY TO ASCII
4288
   4147 FFFF318C 1AC0                                 MOVE.B  D0,(A5)+       ;PUT IN BUFFER
4289
   4148 FFFF318E 1800                                 MOVE.B  D0,D4          ;MARK AS NON ZERO SURPRESS
4290
   4149 FFFF3190 5386                        HX2DC5   SUBQ.L  #1,D6          ;NEXT POWER
4291
   4150 FFFF3192 66BE                                 BNE     HX2DC0
4292
   4151 FFFF3194 4A44                                 TST.W   D4             ;SEE IF ANYTHING PRINTED
4293
   4152 FFFF3196 6604                                 BNE.S   HX2DC6
4294
   4153 FFFF3198 1AFC 0030                   HX2DC57  MOVE.B  #'0',(A5)+     ;PRINT AT LEST A ZERO
4295
   4154 FFFF319C 1ABC 0000                   HX2DC6   MOVE.B  #0,(A5)        ; PUT TERMINATOR
4296
   4155 FFFF31A0 4CDF 00FE                            MOVEM.L (SP)+,D1/D2/D3/D4/D5/D6/D7   ;RESTORE REGISTERS
4297
   4156 FFFF31A4 4E75                                 RTS                    ;END OF ROUTINE
4298
 
4299
                                             ;******************************************************************************
4300
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.