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

Subversion Repositories cpu8080

[/] [cpu8080/] [trunk/] [project/] [scs1.asm] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 samiam9512
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
!                                                                              !
3
!                  IMSAI SCS-1 MONITOR/ASSEMBLER FOR 8080 CPU                  !
4
!                                                                              !
5 11 samiam9512
! This copy was converted to IP assembler, and is modified to run on the       !
6
! MITS serial I/O board, which had jumper selectable baud rates only.          !
7 9 samiam9512
!                                                                              !
8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9
!
10
!       page    62
11
!       title           'imsai scs-1 rev. 2 06 oct. 1976'
12
!
13 11 samiam9512
! MITS serial I/O board equates
14 9 samiam9512
!
15 11 samiam9512
tts:    equ     $20
16
tti:    equ     $21
17
tto:    equ     $21
18
ttyda:  equ     $01
19
ttytr:  equ     $80
20
!
21 9 samiam9512
        jmp     inita           ! dead start
22
        jmp     eor             ! restart monitor
23
!
24
        alignp  $08
25
        jmp     brkp            ! breakpoint restart
26
!
27
        alignp  $40
28
!
29
! this routine initializes the file aread for subsequent
30
! processing
31
!
32 11 samiam9512
inita:
33 9 samiam9512
        lxi     h,file0
34
        mvi     c,maxfil*felen
35
        xra     a
36
init2:  mov     m,a
37
        inx     h
38
        dcr     c
39
        jnz     init2
40
!
41
! clear the breakpoint table
42
!
43
        mvi     b,nbr*3
44
        lxi     h,brt
45
init3:  mov     m,a
46
        inx     h
47
        dcr     b
48
        jnz     init3
49
!
50
! this is the starting point of the self contained
51
! system once the system has been initialized.  commands
52
! are read from the user, executed, and control returns
53
! back to this point to read another command.
54
!
55
eor:    lxi     sp,area+18
56
        call    crlf            ! print c/r, line feed
57
        call    read            ! read input line
58
        inx     h
59
        mov     a,m             ! fetch first character
60
        cpi     '9'+1           ! command or line number?
61
        jc      line            ! jump if line for file
62
        call    valc
63
        call    comm
64
        jmp     eor
65
!
66
! this routine reads in a line from the tty and places
67
! it in an input buffer.
68
! the following are special characters
69
!   cr          terminates read routine
70
!   lf          not recognized by routine
71
!   ctrl x      deletes current line
72
!   del         deletes characer
73
! all displayable characters between blank & z and the
74
! above are recognized by the read routine, all others
75
! are skipped over.  the routine will not accept more
76
! characters than the input buffer will hold.
77
!
78
read:   lxi     h,ibuf          ! get input buffer address
79
        shld    adds            ! save address
80
        mvi     e,2             ! initialize character count
81
next:   call    in8             ! read a line
82
        mov     a,b
83
        cpi     24              ! check for ctrl x
84
        jnz     cr
85
        call    crlf            ! output a crlf
86
        jmp     read
87
cr:     cpi     ascr            ! get an ascii cr
88
        jnz     del
89
        mov     a,l
90
        cpi     ibuf and $00ff  ! check for first char
91
        jz      read
92
        mvi     m,ascr          ! place cr at end of line
93
        inx     h
94
        mvi     m,1             ! place eof indicator in line
95
        inx     h
96
        mvi     a,ibuf+83 and $00ff
97
        call    cler            ! clear remaining buffer
98
        lxi     h,ibuf-1
99
        mov     m,e             ! save character count
100
        ret
101
del:    cpi     127             ! check for delete character
102
        jnz     char
103
        mvi     a,ibuf and $00ff
104
        cmp     l               ! is it 1st character
105
        jz      next
106
        dcx     h               ! decrement pointer
107
        dcr     e               ! decrement count
108
bspa:   mvi     b,$5f
109
        call    out8
110
        jmp     next
111
char:   cpi     ' '             ! check for legal character
112
        jc      next
113
        cpi     'z'+1
114
        jnc     next
115
        mov     b,a
116
        call    out8            ! echo character
117
        mov     m,b
118
        mvi     a,ibuf+81 and $00ff
119
        cmp     l               ! check for end of line
120
        jz      bspa
121
        inx     h
122
        inr     e               ! increment character count
123
        jmp     next
124
!
125
! this routine is used to blank out a portion of memory
126
!
127
cler:   cmp     l
128
        rz
129
        mvi     m,' '           ! place blank in memory
130
        inx     h
131
        jmp     cler
132
!
133
! see if tty input ready and check for ctrl x.
134
!
135
ink:    in      tts             ! get tty status
136
        ani     ttyda           ! is data available?
137
        rnz                     ! return if not
138
        in      tti             ! get the char
139
        ani     $7f             ! strip off parity
140
        cpi     'x'-$40         ! is it a ctrl x?
141
        ret
142
!
143
! this routine reads a byte of data from the usart
144
!
145
in8:    in      tts             ! read usart status
146 11 samiam9512
        cma                     ! invert status
147 9 samiam9512
        ani     ttyda
148
        jz      in8
149
        in      tti             ! read data
150
        ani     127             ! strip off parity
151
        mov     b,a
152
        ret
153
 
154
!
155
! this routine outputs a byte of data to the usart
156
!
157
out8:   in      tts             ! read status
158 11 samiam9512
        cma                     ! invert status
159 9 samiam9512
        ani     ttytr
160
        jz      out8
161
ok:     mov     a,b
162
        out     tto             ! transmit data
163
        ret
164
!
165
! this routine will output a carriage return and
166
! line feed followed by two delete characters which
167
! provide time for print head to return.
168
!
169
crlf:   mvi     b,13            ! cr
170
        call    out8
171
lf:     mvi     b,10            ! lf
172
        call    out8
173
        mvi     b,127
174
        call    out8
175
        call    out8
176
        ret
177
!
178
! this routine jumps to a location in memory given by
179
! the input command and begins execution of program
180
! there.
181
!
182
exec:   call    vchk            ! check for parameters
183
        call    crlf
184
        lhld    bbuf            ! fetch address
185
        pchl                    ! jump to program
186
!
187
! this routine checks the input command agains all
188
! legal commands stored in a table.  if a legal command
189
! is found, a jump is made to that routine.  otherwise
190
! an error message is output to the user.
191
!
192
comm:   lxi     d,ctab          ! command table address
193
        mvi     b,ncom          ! number of commands
194
        mvi     a,4             ! length of command
195
        sta     nchr            ! save
196
        call    coms            ! search table
197
        jnz     what            ! jump if illegal command
198
        pchl                    ! be here now
199
!
200
! this routine checks to see if a base character string
201
! is equal to any of the strings contained in a table
202
! pointed to by d,e.  the table consists of any number
203
! of chars, with 2 bytes containing values associated
204
! with it.  reg b contains the # of strings to compare.
205
! this routine can be used to search through a command
206
! or symbol table.  on return, if the zero flag is set,
207
! a match was found! if not, no match was found.  if
208
! a match was found, d,e point to the last byte
209
! associated with the character string.  if not, d,e
210
! point to the next location after the end fo the table.
211
!
212
coms:   lhld    adds            ! fetch compare address
213
        lda     nchr            ! get length of string
214
        mov     c,a
215
        call    sear            ! compare strings
216
        ldax    d               ! fetch value
217
        mov     l,a
218
        inx     d
219
        ldax    d               ! fetch value
220
        mov     h,a
221
        rz
222
        inx     d               ! set to next string
223
        dcr     b               ! decrement count
224
        jnz     coms
225
        inr     b               ! clear zero flag
226
        ret
227
!
228
! this routine checks to see if two character strings in
229
! memory are equal.  the strings are pointed to by d,e
230
! and h,l.  on return, the zero flag set indicates a
231
! match.  reg c indicates the length of the strings.  on
232
! return, the pointers point to the next address after
233
! the character strings.
234
!
235
sear:   ldax    d               ! fetch character
236
        cmp     m               ! compare characters
237
        jnz     inca
238
        inx     h
239
        inx     d
240
        dcr     c               ! decrement character count
241
        jnz     sear
242
        ret
243
inca:   inx     d
244
        dcr     c
245
        jnz     inca
246
        inr     c               ! clear zero flag
247
        ret
248
!
249
! this routine zeroes out a buffer in memory which is
250
! then used by other scanning routines
251
!
252
zbuf:   xra     a               ! get a zero
253
        lxi     d,abuf+12       ! buffer address
254
        mvi     b,12            ! buffer length
255
zbu1:   dcx     d               ! decrement address
256
        stax    d               ! zero buffer
257
        dcr     b
258
        jnz     zbu1
259
        ret
260
!
261
! this routine calls etra to obtain the input parameter
262
! values and calls an error routine if an error occured
263
! in that routine
264
!
265
valc:   call    etra            ! get input parameters
266
        jc      what            ! jump if error
267
        ret
268
!
269
! this routine extracts the values associated with a
270
! command from the input stream and places them in the
271
! ascii buffer (abuf).  it also calls a routine to
272
! convert the ascii hexadecimals to binary and stores
273
! them in the binary buffer (bbuf).  on return, carry
274
! set indicates an error in input parameters.
275
!
276
etra:   lxi     h,0             ! get a zero
277
        shld    bbuf+2          ! zero value
278
        shld    fbuf            ! set no file name
279
        call    zbuf            ! zero buffer
280
        lxi     h,ibuf-1
281
val1:   inx     h
282
        mov     a,m             ! fetch input character
283
        cpi     ' '             ! look for first character
284
        cmc
285
        rnc                     ! return if no carry
286
        jnz     val1            ! jump if no black
287
        shld    pntr            ! save pointer
