-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathASM.ASM
3681 lines (3549 loc) · 46.9 KB
/
ASM.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; Seattle Computer Products 8086 Assembler version 2.00
; by Tim Paterson
; Runs on the 8086 under 86-DOS
FCB: EQU 5CH
EOL: EQU 13 ;ASCII carriage return
OBJECT: EQU 100H ;DEFAULT "PUT" ADDRESS
;System call function codes
PRINTMES: EQU 9
OPEN: EQU 15
CLOSE: EQU 16
DELETE: EQU 19
READ: EQU 20
SETDMA: EQU 26
MAKE: EQU 22
SEQWRT: EQU 21
;The following equates define some token values returned by GETSYM
UNDEFID:EQU 0 ;Undefined identifier (including no nearby RET)
CONST: EQU 1 ;Constant (including $)
REG: EQU 2 ;8-bit register
XREG: EQU 3 ;16-bit register (except segment registers)
SREG: EQU 4 ;Segment register
ORG 100H
PUT 100H
JMP BEGIN
CPYRHT: DB 'Copyright 1979 by Seattle Computer Products, Inc.'
DB 13,10,13,10,'$'
BEGIN:
MOV SP,STACK
MOV DX,HEADER
MOV CL,PRINTMES
CALL SYSTEM
MOV DX,CPYRHT
CALL SYSTEM
MOV AL,[FCB+17]
MOV [SYMFLG],AL ;Save symbol table request flag
MOV BX,FCB+9 ;Point to file extension
MOV AL,[BX] ;Get source drive letter
CALL CHKDSK ;Valid drive?
OR AL,AL
JZ DEFAULT ;If no extension, use existing drive spec
MOV [FCB],AL
DEFAULT:
INC BX
MOV AL,[BX] ;Get HEX file drive letter
CMP AL,'Z' ;Suppress HEX file?
JZ L0000
CALL CHKDSK
L0000:
MOV [HEXFCB],AL
INC BX
MOV AL,[BX] ;Get PRN file drive letter
CMP AL,'Z' ;Suppress PRN file?
JZ NOPRN
CMP AL,'X' ;PRN file to console?
JZ NOPRN
CALL CHKDSK
NOPRN:
MOV [LSTFCB],AL
CALL ADDEXT
MOV DX,FCB
MOV CL,OPEN
CALL SYSTEM
MOV BX,NOFILE
INC AL
JNZ $+5
JMP PRERR
XOR AL,AL
MOV [FCB+32],AL ;Zero Next Record field
MOV DX,HEXFCB
CALL MAKFIL
MOV DX,LSTFCB
CALL MAKFIL
MOV BX,0FFH
XCHG BX,[HL]
XCHG DX,[DE]
XCHG CX,[BC]
MOV BX,START+1 ;POINTER TO NEXT BYTE OF INTERMEDIATE CODE
MOV [CODE],BX
MOV [IY],START ;POINTER TO CURRENT RELOCATION BYTE
MOV BX,0
MOV [PC],BX ;DEFAULT PROGRAM COUNTER
MOV [BASE],BX ;POINTER TO ROOT OF ID TREE=NIL
MOV [RETPT],BX ;Pointer to last RET record
DEC BX
MOV [LSTRET],BX ;Location of last RET
MOV BX,[6] ;HL=END OF MEMORY
MOV [HEAP],BX ;BACK END OF SYMBOL TABLE SPACE
MOV AL,4
MOV [BCOUNT],AL ;CODE BYTES PER RELOCATION BYTE
XOR AL,AL
MOV [IFFLG],AL ;NOT WITHIN IF/ENDIF
MOV [CHKLAB],AL ;LOOKUP ALL LABELS
;Assemble each line of code
LOOP:
CALL NEXTCHR ;Get first character on line
CMP AL,1AH
JZ ENDJ
MOV AL,-1 ;Flag that no tokens have been read yet
MOV [SYM],AL
CALL ASMLIN ;Assemble the line
MOV AL,[SYM]
CMP AL,-1 ;Any tokens found on line?
JNZ L0002
CALL GETSYM ;If no tokens read yet, read first one
L0002:
CMP AL,';'
JZ ENDLN
CMP AL,EOL
JZ ENDLN
MOV AL,14H ;Garbage at end of line error
JP ENDLIN
ENDJ: JMP END
ENDLN:
XOR AL,AL ;Flag no errors on line
ENDLIN:
;AL = error code for line. Stack depth unknown
MOV SP,STACK
CALL NEXLIN
JP LOOP
NEXLIN:
MOV CH,0C0H ;Put end of line marker and error code (AL)
CALL PUTCD
CALL GEN1
MOV AL,[CHR]
GETEOL:
CMP AL,10
JZ RET
CMP AL,1AH
JZ ENDJ
CALL NEXTCHR ;Scan over comments for linefeed
JP GETEOL
ABORT:
MOV BX,NOMEM
PRERR:
XCHG DX,BX
MOV CL,PRINTMES
CALL SYSTEM
JMP 0
MAKFIL:
MOV SI,DX
LODB ;Get drive select byte
CMP AL,20H ;If not valid, don't make file
JNC RET
PUSH DX
INC DX
MOV BX,FCB+1
MOV CX,8
UP
MOV SI,BX
MOV DI,DX
REP
MOVB ;Copy source file name
MOV DX,DI
MOV BX,SI
POP DX
MOV CL,DELETE
CALL SYSTEM
MOV CL,MAKE
CALL SYSTEM
MOV BX,NOSPAC
INC AL ;Success?
JZ PRERR
MOV CL,OPEN
JMP SYSTEM
ADDEXT:
MOV DX,FCB+9
MOV BX,EXTEND ;Set extension to ASM
MOV CX,7
UP
MOV SI,BX
MOV DI,DX
REP
MOVB
MOV DX,DI
MOV BX,SI
RET
CHKDSK:
SUB AL,' ' ;If not present, set zero flag
JZ RET
SUB AL,20H
JZ DSKERR ;Must be in range A-W
CMP AL,'X'-'@'
JC RET
DSKERR:
MOV BX,BADDSK
JP PRERR
ERROR:
MOV AL,CL
JMP ENDLIN
NEXTCHR:
XCHG BX,[HL]
XCHG DX,[DE]
XCHG CX,[BC]
INC BL
JNZ GETCH
;Buffer empty so refill it
MOV DX,80H
MOV CL,SETDMA
CALL SYSTEM
XCHG DX,BX
MOV DX,FCB
MOV CL,READ
CALL SYSTEM
OR AL,AL
MOV AL,1AH ;Possibly signal End of File
JNZ NOMOD ;If nothing read
GETCH:
MOV AL,[BX]
NOMOD:
XCHG BX,[HL]
XCHG DX,[DE]
XCHG CX,[BC]
MOV [CHR],AL
RET
MROPS:
; Get two operands and check for certain types, according to flag byte
; in CL. OP code in CH. Returns only if immediate operation.
PUSH CX ;Save type flags
CALL GETOP
PUSH DX ;Save first operand
CALL GETOP2
POP BX ;First op in BX, second op in DX
MOV AL,SREG ;Check for a segment register
CMP AL,BH
JZ SEGCHK
CMP AL,DH
JZ SEGCHK
MOV AL,CONST ;Check if the first operand is immediate
MOV CL,26
CMP AL,BH
JZ ERROR ;Error if so
POP CX ;Restore type flags
CMP AL,DH ;If second operand is immediate, then done
JZ RET
MOV AL,UNDEFID ;Check for memory reference
CMP AL,BH
JZ STORE ;Is destination memory?
CMP AL,DH
JZ LOAD ;Is source memory?
RCR SI
TEST CL,1 ;Check if register-to-register operation OK
RCL SI
MOV CL,27
JZ ERROR
MOV AL,DH
CMP AL,BH ;Registers must be of same length
RR:
MOV CL,22
JNZ ERROR
RR1:
AND AL,1 ;Get register length (1=16 bits)
OR AL,CH ;Or in to OP code
CALL PUT ;And write it
POP CX ;Dump return address
MOV AL,BL
ADD AL,AL ;Rotate register number into middle position
ADD AL,AL
ADD AL,AL
OR AL,0C0H ;Set register-to-register mode
OR AL,DL ;Combine with other register number
JMP PUT
SEGCHK:
;Come here if at least one operand is a segment register
POP CX ;Restore flags
RCR SI
TEST CL,8 ;Check if segment register OK
RCL SI
MOV CL,22
JZ ERR1
MOV CX,8E03H ;Segment register move OP code
MOV AL,UNDEFID
CMP AL,DH ;Check if source is memory
JZ LOAD
CMP AL,BH ;Check if destination is memory
JZ STORE
MOV AL,XREG
SUB AL,DH ;Check if source is 16-bit register
JZ RR ;If so, AL must be zero
AND CH,0FDH ;Change direction
XCHG DX,BX ;Flip which operand is first and second
MOV AL,XREG
SUB AL,DH ;Let RR perform finish the test
JP RR
STORE:
TEST CL,004H ;Check if storing is OK
JNZ STERR
XCHG DX,BX ;If so, flip operands
AND CH,0FDH ; and zero direction bit
LOAD:
MOV DH,25
CMP AL,BH ;Check if memory-to-memory
JZ MRERR
MOV AL,BH
CMP AL,REG ;Check if 8-bit operation
JNZ XRG
MOV DH,22
TEST CL,1 ;See if 8-bit operation is OK
JZ MRERR
XRG:
MOV AL,DL
SUB AL,6 ;Check for R/M mode 6 and register 0
OR AL,BL ; meaning direct load/store of accumulator
JNZ NOTAC
TEST CL,8 ;See if direct load/store of accumulator
JZ NOTAC ; means anything in this case
; Process direct load/store of accumulator
MOV AL,CH
AND AL,2 ;Preserve direction bit only
XOR AL,2 ; but flip it
OR AL,0A0H ;Combine with OP code
MOV CH,AL
MOV AL,BH ;Check byte/word operation
AND AL,1
OR AL,CH
POP CX ;Dump return address
JMP PUTADD ;Write the address
NOTAC:
MOV AL,BH
AND AL,1 ;Get byte/word bit
AND AL,CL ;But don't use it in word-only operations
OR AL,CH ;Combine with OP code
CALL PUT
MOV AL,BL
ADD AL,AL ;Rotate to middle position
ADD AL,AL
ADD AL,AL
OR AL,DL ;Combine register field
POP CX ;Dump return address
JMP PUTADD ;Write the address
STERR:
MOV DH,29
MRERR:
MOV CL,DH
ERR1: JMP ERROR
GETOP2:
;Get the second operand: look for a comma and drop into GETOP
MOV AL,[SYM]
CMP AL,','
MOV CL,21
JNZ ERR1
GETOP:
; Get one operand. Operand may be a memory reference in brackets, a register,
; or a constant. If a flag (such as "B" for byte operation) is encountered,
; it is noted and processing continues to find the operand.
;
; On exit, AL (=DH) has the type of operand. Other information depends
; on the actual operand:
;
; AL=DH=0 Memory Reference. DL has the address mode properly prepared in
; the 8086 R/M format (middle bits zero). The constant part of the address
; is in ADDR. If an undefined label needs to be added to this, a pointer to
; its information fields is in ALABEL, otherwise ALABEL is zero.
;
; AL=DH=1 Value. The constant part is in DATA. If an undefined label needs
; to be added to this, a pointer to its information fields is in DLABEL,
; otherwise DLABEL is zero. "$" and "RET" are in this class.
;
; AL=DH=2 8-bit Register. DL has the register number.
;
; AL=DH=3 16-bit Register. DL has the register number.
;
; AL=DH=4 Segment Register. DL has the register number.
CALL GETSYM
GETOP1:
;Enter here if we don't need a GETSYM first
CMP AL,'[' ;Memory reference?
JZ MEM
CMP AL,5 ;Flag ("B", "W", etc.)?
JZ FLG
CMP AL,REG ;8-Bit register?
JZ NREG
CMP AL,XREG ;16-Bit register?
JZ NREG
CMP AL,SREG ;Segment register?
JZ NREG
VAL: ;Must be immediate
XOR AL,AL ;No addressing modes allowed
VAL1:
CALL GETVAL
MOV BX,[CON] ;Defined part
MOV [DATA],BX
MOV BX,[UNDEF] ;Undefined part
MOV [DLABEL],BX
MOV DL,CH
MOV DH,CONST
MOV AL,DH
RET
NREG:
PUSH DX
CALL GETSYM
POP DX
MOV AL,DH
RET
MEM:
CALL GETSYM
MOV AL,1
CALL GETVAL
MOV AL,[SYM]
CMP AL,']'
MOV CL,24
JNZ ERR1
CALL GETSYM
MOV BX,[CON]
MOV [ADDR],BX
MOV BX,[UNDEF]
MOV [ALABEL],BX
MOV DL,CH
MOV DH,UNDEFID
MOV AL,DH
RET
FLG:
CALL GETSYM
CMP AL,','
JZ GETOP
JP GETOP1
GETVAL:
; Expression analyzer. On entry, if AL=0 then do not allow base or index
; registers. If AL=1, we are analyzing a memory reference, so allow base
; and index registers, and compute addressing mode when done. The constant
; part of the expression will be found in CON. If an undefined label is to
; be added to this, a pointer to its information fields will be found in
; UNDEF.
LAHF
XCHG AX,BP
SAHF
PUSH BX
MOV BX,0
MOV [CON],BX
MOV [UNDEF],BX
POP BX
MOV AL,[SYM]
CMP AL,'+'
JZ PLSMNS
CMP AL,'-'
JZ PLSMNS
MOV CH,'+'
PUSH CX
JP L045C
PLSMNS:
LAHF
XCHG AH,AL
PUSH AX
XCHG AH,AL
LAHF
XCHG AX,BP
SAHF
LAHF
OR AL,4 ;Flag that a sign was found
SAHF
LAHF
XCHG AX,BP
SAHF
CALL GETSYM
L045C:
CMP AL,1
JNZ L0463
JMP L0578
L0463:
CMP AL,0
JNZ L046A
JMP L0597
L046A:
CMP AL,'"'
JNZ L0471
L046E:
JMP L0648
L0471:
CMP AL,"'"
JZ L046E
CMP AL,3
MOV CL,14H
JNZ ERR2
LAHF
XCHG AX,BP
SAHF
RCR SI
TEST AL,1
RCL SI
MOV CL,1
JZ ERR2
LAHF
XCHG AX,BP
SAHF
MOV AL,DL
MOV CL,3
CMP AL,3
JZ L04C6
SUB AL,5
JZ L04D7
DEC AL
MOV CL,4
JZ L04B5
DEC AL
JZ L04A6
MOV CL,2
ERR2: JMP ERROR
L04A6:
LAHF
XCHG AX,BP
SAHF
RCR SI
TEST AL,10H
RCL SI
JNZ ERR2
OR AL,30H
JP L04E4
L04B5:
LAHF
XCHG AX,BP
SAHF
RCR SI
TEST AL,10H
RCL SI
JNZ ERR2
LAHF
OR AL,10H
SAHF
JP L04E4
L04C6:
LAHF
XCHG AX,BP
SAHF
RCR SI
TEST AL,80H
RCL SI
JNZ ERR2
LAHF
OR AL,80H
SAHF
JP L04E4
L04D7:
LAHF
XCHG AX,BP
SAHF
RCR SI
TEST AL,80H
RCL SI
JNZ ERR2
OR AL,0C0H
L04E4:
LAHF
XCHG AX,BP
SAHF
POP AX
XCHG AH,AL
SAHF
CMP AL,'-'
MOV CL,5
JZ ERR2
L04F1:
LAHF
XCHG AX,BP
SAHF
LAHF
OR AL,4
SAHF
LAHF
XCHG AX,BP
SAHF
CALL GETSYM
CMP AL,'+'
JNZ L0505
L0502:
JMP PLSMNS
L0505:
CMP AL,'-'
JZ L0502
LAHF
XCHG AX,BP
SAHF
MOV CH,0
RCR SI
TEST AL,10H
RCL SI
RCL AL
JZ NOIND
CMC
RCL CH
RCL AL
RCL CH
RCL AL
RCL CH
L0523:
MOV BX,[UNDEF]
MOV AL,BH
OR AL,BL
LAHF
OR CH,80H
SAHF
JNZ RET3
MOV BX,[CON]
CALL L055B
JNZ RET3
LAHF
AND CH,7FH
SAHF
LAHF
OR CH,40H
SAHF
MOV AL,BH
OR AL,BL
JNZ RET3
MOV AL,CH
AND AL,7
MOV CH,AL
CMP AL,6
JNZ RET3
LAHF
OR CH,40H
SAHF
RET3: RET
L055B:
MOV AL,BH
OR AL,AL
JZ L0565
INC AL
JNZ RET
L0565:
MOV AL,BL
XOR AL,BH
AND AL,80H
RET
NOIND:
MOV CH,6
JNC RET
RCL AL
JC L0523
INC CH
JP L0523
L0578:
MOV BX,[CON]
POP AX
XCHG AH,AL
SAHF
CMP AL,'-'
JNZ L058D
SBB BX,DX
L0586:
MOV [CON],BX
JMP L04F1
L058D:
LAHF
ADD BX,DX
RCR SI
SAHF
RCL SI
JP L0586
L0597:
LAHF
XCHG AX,BP
SAHF
MOV CL,6
RCR SI
TEST AL,8
RCL SI
JNZ L05B5
LAHF
OR AL,8
XCHG AX,BP
SAHF
MOV [UNDEF],BX
POP AX
XCHG AH,AL
SAHF
CMP AL,'+'
MOV CL,5
L05B5:
JNZ ERR3
JMP L04F1
GETSYM:
; The lexical scanner. Used only in the operand field. Returns with the token
; in SYM and AL, sometimes with additional info in BX or DX.
;
; AL=SYM=0 Undefined label. BX has pointer to information fields.
;
; AL=SYM=1 Constant (or defined label). DX has value.
;
; AL=SYM=2,3,4 8-bit register, 16-bit register, or segment register,
; respectively. DL has register number.
;
; AL=SYM=5 A mode flag (such as "B" for byte operation). Type of flag in DL
; and also stored in FLAG: -1=no flags, 0=B, 1=W, 2=S, 3=L, 4=T.
;
; AL=SYM=6 8087 floating point register, ST(n) or ST. DL has register number.
;
; All other values are the ASCII code of the character. Note that this may
; never be a letter or number.
CALL GETSY
MOV AL,[SYM]
RET
SCANB:
MOV AL,[CHR]
SCANT:
CMP AL,' '
JZ NEXB
CMP AL,9
JNZ RET
NEXB:
CALL NEXTCHR
JP SCANT
DOLLAR:
MOV DX,[OLDPC]
MOV AL,CONST
MOV [SYM],AL
NEXTCHJ:
JMP NEXTCHR
GETSY:
CALL SCANB
CMP AL,'$'
JZ DOLLAR
MOV [SYM],AL
OR AL,20H
CMP AL,'z'+1
JNC NEXTCHJ
CMP AL,'a'
JC $+5
JMP LETTER
CMP AL,'9'+1
JNC NEXTCHJ
CMP AL,'0'
JC NEXTCHJ
MOV BX,SYM
MOV B,[BX],CONST
CALL READID
LAHF
DEC BX
SAHF
MOV AL,[BX]
MOV CL,7
MOV BX,0
CMP AL,'h'
JNZ $+5
JMP HEX
INC CL
MOV [IX],ID
DEC:
MOV SI,[IX]
MOV AL,[SI]
INC [IX]
CMP AL,'9'+1
JC $+5
ERR3: JMP ERROR
SUB AL,'0'
MOV DX,BX
SHL BX
SHL BX
ADD BX,DX
SHL BX
MOV DL,AL
MOV DH,0
ADD BX,DX
DEC CH
JNZ DEC
XCHG DX,BX
RET
L0648:
MOV CH,AL
MOV AL,[CHR]
CMP AL,CH
MOV CL,'#'
MOV DL,AL
MOV DH,0
JNZ L065A
CALL L0690
L065A:
CALL L0698
LAHF
XCHG AX,BP
SAHF
MOV CL,'%'
TEST AL,2
JZ ERR3
TEST AL,4
MOV CL,'&'
JNZ ERR3
LAHF
XCHG AX,BP
SAHF
L066F:
MOV AL,DL
CMP AL,13
MOV CL,"'"
JZ ERR3
CALL PUT
MOV AL,[DATSIZ]
OR AL,AL
JNZ L0686
MOV AL,DH
CALL PUT
L0686:
MOV AL,[CHR]
MOV DL,AL
CALL L0698
JP L066F
L0690:
CALL NEXTCHR
CMP AL,CH
JNZ ERR3
RET
L0698:
CALL NEXTCHR
CMP AL,CH
JNZ RET
CALL NEXTCHR
CMP AL,CH
JZ RET
POP BX
JMP L0578
HEX:
MOV DX,ID
DEC CH
HEX1:
MOV SI,DX
LODB
INC DX
SUB AL,'0'
CMP AL,10
JC GOTIT
CMP AL,'g'-'0'
JNC ERR4
SUB AL,'a'-10-'0'
GOTIT:
SHL BX
SHL BX
SHL BX
SHL BX
ADD BL,AL
DEC CH
JNZ HEX1
XCHG DX,BX
RET
ERR4: JMP ERROR
GETLET:
CALL SCANB
CMP AL,EOL
STC
JZ RET
CMP AL,';'
STC
JZ RET
MOV CL,10
OR AL,20H
CMP AL,'a'
JC ERR4
CMP AL,'z'+1
JNC ERR4
READID:
MOV BX,ID
MOV CH,0
MOREID:
MOV [BX],AL
INC CH
LAHF
INC BX
SAHF
CALL NEXTCHR
CMP AL,'0'
JC NOMORE
OR AL,20H
CMP AL,'z'+1
JNC NOMORE
CMP AL,'9'+1
JC MOREID
CMP AL,'a'
JNC MOREID
NOMORE:
MOV CL,AL
MOV AL,CH
MOV [LENID],AL
OR AL,AL
MOV AL,CL
RET
LETTER:
CALL READID
MOV AL,CH
DEC AL
JNZ NOFLG
MOV AL,[ID]
CMP AL,'l'
MOV CL,0
MOV DX,L1A98
JZ SAVFLG
CMP AL,'b'
MOV DX,FLAG
JZ SAVFLG
CMP AL,'w'
MOV CL,1
JZ SAVFLG
XOR AL,AL
NOFLG:
DEC AL
PUSH BX
JNZ L0004
CALL REGCHK
L0004:
POP BX
MOV AL,DH
JZ SYMSAV
CALL LOOKRET
SYMSAV:
MOV [SYM],AL
RET
SAVFLG:
XCHG DX,BX
MOV AL,[BX]
INC AL
MOV [BX],CL
MOV CL,32
JZ L0760
JMP ERROR
L0760:
MOV AL,5
JP SYMSAV
REGCHK:
MOV BX,ID
MOV CL,[BX]
LAHF
INC BX
SAHF
MOV AL,[BX]
MOV BX,REGTAB
MOV DH,XREG
MOV DL,0
CMP AL,'x'
JZ SCANREG
MOV DH,REG
CMP AL,'l'
JZ SCANREG
MOV DL,4
CMP AL,'h'
JZ SCANREG
MOV DH,SREG
MOV DL,0
MOV BX,SEGTAB
CMP AL,'s'
JZ SCANREG
MOV DH,XREG
CMP AL,'p'
JZ PREG
CMP AL,'i'
JNZ RET
MOV DL,6
MOV AL,CL
CMP AL,'s'
JZ RET