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

Subversion Repositories cpu8080

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

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

powered by: WebSVN 2.1.0

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