288
        call    sblk            ! scan to first parameter
289
        cmc
290
        rnc                     ! return if cr
291
        cpi     '/'
292
        jnz     val5            ! no file name
293
        lxi     d,fbuf          ! name follows put in fbuf
294
        mvi     c,nmlen
295
val2:   inx     h
296
        mov     a,m
297
        cpi     '/'
298
        jz      val3
299
        dcr     c
300
        jm      what
301
        stax    d               ! store file name
302
        inx     d
303
        jmp     val2
304
val3:   mvi     a,' '           ! get an ascii space
305
val4:   dcr     c
306
        jm      done
307
        stax    d               ! fill in with spaces
308
        inx     d
309
        jmp     val4
310
done:   call    sbl2
311
        cmc
312
        rnc
313
val5:   lxi     d,abuf
314
        call    alps            ! place parameter in buffer
315
        mov     a,b             ! get digit count
316
        cpi     5               ! check number of digits
317
        cmc
318
        rc                      ! return if too many digits
319
        lxi     b,abuf
320
        call    ahex            ! convert value
321
        rc                      ! illegal character
322
        shld    bbuf            ! save in binary buffer
323
        lxi     h,abuf
324
        call    norm            ! normalize ascii value
325
        call    sblk            ! scan to next parameter
326
        cmc
327
        rnc                     ! return if cr
328
        lxi     d,abuf+4
329
        call    alps            ! place parameters in buffer
330
        mov     a,b             ! get digit count
331
        cpi     5               ! check number of digits
332
        cmc
333
        rc                      ! return if too many digits
334
        lxi     b,abuf+4
335
        call    ahex            ! convert value
336
        rc                      ! illegal value
337
        shld    bbuf+2          ! save in binary buffer
338
        lxi     h,abuf+4
339
        call    norm            ! normalize ascii value
340
        ora     a               ! clear carry
341
        ret
342
!
343
! this routine fetches digits from the buffer addressed
344
! by b,c and converts the ascii decimal digits into
345
! binary.  up to a 16-bit value can be converted.  the
346
! scan stops when a binary zero is found in the buffer.
347
!
348
adec:   lxi     h,0             ! get a 16 bit zero
349
ade1:   ldax    b               ! fetch ascii digit
350
        ora     a               ! set zero flag
351
        rz                      ! return iff finished
352
        mov     d,h             ! save current value
353
        mov     e,l             ! save current value
354
        dad     h               ! times two
355
        dad     h               ! times two
356
        dad     d               ! add in original value
357
        dad     h               ! times two
358
        sui     48              ! ascii bias
359
        cpi     10              ! check for legal value
360
        cmc
361
        rc                      ! return if error
362
        mov     e,a
363
        mvi     d,0
364
        dad     d               ! add in next digit
365
        inx     b               ! increment pointer
366
        jmp     ade1
367
!
368
! this routine fetches digits from the buffer addressed
369
! by b,c and converts the ascii hexadecimal digits into
370
! binary.  up to a 16-bit value can be converted.  the
371
! scan stops when a binary zero is foundin the buffer.
372
!
373
ahex:   lxi     h,0             ! get a 16 bit zero
374
ahe1:   ldax    b               ! fetch ascii digit
375
        ora     a               ! set zero flag
376
        rz                      ! return if done
377
        dad     h               ! left shift
378
        dad     h               ! left shift
379
        dad     h               ! left shift
380
        dad     h               ! left shift
381
        call    ahs1            ! convert to binary
382
        cpi     $10             ! check for legal value
383
        cmc
384
        rc                      ! return if error
385
        add     l
386
        mov     l,a
387
        inx     b               ! increment pointer
388
        jmp     ahe1
389
!
390
! this routine converts ascii hex digits into binary
391
!
392
ahs1:   sui     48              ! ascii bias
393
        cpi     10              ! digit 0-10
394
        rc
395
        sui     7               ! alpha bias
396
        ret
397
!
398
! this routine converts a binary value to ascii
399
! hexadecimal and outputs the characters to the tty.
400
!
401
hout:   call    binh
402
        lxi     h,hcon
403
chot:   mov     b,m
404
        call    out8
405
        inx     h
406
        mov     b,m
407
        call    out8
408
        ret
409
!
410
! this routine does the same as above but outputs a
411
! blank after the last character
412
!
413
hotb:   call    hout            ! convert and output
414
        call    blk1            ! output a blank
415
        ret
416
!
417
! this routine converts a binary value to ascii
418
! decimal digits and optputs the characters to the tty
419
!
420
 
421
dout:   call    bind            ! convert value
422
        call    hout+3          ! output value (2 digits)
423
        inx     h
424
        mov     b,m             ! get last digit
425
        call    out8            ! output
426
        ret
427
!
428
! this routine outputs a blank
429
!
430
blk1:   mvi     b,' '           ! get a blank
431
        call    out8
432
        ret
433
!
434
! this routine is used by other routines to increment
435
! the starting address in a command and compare it with
436
! the final address in the command.  on return, the
437
! carry flag set indicates that the final address has
438
! been reached.
439
!
440
achk:   lhld    bbuf            ! fetch start address
441
        lda     bbuf+3          ! stop address (high)
442
        cmp     h               ! compare addresses
443
        jnz     ach1
444
        lda     bbuf+2          ! stop address (low)
445
        cmp     l               ! compare addresses
446
        jnz     ach1
447
        stc                     ! set carry if equal
448
ach1:   inx     h               ! increment start addresses
449
        shld    bbuf            ! store start address
450
        ret
451
!
452
! this routine outputs character of a string
453
! until a carriage return is found
454
!
455
scrn:   mov     b,m             ! fetch character
456
        mvi     a,13            ! carriage return
457
        cmp     b               ! character = cr?
458
        rz
459
        call    out8
460
        inx     h
461
        jmp     scrn
462
!
463
! this routine converts the binary value in reg a into
464
! ascii hexadecimal digits and stores them in memory
465
!
466
binh:   lxi     h,hcon          ! conversion
467
        mov     b,a             ! save value
468
        rar
469
        rar
470
        rar
471
        rar
472
        call    bin1
473
        mov     m,a
474
        inx     h
475
        mov     a,b
476
        call    bin1            ! convert to ascii
477
        mov     m,a
478
        ret
479
!
480
! this routine converts a value to hexadecimal
481
!
482
bin1:   ani     $f              ! low 4 bits
483
        adi     48              ! convert to ascii
484
        cpi     58              ! digit 0-9
485
        rc
486
        adi     7               ! modify for a-f
487
        ret
488
!
489
! this routine converts the binary value in reg a into
490
! ascii decimal digits and stores them in memory
491
!
492
bind:   lxi     h,hcon          ! conversion address
493
        mvi     b,100
494
        call    bid1            ! convert hundreds digit
495
        mvi     b,10
496
        call    bid1            ! convert tens digit
497
        adi     '0'             ! get units digit
498
        mov     m,a             ! store in memory
499
        ret
500
!
501
! this routine converts a value to decimal
502
!
503
bid1:   mvi     m,'0'-1         ! initialize digit count
504
        inr     m
505
        sub     b               ! check digit
506
        jnc     bid1+2
507
        add     b               ! restore value
508
        inx     h
509
        ret
510
!
511
! legal command table
512
!
513
ctab:   defb    'dump'
514
        defw    dump
515
        defb    'exec'
516
        defw    exec
517
        defb    'entr'
518
        defw    entr
519
        defb    'file'
520
        defw    file
521
        defb    'list'
522
        defw    list
523
        defb    'delt'
524
        defw    dell
525
        defb    'assm'
526
        defw    assm
527
        defb    'page'
528
        defw    pagemov
529
        defb    'cust'
530
        defw    $2000
531
        defb    'brek'
532
        defw    break
533
        defb    'proc'
534
        defw    proc
535
!
536
! this routine checks if any parameters were entered
537
! with the command, if not an error message is issued
538
!
539
vchk:   lda     abuf            ! fetch parameter byte
540
        ora     a               ! set flags
541
        jz      what            ! no parameter
542
        ret
543
!
544
! this routine dumps out the fontents of memory from
545
! the start to final addresses given in the command.
546
!
547
dump:   call    vchk            ! check for parameters
548
dums:   call    crlf            ! start new line
549
dum1:   lhld    bbuf            ! fetch memory address
550
        mov     a,m
551
        call    hotb            ! output value
552
        call    achk            ! check address
553
        rc                      ! return if finished
554
        mov     a,l             ! is next address
555
        ani     $0f             ! divisible by 16?
556
        jnz     dum1
557
        jmp     dums
558
!
559
! this routine will move 256 bytes from 1st address
560
! given in command to 2nd address in command.
561
!
562
pagemov:call    vchk            ! check for parameter
563
        lda     abuf+4          ! fetch 2nd parameter
564
        ora     a               ! does 2nd parameter exist?
565
        jz      what
566
        lhld    bbuf            ! fetch move to address
567
        xchg
568
        lhld    bbuf+2          ! fetch move to address
569
        mvi     b,0             ! set counter
570
pag1:   ldax    d
571
        mov     m,a
572
        inx     h
573
        inx     d
574
        dcr     b               ! decrement counter
575
        jnz     pag1
576
        ret
577
!
578
! this command initializes the beginning of file address
579
! and end of file address as well as the file area
580
! when the file command is used
581
!
582
file:   call    crlf
583
! check for file parameters
584
        lda     fbuf
585
        ora     a
586
        jz      fout            ! no ? go list
587
        call    fsea            ! look up file
588
        xchg                    ! pntr in de
589
        jnz     test
590
! no entry
591
        lda     abuf            ! check for param
592
        ora     a
593
        jz      wha1            ! no?? - error
594
! check for room in directory
595
        lda     fef
596
        ora     a
597
        jnz     room
598
        lxi     h,emes1
599
        jmp     mess
600
! entry found are these parameters
601
test:   lda     abuf
602
        ora     a
603
        jz      swaps
604
        lhld    bbuf
605
        mov     a,h
606
        ora     l
607
        jz      swaps
608
        lxi     h,emes2         ! no-no can?t do
609
        jmp     mess            ! it - delete first
610
! move file name to block pointed to by fread
611
room:   lhld    fread
612
        xchg
613
        lxi     h,fbuf          ! file name pointer in h,l
614
        push    d
615
        mvi     c,nmlen         ! name length count
616
mov23:  mov     a,m
617
        stax    d
618
        inx     d
619
        dcr     c               ! test count
620
        inx     h
621
        jnz     mov23
622
        pop     d               ! restore entry pointer
623
! make file pointed to by d,e current
624
swaps:  lxi     h,file0
625
        mvi     c,felen         ! entry length
626
swap:   ldax    d
627
        mov     b,m
628
        mov     m,a             ! exchange
629
        mov     a,b
630
        stax    d
631
        inx     d
632
        inx     h               ! bump pointer
633
        dcr     c               ! test count
634
        jnz     swap
635
 
636
! check for 2nd parameter
637
            lda abuf
638
        ora     a
639
        jz      foot            ! no second parameter
640
! process 2nd parameter
641
        lhld    bbuf            ! get address
642
        shld    bofp            ! set begin
643
        shld    eofp            ! set end
644
        mov     a,l             ! is address zero
645
        ora     h
646
        jz      fil35           ! yes
647
fil30:  mvi     m,1             ! non-zero ? set eof
648
fil35:  xra     a               ! and max line #
649
        sta     maxl
650
        jmp     foot            ! output parameters
651
fout:   lda     ibuf+4
652
        cpi     's'             ! is command files?
653
        mvi     c,maxfil
654
        jz      foul
655
foot:   mvi     c,1
656
! output the # of entries in c
657
foul:   lxi     h,file0
658
        mov     a,c
659
fine:   sta     focnt           ! save count
660
        push    h
661
        lxi     d,nmlen
662
        dad     d
663
        mov     a,m
664
        ora     a
665
        jnz     food
666
        inx     h
667
        add     m
668
        inx     h
669
        jnz     food            ! non zero, ok to output
670
        inx     sp
671
        inx     sp
672
        inx     h
673
        inx     h
674
        jmp     feet
675
! have an entry to output
676
food:   pop     h               ! ptr
677
        mvi     c,nmlen
678
fast:   mov     b,m             ! load character to b
679
        call    out8
680
        dcr     c
681
        inx     h
682
        jnz     fast            ! do the rest
683
! now output begin-end ptrs
684
        call    fool            ! output begin
685
        call    fool            ! output end
686
        call    crlf            ! and c/r
687
! test count, h,l points past eofp
688
feet:   lxi     d,felen-nmlen-4
689
        dad     d               ! move to next entry
690
        lda     focnt
691
        dcr     a               ! test count
692
        jnz     fine            ! more to do
693
        ret                     ! done!
694
! output number pointed to by h,l
695
! on ret, h,l point 2 words later
696
fool:   call    blk1            ! space
697
        inx     h
698
        mov     a,m
699
        dcx     h
700
        push    h
701
        call    hout            ! output
702
        pop     h
703
        mov     a,m
704
        inx     h
705
        inx     h
706
        push    h
707
        call    hotb            ! output
708
        pop     h               ! restore h,l
709
        ret
710
!
711
! search the file directory for the file
712
! whose name is in fbuf.
713
! return if found, zero if off, h,l point to
714
! entry while searching, on entry found with addr
715
! zero, set fef to >0 and fread to the addr of entry
716
!
717
fsea:   xra     a
718
        sta     fef             ! claim no free entries
719
        mvi     b,maxfil        ! count of entries
720
        lxi     d,file0         ! table address
721
fse10:  lxi     h,fbuf
722
        mvi     c,nmlen
723
        call    sear            ! test strings
724
        push    psw             ! save flag
725
        push    d
726
        ldax    d               ! get bofp
727
        ora     a               ! empty entry?
728
        jnz     fse20
729
        inx     d               ! store other word
730
        ldax    d
731
        ora     a
732
        jnz     fse20           ! nope-go test for match
733
        xchg
734
        lxi     d,-nmlen-1
735
        dad     d               ! move to beginning
736
        shld    fread           ! save addr
737
        mov     a,d
738
        sta     fef             ! set free entry found
739
        pop     h               ! restore interim ptr
740
        pop     psw             ! unjunk stack
741
! move to next entry
742
fse15:  lxi     d,felen-nmlen
743
        dad     d
744
        xchg                    ! next entry in de
745
        dcr     b               ! test count
746
        rz                      ! done--nope
747
        jmp     fse10           ! try next
748
! entry wasn?t free, test for match
749
fse20:  pop     h
750
        pop     psw
751
        jnz     fse15           ! if zero clear, no match
752
! entry found
753
        lxi     d,-nmlen        ! backup
754
        dad     d               ! h,l points to entry
755
        mov     a,d
756
        ora     a               ! clear zero
757
        ret                     ! that?s all
758
!
759
! output error message for illegal command
760
!
761
what:   call    crlf            ! out crlf
762
wha1:   lxi     h,emes          ! message address
763
mess:   call    scrn
764
        jmp     eor
765
!
766
emes:   defb    'what'
767
        defb    13
768
emes1:  defb    'full',13
769
emes2:  defb    'no no',13
770
!
771
! call routine to enter data into memory
772
! and check for error on return
773
!
774
! this routine is used to enter data values into memory.
775
! each value is one byte and is written in hexadecimal
776
! values greater than 255 will cause carry to be set
777
! and return to be made to calling program
778
!
779
entr:   call    vchk            ! check for parameters
780
        call    ents
781
        jc      what
782
        call    crlf
783
        ret
784
!
785
eend:   equ     '/'             ! termination character
786
ents:   call    crlf
787
        call    read            ! read input data
788
        lxi     h,ibuf          ! set line pointer
789
        shld    pntr            ! save pointer
790
ent1:   call    zbuf            ! clear buffer
791
        call    sblk            ! scan to first value
792
        jc      ents            ! jump if cr found
793
        cpi     eend
794
        rz                      ! return carry is zero
795
        call    alps            ! place value in buffer
796
        mov     a,b             ! get digit count
797
        cpi     3               ! check nmbr of digits
798
        cmc
799
        rc                      ! return if more than 2 digits
800
        lxi     b,abuf          ! conversion address
801
        call    ahex            ! convert value
802
        rc                      ! error in hex character
803
        mov     a,l
804
        lhld    bbuf            ! fetch memory address
805
        mov     m,a             ! put in memory
806
        call    ach1            ! increment memory location
807
        jmp     ent1
808
!
809
! this routine is used to enter lines into the file
810
! area.  the line number is first checked to see if it is
811
! a valid number (0000-9999).  next it is checked to see
812
! if it is greater than the maximum current line number.
813
! if it is, the next line is inserted at the end of the
814
! current file and the maximum line number is updated as
815
! well as the end of file position.  line numbers that
816
! already exist are inserted into the file area at the
817
! appropriate place and any extra characters in the old
818
! line are deleted.
819
!
820
line:   lda     file0           ! is a file defined?
821
        ora     a
822
        jz      what            ! abort if not
823
        mvi     c,4             ! no of digits to check
824
        lxi     h,ibuf-1                !initialize address
825
lick:   inx     h
826
        mov     a,m             ! fetch line digit
827
        cpi     '0'             ! check for valid number
828
        jc      what
829
        cpi     '9'+1
830
        jnc     what
831
        dcr     c
832
        jnz     lick
833
        shld    adds            ! find address
834
        lxi     d,maxl+3        ! get address
835
        call    com0
836
        jnc     insr
837
! get here if new line is greater than maximum line #
838
        inx     h
839
        call    lodm            ! get new line number
840
        lxi     h,maxl+3
841
        call    stom            ! make it maximum line number
842
        lxi     d,ibuf-1
843
        lhld    eofp            ! end of file position
844
        mvi     c,1
845
        call    lmov            ! place line in file
846
seof:   mvi     m,1             ! end of file indicator
847
        shld    eofp            ! end of file address
848
        jmp     eor
849
! get here if new line must be inserted into already
850
! eisting file area
851
insr:   call    fin1            ! find line in file
852
        mvi     c,2
853
        jz      equl
854
        dcr     c               ! new ln not equal to some old ln
855
equl:   mov     b,m
856
        dcx     h
857
        mvi     m,2             ! move line indicator
858
        shld    insp            ! insert line position
859
        lda     ibuf-1          ! new line count
860
        dcr     c
861
        jz      less            !new ln not = old ln
862
        sub     b               !count difference
863
        jz      zero            !line lengths equal
864
        jc      more
865
! get here if # of chars in old line > # of chars in
866
! new line or new line # was not equal to sold old
867
! line #
868
less:   lhld    eofp            !end of file address
869
        mov     d,h
870
        mov     e,l
871
        call    adr             !move to address
872
        shld    eofp            !new end of file address
873
        mvi     c,2
874
        call    rmov            !open up file area
875
        jmp     zero
876
! get here if # of chars in old line < # of chars in
877
! new line
878
more:   cma
879
        inr     a               !count difference
880
        mov     d,h
881
        mov     e,l
882
        call    adr
883
        xchg
884
        call    lmov            !delete excess char in file
885
        mvi     m,1             !e-o-f indicator
886
        shld    eofp            !e-o-f address
887
! get here to insert line into file area
888
zero:   lhld    insp            !insert address
889
        mvi     m,ascr
890
        inx     h
891
        lxi     d,ibuf-1                !new line address
892
        mvi     c,1             !check value
893
        call    lmov            !place line in file
894
        jmp     eor
895
!
896
! this routine is used to find a ln in the file area
897
! which is greater than or equal to the current line #
898
!
899
find:   lxi     h,abuf+3                !buffer address
900
        shld    adds            !save address
901
fin1:   lhld    bofp            !begin file address
902
        mov     a,h             !return to monitor if
903
        ora     l               !  file is empty...
904
        jz      eor
905
fi1:    call    eo1             !check for end of file
906
        xchg
907
        lhld    adds            !fetch find address
908
        xchg
909
        mvi     a,4
910
        call    adr             !bump line address
911
        call    com0            !compare line numbers
912
        rc
913
        rz
914
fi2:    mov     a,m
915
        call    adr             !next line address
916
        jmp     fi1
917
!
918
! when searching through the file area, this routine
919
! checks to see if the current address is the end of
920
! file
921
!
922
eof:    inx     h
923
eo1:    mvi     a,1             !e-o-f indicator
924
        cmp     m
925
        rnz
926
        jmp     eor
927
!
928
! this routine is used to add a value to an address
929
! contained in register h,l
930
!
931
adr:    add     l
932
        mov     l,a
933
        rnc
934
        inr     h
935
        ret
936
!
937
! this routine will move character strings from one
938
! location of memory to another
939
! characters are moved from location addressed by d,e
940
! to location addressed by h,l.  additional characters
941
! are moved by bumping pointers until the character in
942
! reg c is fetched.
943
!
944
lmov:   ldax    d               !fetch character
945
        inx     d               !increment fetch address
946
        cmp     c               !termination character
947
        rz
948
        mov     m,a             !store character
949
        inx     h               !increment store address
950
        jmp     lmov
951
!
952
! this routine is similar to above except that the
953
! character address is decremented after each fetch
954
! and store
955
!
956
rmov:   ldax    d               !fetch character
957
        dcx     d               !decrement fetch character
958
        cmp     c               !termination character
959
        rz
960
        mov     m,a             !store character
961
        dcx     h               !decrement store address
962
        jmp     rmov
963
!
964
! this routine is used to load four characters from
965
! memory into registers
966
!
967
 
968
lodm:   mov     b,m             !fetch character
969
        inx     h
970
        mov     c,m             !fetch character
971
        inx     h
972
        mov     d,m             !fetch character
973
        inx     h
974
        mov     e,m             !fetch character
975
        ret
976
!
977
! this routine stores four characters from the registers
978
! into memory
979
!
980
stom:   mov     m,e             !store character
981
        dcx     h
982
        mov     m,d             !store character
983
        dcx     h
984
        mov     m,c             !store character
985
        dcx     h
986
        mov     m,b             !store character
987
        ret
988
!
989
! this routine is used to compare two character strings
990
! of length 4, on return zero flag set means both
991
! strings are equal.  carry flag =0 means string address
992
! by d,e was greater than or equal to character string
993
! addressed by h,l
994
!
995
com0:   mvi     b,1             !equal counter
996
        mvi     c,4             !string length
997
        ora     a               !clear carry
998
co1:    ldax    d               !fetch character
999
        sbb     m               !compare characters
1000
        jz      co2
1001
        inr     b               !increment equal counter
1002
co2:    dcx     d
1003
        dcx     h
1004
        dcr     c
1005
        jnz     co1
1006
        dcr     b
1007
        ret
1008
!
1009
! this routine is similar to the above routine except on
1010
! return carry flag = 0 means that character string
1011
! addressed by d,e is only > string addressed by h,l.
1012
!
1013
com1:   mvi     c,4             !string length
1014
        ldax    d               !tch character
1015
        sui     1
1016
        jmp     co1+1
1017
!
1018
! this routine will take ascii characters and add any
1019
! necessary ascii zeroes so the result is a 4 character
1020
! ascii value
1021
!
1022
norm:   call    lodm            !load characters
1023
        xra     a               !fetch a zero
1024
        cmp     b
1025
        rz
1026
nor1:   cmp     e
1027
        cnz     stom            !store values
1028
        rnz
1029
        mov     e,d             !normalize value
1030
        mov     d,c
1031
        mov     c,b
1032
        mvi     b,'0'
1033
        jmp     nor1
1034
!
1035
! this routine is used to list the contents of the file
1036
! area starting at the line number given in the command
1037
!
1038
list:   call    crlf
1039
        call    find            !find starting line number
1040
list0:  inx     h               !output line...
1041
        call    scrn
1042
        call    crlf
1043
        call    eof             !check for end of file
1044
        call    ink             !check for ?x
1045
        jnz     list0           !loop if no ?x
1046
        ret
1047
!
1048
! this routine is used to delete lines from the
1049
! file area.  the remaining file area is then moved in
1050
! memory so that there is no excess space.
1051
!
1052
dell:   call    vchk            !check for parameter
1053
        call    find            !find line in file area
1054
        shld    delp            !save delete position
1055
        lxi     h,abuf+7
1056
        mov     a,m             !check for 2nd parameter
1057
        ora     a               !set flags
1058
        jnz     del1
1059
        lxi     h,abuf+3                !use first parameter
1060
del1:   shld    adds            !save find address
1061
        xchg
1062
        lxi     h,maxl+3
1063
        call    com0            !compare line numbers
1064
        lhld    delp            !load delete position
1065
        jc      novr
1066
! get here if deletion involves end of file
1067
        shld    eofp            !change e-o-f position
1068
        mvi     m,1             !set e-o-f indicator
1069
        xchg
1070
        lhld    bofp
1071
        xchg
1072
        mvi     b,13            !set scan switch
1073
        dcx     h               !check for bofp
1074
del2:   mov     a,l
1075
        sub     e
1076
        mov     a,h
1077
        sbb     d
1078
        mvi     a,ascr          !look for cr
1079
        jc      del4            !decremented past bof
1080
        dcr     b
1081
        dcx     h
1082
        cmp     m               !find new max ln
1083
        jnz     del2
1084
        dcx     h
1085
        mov     a,l
1086
        sub     e
1087
        mov     a,h
1088
        sbb     d
1089
        jc      del5
1090
        cmp     m               !end of previous line
1091
        inx     h
1092
        inx     h
1093
        jz      del3
1094
        inx     h
1095
del3:   call    lodm            !load new max ln
1096
        lxi     h,maxl+3                !set address
1097
        call    stom            !store new max ln
1098
        ret
1099
del4:   cmp     b               !check switch
1100
del5:   xchg
1101
        jnz     del3-1
1102
        sta     maxl            !make max ln a small number
1103
        ret
1104
! get here if deletion is in the middle of file area
1105
novr:   call    fi1             !find end of delete area
1106
        cz      fi2             !next line if this ln equal
1107
nov1:   xchg
1108
        lhld    delp            !char move to position
1109
        mvi     c,1             !move terminator
1110
        call    lmov            !compact file area
1111
        shld    eofp            !set eof position
1112
        mvi     m,1             !set eof indicator
1113
        ret
1114
!
1115
! starting here is the self assembler program
1116
! this program assembles programs which are
1117
! in the file area
1118
!
1119
assm:   call    vchk            !check for parameters
1120
        lda     abuf+4          !get 2nd parameter
1121
        ora     a               !check for prarmeters
1122
        jnz     asm4
1123
        lhld    bbuf            !fetch 1st parameter
1124
        shld    bbuf+2          !store into 2nd parameter
1125
asm4:   lda     ibuf+4          !fetch input character
1126
        sui     'e'             !reset a if errors only
1127
        sta     aerr            !save error flag
1128
        xra     a               !get a zero
1129
        sta     nola            !initialize label count
1130
asm3:   sta     pasi            !set pass indicator
1131
        call    crlf            !indicate start of pass
1132
        lhld    bbuf            !fetch origin
1133
        shld    aspc            !initialize pc
1134
        lhld    bofp            !get start of file
1135
        shld    apnt
1136
asm1:   lhld    apnt            !fetch line pointer
1137
        lxi     sp,area+18
1138
        mov     a,m             !fetch character
1139
        cpi     1               !end of file?
1140
        jz      eass            !jump if end of file
1141
        xchg
1142
        inx     d               !increment address
1143
        lxi     h,obuf          !blank start address
1144
        mvi     a,ibuf-5 and $0ff       !blank end address
1145
        call    cler            !blank out buffer
1146
        mvi     c,ascr          !stop character
1147
        call    lmov            !move line into buffer
1148
        mov     m,c             !place cr in buffer
1149
        xchg
1150
        shld    apnt            !save address
1151
        lda     pasi            !fetch pass indicator
1152
        ora     a               !set flagw
1153
        jnz     asm2            !jump if pass 2
1154
        call    pas1
1155
        jmp     asm1
1156
!
1157
asm2:   call    pas2
1158
        lxi     h,obuf          !output buffer address
1159
        call    aout            !output line
1160
        jmp     asm1
1161
!
1162
! this routine is used to output the listing for
1163
! an assembly.  it checks the error switch to see if
1164
! all lines are to be printed or just those with
1165
! errors.
1166
!
1167
aout:   lda     aerr            !fetch error switch
1168
        ora     a               !set flags
1169
        jnz     aou1            !output all lines
1170
aou2:   lda     obuf            !fetch error indicator
1171
        cpi     ' '             !check for an error
1172
        rz                      !return if no error
1173
aou1:   lxi     h,obuf          !output buffer address
1174
        call    scrn            !output line...
1175
        call    crlf
1176
        ret
1177
!
1178
! pass 1 of assembler, used to form symbol table
1179
!
1180
pas1:   call    zbuf            !clear buffer
1181
        sta     pasi            !set for pass1
1182
        lxi     h,ibuf          !initialize line pointer
1183
        shld    pntr
1184
        mov     a,m             !fetch character
1185
        cpi     ' '             !check for a blank
1186
        jz      opc             !jump if no lable
1187
        cpi     '*'             !check for comment
1188
        rz                      !return if comment
1189
!
1190
! process label
1191
!
1192
        call    slab            !get and check label
1193
        jc      op5             !error in label
1194
        jz      errd            !duplicate label
1195
        call    lchk            !check character after label
1196
        jnz     op5             !error if no blank
1197
        mvi     c,llab          !length of labels
1198
        lxi     h,abuf          !set buffer address
1199
mlab:   mov     a,m             !fetch next character
1200
        stax    d               !store in symbol table
1201
        inx     d
1202
        inx     h
1203
        dcr     c
1204
        jnz     mlab
1205
        xchg
1206
        shld    taba            !save table address for equ
1207
        lda     aspc+1          !fetch pc (high)
1208
        mov     m,a
1209
        inx     h
1210
        lda     aspc            !fetch pc (low)
1211
        mov     m,a             !store in table
1212
        lxi     h,nola
1213
        inr     m               !increment number of labels
1214
!
1215
! process opcode
1216
!
1217
opc:    call    zbuf            !zero working buffer
1218
        call    sblk            !scan to opcode
1219
        jc      oerr            !found carriage return
1220
        call    alps            !place opcode in buffer
1221
        cpi     ' '             !check for blank after opcode
1222
        jc      opcd            !cr after opcode
1223
        jnz     oerr            !error if no blank
1224
        jmp     opcd            !check opcode
1225
!
1226
! this routine checks the character after a label
1227
! for a blank or colon
1228
!
1229
lchk:   lhld    pntr
1230
        mov     a,m             !get character after label
1231
        cpi     ' '             !check for blank
1232
        rz                      !return if a blank
1233
        cpi     ':'             !check for colon
1234
        rnz
1235
        inx     h
1236
        shld    pntr            !save pointer
1237
        ret
1238
!
1239
! process any pseudo ops that need to be in pass 1
1240
!
1241
psu1:   call    sblk            !scan to operand
1242
        ldax    d               !fetch value
1243
        ora     a               !set flags
1244
        jz      org1            !org opcode
1245
        jm      dat1            !data statement
1246
        jpo     equ1            !equ opcode
1247
        cpi     5
1248
        jc      res1            !res opcode
1249
        jnz     eass            !jump if end
1250
! do dw pseudo/op
1251
aco1:   mvi     c,2             !2 byte instruction
1252
        xra     a               !get a zero
1253
        jmp     ocn1            !add value to program counter
1254
! do org psuedo op
1255
org1:   call    ascn            !get operand
1256
        lda     obuf            !fetch error indicator
1257
        cpi     ' '             !check for an error
1258
        rnz
1259
        shld    aspc            !store new origin
1260
        lda     ibuf            !get first character
1261
        cpi     ' '             !check for an error
1262
        rz                      !no label
1263
        jmp     equs            !change label value
1264
! do equ psuedo-op
1265
equ1:   call    ascn            !get operand
1266
        lda     ibuf            !fetch 1st character
1267
        cpi     ' '             !check for label
1268
        jz      errm            !missing label
1269
equs:   xchg
1270
        lhld    taba            !symbol table address
1271
        mov     m,d             !store label value
1272
        inx     h
1273
        mov     m,e
1274
        ret
1275
! do ds pseudo-op
1276
res1:   call    ascn            !get operand
1277
        mov     b,h
1278
        mov     c,l
1279
        jmp     res21           !add value to program counter
1280
!
1281
! do db pseudo-op
1282
!
1283
dat1:   jmp     dat2a
1284
!
1285
! perform pass 2 of the assembler
1286
!
1287
pas2:   lxi     h,obuf+2                !set output buffer address
1288
        lda     aspc+1          !fetch pc (high)
1289
        call    binh+3          !convert for output
1290
        inx     h
1291
        lda     aspc            !fetch pc(low)
1292
        call    binh+3          !convert for output
1293
        inx     h
1294
        shld    oind            !save output address
1295
        call    zbuf            !clear buffer
1296
        lxi     h,ibuf          !initialize line pointer
1297
pabl:   shld    pntr            !save pointer
1298
        mov     a,m             !fetch first character
1299
        cpi     ' '             !check for label
1300
        jz      opc             !get opcode
1301
        cpi     '*'             !check for comment
1302
        rz                      !return if comment
1303
        call    slab            !scan off label
1304
        jc      errl            !error in label
1305
        call    lchk            !check for a blank or colon
1306
        jnz     errl            !error if not a blank
1307
        jmp     opc
1308
!
1309
! process pseudo ops for pass2
1310
!
1311
psu2:   ldax    d
1312
        ora     a               !set flags
1313
        jz      org2            !org opcode
1314
        jm      dat2            !data opcode
1315
        jpo     equ2            !equate pseudo-op
1316
        cpi     5
1317
        jc      res2            !res opcode
1318
        jnz     eass            !end opcode
1319
! do dw opcode
1320
aco2:   call    tys6            !get value
1321
        jmp     aco1
1322
! do ds pseudo-op
1323
res2:   call    asbl            !get operand
1324
        mov     b,h
1325
        mov     c,l
1326
        lhld    bbuf+2          !fetch storage counter
1327
        dad     b               !add value
1328
        shld    bbuf+2
1329
res21:  xra     a               !get a zero
1330
        jmp     ocn2
1331
! do db pseudo-op
1332
dat2:   call    ty55            !get operand
1333
dat2a:  xra     a               !make zero
1334
        mvi     c,1             !byte count
1335
        jmp     ocn1
1336
!
1337
! handle equates on 2nd pass
1338
!
1339
equ2:   call    asbl            !get operand into hl and
1340
                                !  fall into next routine
1341
!
1342
! store contents of hl as hex ascii at obuf+2
1343
!   on return, de holds value which was in hl.
1344
!
1345
binad:  xchg                    !put value into de
1346
        lxi     h,obuf+2                !pointer to addr in obuf
1347
        mov     a,d             !store hi byte
1348
        call    binh+3
1349
        inx     h
1350
        mov     a,e             !store low byte...
1351
        call    binh+3
1352
        inx     h
1353
        ret
1354
! do org pseudo-op
1355
org2:   call    asbl            !get new origin
1356
        lda     obuf            !get error indicator
1357
        cpi     ' '             !check for an error
1358
        rnz                     !don?t modify pc if error
1359
        call    binad           !store new addr in obuf
1360
        lhld    aspc            !fetch pc
1361
        xchg
1362
        shld    aspc            !store new pc
1363
        mov     a,l
1364
        sub     e               !form difference of origins
1365
        mov     e,a
1366
        mov     a,h
1367
        sbb     d
1368
        mov     d,a
1369
        lhld    bbuf+2          !fetch storage pointer
1370
        dad     d               !modify
1371
        shld    bbuf+2          !save
1372
        ret
1373
!
1374
! process 1 byte instructions without operands
1375
!
1376
typ1:   call    asto            !store value in memory
1377
        ret
1378
!
1379
! process stax and ldax instructions
1380
!
1381
typ2:   call    asbl            !fetch operand
1382
        cnz     errr            !illegal register
1383
        mov     a,l             !get low order operand
1384
        ora     a               !set flags
1385
        jz      ty31            !operand = 0
1386
        cpi     2               !operand = 2
1387
        cnz     errr            !illegal register
1388
        jmp     ty31
1389
!
1390
! process push, pop, inx, dcx, dad instructions
1391
!
1392
typ3:   call    asbl            !fetch operand
1393
        cnz     errr            !illegal register
1394
        mov     a,l             !get low order operand
1395
        rrc                     !check low order bit
1396
        cc      errr            !illegal register
1397
        ral                     !restore
1398
        cpi     8
1399
        cnc     errr            !illegal register
1400
ty31:   rlc                     !multiply by 8
1401
        ral
1402
        ral
1403
ty32:   mov     b,a
1404
        ldax    d               !fetch opcode base
1405
        add     b               !form opcode
1406
        cpi     118             !check for mov m,m
1407
        cz      errr            !illegal register
1408
        jmp     typ1
1409
!
1410
! process accumulator, inr,dcr,mov,rst instructions
1411
!
1412
typ4:   call    asbl            !fetch operand
1413
        cnz     errr            !illegal register
1414
        mov     a,l             !get low order operand
1415
        cpi     8
1416
        cnc     errr            !illegal register
1417
        ldax    d               !fetch opcode base
1418
        cpi     64              !check for mov instruction
1419
        jz      ty41
1420
        cpi     199
1421
        mov     a,l
1422
        jz      ty31            !rst instruction
1423
        jm      ty32            !accumulator instruction
1424
        jmp     ty31            !inr, dcr
1425
! process mov instruction
1426
ty41:   dad     h               !multiply operand by 8
1427
        dad     h
1428
        dad     h
1429
        add     l               !form opcode
1430
        stax    d               !save opcode
1431
        call    mpnt
1432
        call    ascn
1433
        cnz     errr            !increment pointer
1434
        mov     a,l
1435
        cpi     8
1436
        cnc     errr            !illegal register
1437
        jmp     ty32
1438
!
1439
! process immediate instructions
1440
! immediate byte can between -256 and +255
1441
! mvi instruction is a special case and contains
1442
! 2 arguments in operand
1443
!
1444
typ5:   cpi     6               !check for mvi
1445
        cz      ty56
1446
        call    asto            !store object byte
1447
ty55:   call    asbl            !get immediate argument
1448
        inr     a
1449
        cpi     2               !check operand for range
1450
        cnc     errv
1451
        mov     a,l
1452
        jmp     typ1
1453
!
1454
! fetch 1st arg for mvi and lxi instructions
1455
!
1456
ty56:   call    asbl            !fetch arg
1457
        cnz     errr            !illegal register
1458
        mov     a,l             !get low order argument
1459
        cpi     8
1460
        cnc     errr            !illegal register
1461
        dad     h
1462
        dad     h
1463
        dad     h
1464
        ldax    d               !fetch opcode base
1465
        add     l               !for opcode
1466
        mov     e,a             !save object byte
1467
mpnt:   lhld    pntr            !fetch pointer
1468
        mov     a,m             !fetch character
1469
        cpi     ','             !check for comma
1470
        inx     h               !increment pointer
1471
        shld    pntr
1472
        jnz     errs            !syntax error if no comma
1473
        mov     a,e
1474
        ret
1475
!
1476
! process 3 byte instructions
1477
! lxi instruction is a special case
1478
!
1479
typ6:   cpi     1               !check for lxi instruction
1480
        jnz     ty6             !jump if not lxi
1481
        call    ty56            !get register
1482
        ani     $08             !check for illegal register
1483
        cnz     errr            !register error
1484
        mov     a,e             !get opcode
1485
        ani     $f7             !clear bit in error
1486
ty6:    call    asto            !store object byte
1487
tys6:   call    asbl            !fetch operand
1488
        mov     a,l
1489
        mov     d,h
1490
        call    asto            !store 2nd byte
1491
        mov     a,d
1492
        jmp     typ1
1493
        ret
1494
!
1495
! this routine is used to store object code produced
1496
! by the assembler during pass 2 into memory
1497
!
1498
asto:   lhld    bbuf+2          !fetch storage address
1499
        mov     m,a             !store object byte
1500
        inx     h               !increment location
1501
        shld    bbuf+2
1502
        lhld    oind            !fetch output address
1503
        inx     h
1504
        call    binh+3          !convert object byte
1505
        shld    oind
1506
        ret
1507
!
1508
! get here when end pseudo-op is found or when
1509
! end-of-file occurs in source file.  control is set
1510
! for either pass 2 or assembly terminator if finished
1511
!
1512
eass:   lda     pasi            !fetch pass indicator
1513
        ora     a               !set flags
1514
        jnz     eor             !jump if finished
1515
        mvi     a,1             !pass indicator for 2nd pass
1516
        jmp     asm3            !do 2nd pass
1517
!
1518
! this routine scans through a character string until
1519
! the first non-blank character is found
1520
!
1521
! on return, carry set indicates a carriage return
1522
! as  first non-blank character.
1523
!
1524
sblk:   lhld    pntr            !fetch address
1525
sbl1:   mov     a,m             !fetch character
1526
        cpi     ' '             !check for blank
1527
        rnz                     !return if non-blank
1528
sbl2:   inx     h               !increment
1529
        shld    pntr            !save pointer
1530
        jmp     sbl1
1531
!
1532
! this routine is used to check the condition
1533
! code nmeumonics for conditional jumps, calls,
1534
! and returns.
1535
!
1536
cond:   lxi     h,abuf+1
1537
        shld    adds
1538
        mvi     b,2             !2 characters
1539
        call    copc
1540
        ret
1541
!
1542
! the following is the opcode table
1543
!
1544
otab:   defb    'org'
1545
        defb    0
1546
        defb    0
1547
        defb    'equ'
1548
        defb    0
1549
        defb    1
1550
        defb    'db'
1551
        defb    0
1552
        defb    0
1553
        defb    -1 and $0ff
1554
        defb    'ds'
1555
        defb    0
1556
        defb    0
1557
        defb    3
1558
        defb    'dw'
1559
        defb    0
1560
        defb    0
1561
        defb    5
1562
        defb    'end'
1563
        defb    0
1564
        defb    6
1565
        defb    0
1566
        defb    'hlt'
1567
        defb    118
1568
        defb    'rlc'
1569
        defb    7
1570
        defb    'rrc'
1571
        defb    15
1572
        defb    'ral'
1573
        defb    23
1574
        defb    'rar'
1575
        defb    31
1576
        defb    'ret'
1577
        defb    201
1578
        defb    'cma'
1579
        defb    47
1580
        defb    'stc'
1581
        defb    55
1582
        defb    'daa'
1583
        defb    39
1584
        defb    'cmc'
1585
        defb    63
1586
        defb    'ei'
1587
        defb    0
1588
        defb    251
1589
        defb    'di'
1590
        defb    0
1591
        defb    243
1592
        defb    'nop'
1593
        defb    0
1594
        defb    0
1595
        defb    'xchg'
1596
        defb    235
1597
        defb    'xthl'
1598
        defb    227
1599
        defb    'sphl'
1600
        defb    249
1601
        defb    'pchl'
1602
        defb    233
1603
        defb    0
1604
        defb    'stax'
1605
        defb    2
1606
        defb    'ldax'
1607
        defb    10
1608
        defb    0
1609
        defb    'push'
1610
        defb    197
1611
        defb    'pop'
1612
        defb    0
1613
        defb    193
1614
        defb    'inx'
1615
        defb    0
1616
        defb    3
1617
        defb    'dcx'
1618
        defb    0
1619
        defb    11
1620
        defb    'dad'
1621
        defb    0
1622
        defb    9
1623
        defb    0
1624
        defb    'inr'
1625
        defb    4
1626
        defb    'dcr'
1627
        defb    5
1628
        defb    'mov'
1629
        defb    64
1630
        defb    'add'
1631
        defb    128
1632
        defb    'adc'
1633
        defb    136
1634
        defb    'sub'
1635
        defb    144
1636
        defb    'sbb'
1637
        defb    152
1638
        defb    'ana'
1639
        defb    160
1640
        defb    'xra'
1641
        defb    168
1642
        defb    'ora'
1643
        defb    176
1644
        defb    'cmp'
1645
        defb    184
1646
        defb    'rst'
1647
        defb    199
1648
        defb    0
1649
        defb    'adi'
1650
        defb    198
1651
        defb    'aci'
1652
        defb    206
1653
        defb    'sui'
1654
        defb    214
1655
        defb    'sbi'
1656
        defb    222
1657
        defb    'ani'
1658
        defb    230
1659
        defb    'xri'
1660
        defb    238
1661
        defb    'ori'
1662
        defb    246
1663
        defb    'cpi'
1664
        defb    254
1665
        defb    'in'
1666
        defb    0
1667
        defb    219
1668
        defb    'out'
1669
        defb    211
1670
        defb    'mvi'
1671
        defb    6
1672
        defb    0
1673
        defb    'jmp'
1674
        defb    0
1675
        defb    195
1676
        defb    'call'
1677
        defb    205
1678
        defb    'lxi'
1679
        defb    0
1680
        defb    1
1681
        defb    'lda'
1682
        defb    0
1683
        defb    58
1684
        defb    'sta'
1685
        defb    0
1686
        defb    50
1687
        defb    'shld'
1688
        defb    34
1689
        defb    'lhld'
1690
        defb    42
1691
        defb    0
1692
!       condition       code    table
1693
        defb    'nz'
1694
        defb    0
1695
        defb    'z'
1696
        defb    0
1697
        defb    8
1698
        defb    'nc'
1699
        defb    16
1700
        defb    'c'
1701
        defb    0
1702
        defb    24
1703
        defb    'po'
1704
        defb    32
1705
        defb    'pe'
1706
        defb    40
1707
        defb    'p'
1708
        defb    0
1709
        defb    48
1710
        defb    'm'
1711
        defb    0
1712
        defb    56
1713
        defb    0
1714
!
1715
! this routine is used to check a given opcode
1716
! against the legal opcodes in the opcode table
1717
!
1718
copc:   lhld    adds
1719
        ldax    d               !fetch character
1720
        ora     a               !set flags
1721
        jz      cop1            !jump if termination character
1722
        mov     c,b
1723
        call    sear
1724
        ldax    d
1725
        rz                      !return if a match
1726
        inx     d               ! next string
1727
        jmp     copc            !continue search
1728
cop1:   inr     a               !clear zero flag
1729
        inx     d               !increment address
1730
        ret
1731
!
1732
! this routine checks the legal opcodes in both pass 1
1733
! and pass 2.  in pass 1 the program counter is incre-
1734
! mented by the correct number of bytes.  an address is
1735
! also set so that an indexed jump can be made to
1736
! process the opcode for pass 2.
1737
!
1738
opcd:   lxi     h,abuf          !get address
1739
        shld    adds
1740
        lxi     d,otab          !opcode table address
1741
        mvi     b,4             !character count
1742
        call    copc            !check opcode
1743
        jz      pseu            !jump if pseudo-op
1744
        dcr     b               !3-character opcodes
1745
        call    copc
1746
        jz      op1
1747
        inr     b               !4 character opcodes
1748
        call    copc
1749
op1:    lxi     h,typ1          !type 1 instructions
1750
op2:    mvi     c,1             !1 byte instructions
1751
        jz      ocnt
1752
!
1753
opc2:   call    copc            !check for stax, ldax
1754
        lxi     h,typ2
1755
        jz      op2
1756
        call    copc            !check for push,pop,inx
1757
                                ! dcx and dad
1758
        lxi     h,typ3
1759
        jz      op2
1760
        dcr     b               !3 char opcodes
1761
        call    copc            !accumulator instructions,
1762
                                ! inr, dcr, mov, rst
1763
        lxi     h,typ4
1764
        jz      op2
1765
!
1766
opc3:   call    copc            !immediate instructions
1767
        lxi     h,typ5
1768
        mvi     c,2             !2 byte instructions
1769
        jz      ocnt
1770
        inr     b               !4 character opcodes
1771
        call    copc            !jmp, call, lix, lda, sta,
1772
                                ! lhld, shld opcodes
1773
        jz      op4
1774
        call    cond            !conditional instructions
1775
        jnz     oerr            !illegal opcode
1776
        adi     192             !add base value to return
1777
        mov     d,a
1778
        mvi     b,3             !3 character opcodes
1779
        lda     abuf            !fetch first character
1780
        mov     c,a             !save character
1781
        cpi     'r'             !conditional return
1782
        mov     a,d
1783
        jz      op1
1784
        mov     a,c
1785
        inr     d               !form conditional jump
1786
        inr     d
1787
        cpi     'j'             !conditional jump
1788
        jz      opad
1789
        cpi     'c'             !conditional call
1790
        jnz     oerr            !illegal opcode
1791
        inr     d               !form conditional call
1792
        inr     d
1793
opad:   mov     a,d             !get opcode
1794
op4:    lxi     h,typ6
1795
op5:    mvi     c,3             !3 byte instruction
1796
ocnt:   sta     temp            !save opcode
1797
!
1798
! check for opcode only containing the correct number of
1799
! characters.  thus addq, say, would give an error
1800
!
1801
        mvi     a,abuf and $0ff !load buffer address
1802
        add     b               !add length of buffer
1803
        mov     e,a
1804
        mvi     a,abuf/256
1805
        aci     0               !get high order address
1806
        mov     d,a
1807
        ldax    d               !fetch character after opcode
1808
        ora     a               !it should be zero
1809
        jnz     oerr            !opcode error
1810
        lda     pasi            !fetch pass indicator
1811
ocn1:   mvi     b,0
1812
        xchg
1813
ocn2:   lhld    aspc            !fetch program counter
1814
        dad     b               !add in byte count
1815
        shld    aspc            !store pc
1816
        ora     a               !which pass?
1817
        rz                      !return if pass 1
1818
        lda     temp            !fetch opcode
1819
        xchg
1820
        pchl
1821
!
1822
oerr:   lxi     h,erro          !get error address
1823
        mvi     c,3             !leave 3 bytes for patch
1824
        jmp     ocn1-3
1825
!
1826
pseu:   lxi     h,abuf+4                !set buffer address
1827
        mov     a,m             !fetch character after opcode
1828
        ora     a               !should be a zero
1829
        jnz     oerr
1830
        lda     pasi            !fetch pass indicator
1831
        ora     a
1832
        jz      psu1
1833
        jmp     psu2
1834
!
1835
! this routine is used to process labels.
1836
! it checks to see if a label is in the symbol table
1837
! or not.  on return, z=1 indicates a match was found
1838
! and h,l contain the value associated with the label.
1839
! the register names a, b, c, d, e, h, l, p, and s are
1840
! pre-defined and need not be entered by the user.
1841
! on return, c=1 indicates a label error.
1842
!
1843
slab:   cpi     'a'             !check for legal character
1844
        rc
1845
        cpi     'z'+1           !check for illegal character
1846
        cmc
1847
        rc                      !return if illegal character
1848
        call    alps            !place symbol in buffer
1849
        lxi     h,abuf          !set buffer address
1850
        shld    adds            !save address
1851
        dcr     b               !check if one character
1852
        jnz     sla1
1853
! check if prefefined register name
1854
        inr     b               !set b=1
1855
        lxi     d,rtab          !register name table
1856
        call    copc            !check name of register
1857
        jnz     sla1            !not a prefefined regigter
1858
        mov     l,a             !set value (high)
1859
        mvi     h,0
1860
        jmp     sla2
1861
sla1:   lda     nola            !fetch symbol count
1862
        mov     b,a
1863
        lxi     d,symt          !set symbol table address
1864
        ora     a               !are there any labels?
1865
        jz      sla3            !jump if no labels
1866
        mvi     a,llab          !fetch length of label
1867
        sta     nchr
1868
        call    coms            !check table
1869
        mov     c,h             !swap h and l
1870
        mov     h,l
1871
        mov     l,c
1872
sla2:   stc                     !set carry
1873
        cmc                     !clear carry
1874
        ret                     !return
1875
sla3:   inr     a               !clear zero flag
1876
        ora     a               !clear carry
1877
        ret
1878
!
1879
! predefine register values in this table
1880
!
1881
rtab:   defb    'a'
1882
        defb    7
1883
        defb    'b'
1884
        defb    0
1885
        defb    'c'
1886
        defb    1
1887
        defb    'd'
1888
        defb    2
1889
        defb    'e'
1890
        defb    3
1891
        defb    'h'
1892
        defb    4
1893
        defb    'l'
1894
        defb    5
1895
        defb    'm'
1896
        defb    6
1897
        defb    'p'
1898
        defb    6
1899
        defb    's'
1900
        defb    6
1901
        defb    0               !end of table indicator.
1902
!
1903
! this routine scans the input line and places th
1904
! opcodes and labels in the buffer.  the scan terminates
1905
! when a character other than 0-9 or a-z is found.
1906
!
1907
alps:   mvi     b,0             !set count
1908
alp1:   stax    d               !store character in buffer
1909
        inr     b               !increment count
1910
        mov     a,b             !fetch count
1911
        cpi     11              !maximum buffer size
1912
        rnc                     !return if buffer filled
1913
        inx     d               !increment buffer
1914
        inx     h               !increment input pointer
1915
        shld    pntr            !save line pointer
1916
        mov     a,m             !fetch character
1917
        cpi     '0'             !check for illegal characters
1918
        rc
1919
        cpi     '9'+1
1920
        jc      alp1
1921
        cpi     'a'
1922
        rc
1923
        cpi     'z'+1
1924
        jc      alp1
1925
        ret
1926
!
1927
! this routine is used to scan through the input line
1928
! to fetch the value of the operand field.  on return,
1929
! the value of the operand is contained in reg?s h,l
1930
!
1931
asbl:   call    sblk            !get 1st argument
1932
ascn:   lxi     h,0             !get a zero
1933
        shld    oprd            !initialize operand
1934
        inr     h
1935
        shld    opri-1          !initialize operand indicator
1936
nxt1:   lhld    pntr            !fetch scan pointer
1937
        dcx     h
1938
        call    zbuf            !clear buffer
1939
        sta     sign            !zero sign indicator
1940
nxt2:   inx     h               !increment pointer
1941
        mov     a,m             !fetch next character
1942
        cpi     ' '+1
1943
        jc      send            !jump if cr or blank
1944
        cpi     ','             !field separator
1945
        jz      send
1946
! check for operator
1947
        cpi     '+'             !check for plus
1948
        jz      asc1
1949
        cpi     '-'             !check for minus
1950
        jnz     asc2
1951
        sta     sign
1952
asc1:   lda     opri            !fetch operand indicator
1953
        cpi     2               !check for 2 operators
1954
        jz      errs            !syntax error
1955
        mvi     a,2
1956
        sta     opri            !set indicator
1957
        jmp     nxt2
1958
! check for operands
1959
asc2:   mov     c,a             !save character
1960
        lda     opri            !get indicator
1961
        ora     a               !check for 2 operands
1962
        jz      errs            !syntax error
1963
        mov     a,c
1964
        cpi     '$'             !lc expression
1965
        jnz     asc3
1966
        inx     h               !increment pointer
1967
        shld    pntr            !save pointer
1968
        lhld    aspc            !fetch location counter
1969
        jmp     aval
1970
!check for ascii characters
1971
asc3:   cpi     $27             !check for single quote
1972
        jnz     asc5            !jump if not quote
1973
        lxi     d,0             !get a zero
1974
        mvi     c,3             !character count
1975
asc4:   inx     h               !bump pointer
1976
        shld    pntr            !save
1977
        mov     a,m             !fetch next character
1978
        cpi     ascr            !is it a carriage return?
1979
        jz      erar            !argument error
1980
        cpi     $27             !is it a quote?
1981
        jnz     sstr
1982
        inx     h               !increment pointer
1983
        shld    pntr            !save
1984
        mov     a,m             !fetch next char
1985
        cpi     $27             !check for 2 quotes in a row
1986
        jnz     aval+1          !terminal quote
1987
sstr:   dcr     c               !check count
1988
        jz      erar            !too many characters
1989
        mov     d,e
1990
        mov     e,a             !set character in buffer
1991
        jmp     asc4
1992
asc5:   cpi     '0'             !check for numeric
1993
        jc      erar            !illegal character
1994
        cpi     '9'+1
1995
        jnc     alab
1996
        call    nums            !get numeric value
1997
        jc      erar            !argument error
1998
aval:   xchg
1999
        lhld    oprd            !fetch operand
2000
        xra     a               !get a zero
2001
        sta     opri            !stor in operand indicator
2002
        lda     sign            !get sign indicator
2003
        ora     a               !set flags
2004
        jnz     asub
2005
        dad     d               !form result
2006
asc7:   shld    oprd            !save result
2007
        jmp     nxt1
2008
asub:   mov     a,l
2009
        sub     e
2010
        mov     l,a
2011
        mov     a,h
2012
        sbb     d
2013
        mov     h,a
2014
        jmp     asc7
2015
alab:   call    slab
2016
        jz      aval
2017
        jc      erar            !illegal symbol
2018
        jmp     erru            !undefined symbol
2019
!
2020
! get here when terminating character is found.
2021
! check for leading field separator
2022
!
2023
send:   lda     opri            !fetch operand indicator
2024
        ora     a               !set flags
2025
        jnz     errs            !syntax error
2026
        lhld    oprd
2027
sen1:   mov     a,h             !get high order byte
2028
        lxi     d,temp          !get address
2029
        ora     a               !set flags
2030
        ret
2031
!
2032
! get a numeric value which is either hexadecimal or
2033
! decimal.  on return, carry set indicates an error.
2034
!
2035
nums:   call    alps            !get numeric
2036
        dcx     d
2037
        ldax    d               !get last character
2038
        lxi     b,abuf          !set buffer address
2039
        cpi     'h'             !is it hexadecimal?
2040
        jz      num2
2041
        cpi     'd'             !is it decimal
2042
        jnz     num1
2043
        xra     a               !get a zero
2044
        stax    d               !clear d from buffer
2045
num1:   call    adec            !convert decimal value
2046
        ret
2047
num2:   xra     a               !get a zero
2048
        stax    d               !clear h from buffer
2049
        call    ahex
2050
        ret
2051
!
2052
! process register error
2053
!
2054
errr:   mvi     a,'r'           !get indicator
2055
        lxi     h,0             !get a zero
2056
        sta     obuf            !set in output buffer
2057
        ret
2058
!
2059
! process syntax error
2060
!
2061
errs:   mvi     a,'s'           !get indicator
2062
        sta     obuf            !store in output buffer
2063
        lxi     h,0
2064
        jmp     sen1
2065
!
2066
! process undefined symbol error
2067
!
2068
erru:   mvi     a,'u'           !get indicator
2069
        jmp     errs+2
2070
!
2071
! process value error
2072
!
2073
errv:   mvi     a,'v'           !get indicator
2074
        jmp     errr+2
2075
!
2076
! process missing label error
2077
!
2078
errm:   mvi     a,'m'           !get indicator
2079
        sta     obuf            !store in output buffer
2080
        call    aou1            !display error
2081
        ret
2082
!
2083
!process argument error
2084
!
2085
erar:   mvi     a,'a'           !get indicator
2086
        jmp     errs+2
2087
!
2088
! process opcode error
2089
! store 3 bytes of zero in object code to provide
2090
! for a patch
2091
!
2092
erro:   mvi     a,'o'           !get indicator
2093
        sta     obuf            !store in output buffer
2094
        lda     pasi            !fetch pass indicator
2095
        ora     a               !which pass
2096
        rz                      !return if pass 1
2097
        mvi     c,3             !need 3 bytes
2098
ero1:   xra     a               !get a zero
2099
        call    asto            !put in listing and memory
2100
        dcr     c
2101
        jnz     ero1
2102
        ret
2103
!
2104
! process label error
2105
!
2106
errl:   mvi     a,'l'           !get indicator
2107
        jmp     erro+2
2108
!
2109
! process duplicate label error
2110
!
2111
errd:   mvi     a,'d'           !get indicator
2112
        sta     obuf
2113
        call    aout
2114
        jmp     opc
2115
!
2116
! this routine sets or clears breakpoints
2117
!
2118
break:  lda     abuf            !check for an arg
2119
        ora     a
2120
        jz      clrb            !if no argument, go clear breakpoint
2121
        mvi     d, nbr          !else get number of breakpoints
2122
        lxi     h,brt           !and addr of table
2123
b1:     mov     a,m             !get hi byte of entry
2124
        inx     h
2125
        mov     b,m             !get low byte of entry
2126
        ora     b               !check for empty entry
2127
        jz      b2              !branch if empty
2128
        inx     h               !else go on to next entry
2129
        inx     h
2130
        dcr     d               !bump count
2131
        jnz     b1              !and try again
2132
        jmp     what            !oops no room
2133
b2:     dcx     h
2134
        xchg
2135
        lhld    bbuf            !get address
2136
        xchg                    !in d,e
2137
        mov     a,d             !check for addr > 11d
2138
        ora     a
2139
        jnz     b3
2140
        mov     a,e
2141
        cpi     11
2142
        jc      what            !oops, too low
2143
b3:     mov     m,d             !save address
2144
        inx     h
2145
        mov     m,e
2146
        inx     h
2147
        ldax    d               !pick up instruction
2148
        mov     m,a             !save it
2149
        mvi     a,$cf           !rst 1 instruction
2150
        stax    d
2151
        mvi     a,$c3           !set up lo memory
2152
        sta     8               !with a jump to breakpoint
2153
        lxi     h,brkp
2154
        shld    9
2155
        ret                     !then return
2156
!
2157
! this routine clears all breakpoints
2158
!
2159
clrb:   lxi     h,brt           !get table address
2160
        mvi     b,nbr           !get number of breakpoints
2161
clbl:   xra     a               !get a zero
2162
        mov     d,m             !get hi-byte of entry
2163
        mov     m,a
2164
        inx     h
2165
        mov     e,m             !get lo-byte of entry
2166
        mov     m,a
2167
        inx     h
2168
        mov     b,m             !get inst byte
2169
        inx     h
2170
        mov     a,d             !was this a null entry
2171
        ora     e
2172
        jz      cl2             !branch if it was
2173
        mov     a,b
2174
        stax    d               !else plug inst back in
2175
cl2:    dcr     b               !bump count
2176
        jnz     clbl            !go do next one
2177
        ret
2178
!
2179
! come here when we hit a breakpoint
2180
!
2181
brkp:   shld    hold+8          !save h,l
2182
        pop     h               !get pc
2183
        dcx     h               !adjust it
2184
        shld    hold+10         !save it
2185
        push    psw             !save flags
2186
        pop     h               !get them into h,l
2187
        shld    hold            !now store them for user
2188
        lxi     h,0
2189
        dad     sp              !get stack pointer
2190
        lxi     sp,hold+8       !set stack pointer again
2191
        push    h               !save old sp
2192
        push    d               !save d,e
2193
        push    b               !save b,c
2194
        cma                     !complement accumulator
2195
        out     $ff             !display it in lights
2196
        lxi     sp,area+18      !set sp again
2197
        lhld    hold+10         !get pc
2198
        xchg                    !into d,e
2199
        lxi     h,brt           !get addr of table
2200
        mvi     b,nbr           !and number of entries
2201
bl1:    mov     a,m             !get an entry from the table
2202
        inx     h
2203
        cmp     d               !does it match?
2204
        jnz     bl2             !branch if not
2205
        mov     a,m             !else get next byte
2206
        cmp     e               !check it
2207
        jz      bl3             !it matches!
2208
bl2:    inx     h               !bump around this entry
2209
        inx     h
2210
        dcr     b               !bump count
2211
        jz      what            !not in our table
2212
        jmp     bl1
2213
!
2214
bl3:    inx     h
2215
        mov     a,m             !get instr byte
2216
        stax    d               !put it back
2217
        xra     a               !clear entry in table
2218
        dcx     h
2219
        mov     m,a
2220
        dcx     h
2221
        mov     m,a
2222
        call    crlf            !restore the carriage
2223
        lda     hold+11         !get hi-byte of pc
2224
        call    hout            !type it
2225
        lda     hold+10         !get lo-byte of pc
2226
        call    hout            !type it
2227
        lxi     h,bmes          !tell user what it is
2228
        call    scrn
2229
        jmp     eor             !go back to command level
2230
!
2231
bmes:   defb    ' break',13
2232
!
2233
! this routine proceeds from a breakpoint
2234
!
2235
proc:   lda     abuf            !check for arg
2236
        ora     a
2237
        jz      p1              !jump if no arg
2238
        lhld    bbuf            !else get arg
2239
        shld    hold+10         !plug it into pc slot
2240
p1:     lxi     sp,hold         !set sp to point at reg?s
2241
        pop     psw             !restore psw
2242
        pop     b               !restore b,c
2243
        pop     d               !restore d,e
2244
        pop     h               !get old sp
2245
        sphl                    !restore it
2246
        lhld    hold+10         !get pc
2247
        push    h               !put it on stack
2248
        lhld    hold+8          !restore h,l
2249
        ret                     !and proceed
2250
!
2251
! system ram
2252
!
2253
 
2254
!
2255
! define breakpoint region
2256
!
2257
nbr:    equ     8               !number of breakpoints
2258
hold:   defvs   12              !register hold area
2259
brt:    defvs   3*nbr           !breakpoint table
2260
!
2261
! file area parameters
2262
!
2263
maxfil: equ     6
2264
nmlen:  equ     5
2265
felen:  equ     nmlen+8
2266
file0:  defvs   nmlen
2267
bofp:   defvs   2
2268
eofp:   defvs   2
2269
maxl:   defvs   4
2270
filtb:  defvs   (maxfil-1)*felen
2271
insp:   defvs   2
2272
delp:   equ     insp
2273
ascr:   equ     13
2274
hcon:   defvs   2
2275
adds:   equ     hcon
2276
fbuf:   defvs   nmlen
2277
fread:  defvs   2
2278
fef:    defvs   1
2279
focnt:  equ     fef
2280
abuf:   defvs   12
2281
bbuf:   defvs   4
2282
scnt:   defvs   1
2283
dcnt:   defvs   1
2284
ncom:   equ     11
2285
taba:   defvs   2
2286
aspc:   defvs   2
2287
pasi:   defvs   1
2288
nchr:   defvs   1
2289
pntr:   defvs   2
2290
nola:   defvs   1
2291
sign:   defvs   1
2292
oprd:   defvs   2
2293
opri:   defvs   1
2294
temp:   defvs   1
2295
apnt:   equ     insp
2296
aerr:   equ     scnt
2297
oind:   defvs    2
2298
llab:   equ     5
2299
area:   defvs    18
2300
obuf:   defvs    16
2301
        defvs    5
2302
ibuf:   defvs    83
2303
swch:   equ     $ff
2304 11 samiam9512
symt:   defvs

powered by: WebSVN 2.1.0

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