This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 482
/
IBMRES.ASM
989 lines (927 loc) · 15.9 KB
/
IBMRES.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
; [ This translation created 10-Feb-83 by Version 4.3 ]
.RADIX 8 ; To be safe
CSEG SEGMENT PUBLIC 'CODESG'
ASSUME CS:CSEG
INCLUDE IBMRES.H
SUBTTL Equates and External Declarations
TITLE IBMRES - IBM compatible reserved words / MLC
COMMENT *
--------- --- ---- -- ---------
COPYRIGHT (C) 1982 BY MICROSOFT
--------- --- ---- -- ---------
This module is used to create GW-BASICs with IBM PC compatible
reserved word tokens. The reserved word tables were created by
cleaning up a copy of the tables from BINTRP. The code and tables
to handle the extended reserved words was taken from L2RESS.MAC and
modified as necessary.
*
GWLEV2=0 ;GW BASIC version 2.0 features
.SALL
.RADIX 10
PUBLIC $KEY2B,$COM2B,$PEN2B,$STR2B
EXTRN CHRGTR:NEAR
EXTRN DATEF:NEAR
EXTRN LABBCK:NEAR
EXTRN MAKUPL:NEAR
EXTRN NOTRFN:NEAR
EXTRN PARCHK:NEAR,PENS:NEAR,PLOOP2:NEAR,PPSWRT:NEAR
EXTRN RENCRN:NEAR
EXTRN STRIGS:NEAR
EXTRN TIMEF:NEAR,TSTANM:NEAR
DSEG SEGMENT PUBLIC 'DATASG'
ASSUME DS:DSEG
EXTRN FLGOVC:WORD,TEMPA:WORD
DSEG ENDS
;
; THESE MACRO CALLS DEFINE THE RESWRD VALUES
; AND THE TABLE DISPATCH FOR STATEMENTS AND FUNCTIONS
;
; STATEMENTS:
;
PUBLIC STMDSP
STMDSP: ;MARKS START OF STATEMENT LIST
QQ=128
R2 END,ENDST
R FOR
R NEXT
R2 DATA,DATAS
R INPUT
R DIM
R READ
R LET
R GOTO
R RUN
R2 IF,IFS
R RESTORE
R GOSUB
R RETURN
R REM
R STOP
R PRINT
R CLEAR
R LIST
R2 NEW,SCRATH
R2 ON,ONGOTO
R2 WAIT,FNWAIT
R DEF
R POKE
R CONT
R2 DUMMY,SNERR ;padding
R2 DUMMY,SNERR ;padding
R2 OUT,FNOUT
R LPRINT
R LLIST
R2 DUMMY,SNERR ;padding
R2 WIDTH,WIDTHS
R2 ELSE,ELSES
R2 TRON,TON
R2 TROFF,TOFF
R SWAP
R ERASE
R EDIT
R2 ERROR,ERRORS
R RESUME
R DELETE
R AUTO
R2 RENUM,RESEQ
R DEFSTR
R DEFINT
R2 DEFSNG,DEFREA
R DEFDBL
R LINE
R WHILE
R WEND
R2 CALL,CALLS
R2 DUMMY,SNERR ;padding
R2 DUMMY,SNERR ;padding
R2 DUMMY,SNERR ;padding
R WRITE
R OPTION
R2 RANDOMIZE,RANDOM
R OPEN
R CLOSE
R LOAD
R MERGE
R SAVE
R COLOR
R CLS
R MOTOR
R BSAVE
R BLOAD
R2 SOUND,SOUNDS
R2 BEEP,BEEPS
R PSET
R PRESET
R SCREEN
R2 KEY,KEYS
$KEY2B=0+QQ ;value of KEY 2-byte token
R LOCATE
PUBLIC NUMCMD
NUMCMD=QQ-$END+1
;
; TOKENS
;
;
;QQ MUST BE SET SO TOKENS START AT RIGHT PLACE
;
QQ=QQ+1
T TO
T THEN
PUBLIC THENTK
THENTK=QQ
T TAB
PUBLIC TABTK
TABTK=QQ
T STEP
PUBLIC STEPTK
STEPTK=QQ
T USR
PUBLIC USRTK
USRTK=QQ
T FN
PUBLIC FNTK
FNTK=QQ
T SPC
PUBLIC SPCTK
SPCTK=QQ
T NOT
PUBLIC NOTTK
NOTTK=QQ
T ERL
PUBLIC ERLTK
ERLTK=QQ
T ERR
PUBLIC ERCTK
ERCTK=QQ
T STRING$
T USING
PUBLIC USINTK
USINTK=QQ
T INSTR
PUBLIC INSRTK
INSRTK=QQ
T DUMMY
PUBLIC SNGQTK
SNGQTK=QQ
T VARPTR
T CSRLIN
PUBLIC CLINTK
CLINTK=QQ
T POINT
T OFF
T INKEY$
;
; OPERATORS
;
QQ=QQ+7
T DUMMY
PUBLIC GREATK
GREATK=QQ
T DUMMY
PUBLIC EQULTK
EQULTK=QQ
T DUMMY
PUBLIC LESSTK
LESSTK=QQ
T DUMMY
PUBLIC PLUSTK
PLUSTK=QQ
T DUMMY
PUBLIC MINUTK
MINUTK=QQ
T DUMMY
PUBLIC MULTK
MULTK=QQ
T DUMMY
PUBLIC DIVTK
DIVTK=QQ
T DUMMY
PUBLIC EXPTK
EXPTK=QQ
T AND
T OR
T XOR
T EQV
T IMP
T MOD
T DUMMY
PUBLIC IDIVTK
IDIVTK=QQ
PUBLIC LSTOPK
LSTOPK=QQ+1-PLUSTK
;
; FUNCTIONS - 2 byte tokens, the 1st byte is FF
;
QQ=128
PUBLIC FUNDSP
FUNDSP:
R LEFT$
PUBLIC ONEFUN
ONEFUN=QQ
R RIGHT$
R MID$
PUBLIC MIDTK
MIDTK=QQ
R SGN
R2 INT,VINT
R2 ABS,ABSFN
R SQR
PUBLIC SQRTK
SQRTK=QQ
R RND
R SIN
R LOG
R EXP
R COS
R TAN
R ATN
PUBLIC ATNTK
ATNTK=QQ
R FRE
R2 INP,FNINP
R POS
R LEN
R STR$
R VAL
R ASC
R CHR$
R PEEK
R SPACE$
R2 OCT$,STRO$
R2 HEX$,STRH$
R LPOS
PUBLIC LASNUM
LASNUM=QQ
R2 CINT,FRCINT
R2 CSNG,FRCSNG
R2 CDBL,FRCDBL
R2 DUMMY,FIXER
PUBLIC $FIX
$FIX=QQ
R2 PEN,PENF
$PEN2B=0+(400O*377O)+QQ ;value of PEN 2-byte token
R2 STICK,STICKF
R2 STRIG,STRIGF
$STR2B=0+(400O*377O)+QQ ;value of STRIG 2-byte token
R EOF
R LOC
R LOF
;
; THE FOLLOWING TABLES ARE THE ALPHABETIC DISPATCH TABLE
; FOLLOWED BY THE RESERVED WORD TABLE ITSELF
;
PUBLIC ALPTAB
ALPTAB:
DW OFFSET ATAB
DW OFFSET BTAB
DW OFFSET CTAB
DW OFFSET DTAB
DW OFFSET ETAB
DW OFFSET FTAB
DW OFFSET GTAB
DW OFFSET HTAB
DW OFFSET ITAB
DW OFFSET JTAB
DW OFFSET KTAB
DW OFFSET LTAB
DW OFFSET MTAB
DW OFFSET NTAB
DW OFFSET OTAB
DW OFFSET PTAB
DW OFFSET QTAB
DW OFFSET RTAB
DW OFFSET STAB
DW OFFSET TTAB
DW OFFSET UTAB
DW OFFSET VTAB
DW OFFSET WTAB
DW OFFSET XTAB
DW OFFSET YTAB
DW OFFSET ZTAB
PUBLIC RESLST
RESLST:
ATAB:
Q AUTO
Q AND
QF ABS
QF ATN
QF ASC
DB 0
BTAB:
Q BSAVE
Q BLOAD
Q BEEP
DB 0
CTAB:
Q COLOR
Q CLOSE
Q CONT
Q CLEAR
Q CSRLIN
QF CINT
QF CSNG
QF CDBL
QF COS
QF CHR$
Q CALL
Q CLS
DB 0
DTAB:
Q DELETE
Q DATA
Q DIM
Q DEFSTR
Q DEFINT
Q DEFSNG
Q DEFDBL
Q DEF
DB 0
ETAB:
Q ELSE
Q END
Q ERASE
Q EDIT
Q ERROR
Q ERL
Q ERR
QF EXP
QF EOF
Q EQV
DB 0
FTAB:
Q FOR
Q FN
QF FRE
QF FIX
DB 0
GTAB:
Q GOTO
DB "O"
DB " "
DB "T"
DB "O"+128D
DB OFFSET $GOTO
Q GOSUB
DB 0
HTAB:
QF HEX$
DB 0
ITAB:
Q INPUT
Q IF
Q INSTR
QF INT
QF INP
Q IMP
Q INKEY$
DB 0
JTAB:
DB 0
KTAB:
Q KEY
DB 0
LTAB:
Q LOCATE
Q LPRINT
Q LLIST
QF LPOS
Q LET
Q LINE
Q LOAD
Q LIST
QF LOG
QF LOC
QF LEN
QF LEFT$
QF LOF
DB 0
MTAB:
Q MOTOR
Q MERGE
Q MOD
QF MID$
DB 0
NTAB:
Q NEXT
Q NEW
Q NOT
DB 0
OTAB:
Q OPEN
Q OUT
Q ON
Q OR
QF OCT$
Q OPTION
Q OFF
DB 0
PTAB:
Q PRINT
Q POKE
QF POS
QF PEEK
Q PSET
Q PRESET
Q POINT
QF PEN
DB 0
QTAB:
DB 0
RTAB:
Q RUN
Q RETURN
Q READ
Q RESTORE
Q REM
Q RESUME
QF RIGHT$
QF RND
Q RENUM
Q RANDOMIZE
DB 0
STAB:
Q SCREEN
Q STOP
Q SWAP
Q SAVE
DB "P"
DB "C"
DB "("+128D
DB OFFSET SPCTK
Q STEP
QF SGN
QF SQR
QF SIN
QF STR$
Q STRING$
QF SPACE$
Q SOUND
QF STICK
QF STRIG
DB 0
TTAB:
Q THEN
Q TRON
Q TROFF
DB "A"
DB "B"
DB "("+128D
DB OFFSET TABTK
Q TO
QF TAN
DB 0
UTAB:
Q USING
Q USR
DB 0
VTAB:
QF VAL
Q VARPTR
DB 0
WTAB:
Q WIDTH
Q WAIT
Q WHILE
Q WEND
Q WRITE
DB 0
XTAB:
Q XOR
DB 0
YTAB:
DB 0
ZTAB:
DB 0
PUBLIC SPCTAB
SPCTAB:
DB "+"+128D
DB OFFSET PLUSTK
DB "-"+128D
DB OFFSET MINUTK
DB "*"+128D
DB OFFSET MULTK
DB "/"+128D
DB OFFSET DIVTK
DB "^"+128D
DB OFFSET EXPTK
DB "\"+128D
DB OFFSET IDIVTK
DB "'"+128D
DB OFFSET SNGQTK
DB 62+128D
DB OFFSET GREATK
DB "="+128D
DB OFFSET EQULTK
DB 60+128D
DB OFFSET LESSTK
DB 0
SUBTTL Extended reserved words
;The following are 2 byte tokens, the 1st byte is FE
QQ=128D
STMDSX:
R FILES
R FIELD
R SYSTEM
R NAME
R LSET
R RSET
R KILL
R PUT
R GET
R RESET
R COMMON
R CHAIN
R2 DATE$,DATES
R2 TIME$,TIMES
R PAINT
R2 COM,COMS
$COM2B=0+(400O*376O)+QQ ;value of COM 2-byte token
R CIRCLE
R DRAW
R2 PLAY,PLAYS
R TIMER
R ERDEV
R IOCTL
R CHDIR
R MKDIR
R RMDIR
R SHELL
R ENVIRON
R VIEW
R WINDOW
R PMAP
R2 PALETTE,PALETE
R2 LCOPY,LCOPYS
R2 CALLS,CALLSL
;*************************************************************************
;*** The DEBUG entry should be the last entry in the FE Dispatch table ***
;*************************************************************************
PAGE
;The following are 2 byte tokens, the 1st byte is FD
QQ=128D
FUNDSX:
R CVI
R CVS
R CVD
R MKI$
R MKS$
R MKD$
R2 KTN,KTNFN
R2 JIS,JISFN
R2 KPOS,KPOSFN
R2 KLEN,KLENFN
PAGE
PUBLIC ALPTAX
ALPTAX:
ADR ATABX
ADR BTABX
ADR CTABX
ADR DTABX
ADR ETABX
ADR FTABX
ADR GTABX
ADR HTABX
ADR ITABX
ADR JTABX
ADR KTABX
ADR LTABX
ADR MTABX
ADR NTABX
ADR OTABX
ADR PTABX
ADR QTABX
ADR RTABX
ADR STABX
ADR TTABX
ADR UTABX
ADR VTABX
ADR WTABX
ADR XTABX
ADR YTABX
ADR ZTABX
PAGE
RESLSX:
ATABX:
DB 0
BTABX:
DB 0
CTABX:
Q CHAIN
QF CVI
QF CVS
QF CVD
Q COMMON
Q COM
Q CIRCLE
Q CALLS
DB 0
DTABX:
Q DATE$
Q DRAW
DB 0
ETABX:
DB 0
FTABX:
Q FIELD
Q FILES
DB 0
GTABX:
Q GET
DB 0
HTABX:
DB 0
ITABX:
Q IOCTL
DB 0
JTABX:
DB 0
KTABX:
Q KILL
DB 0
LTABX:
Q LSET
Q LCOPY
DB 0
MTABX:
QF MKI$
QF MKS$
QF MKD$
DB 0
NTABX:
Q NAME
DB 0
OTABX:
DB 0
PTABX:
Q PUT
Q PAINT
Q PLAY
DB 0
QTABX:
DB 0
RTABX:
Q RSET
Q RESET
DB 0
STABX:
Q SYSTEM
DB 0
TTABX:
Q TIME$
DB 0
UTABX:
DB 0
VTABX:
DB 0
WTABX:
DB 0
XTABX:
DB 0
YTABX:
DB 0
ZTABX:
DB 0
PUBLIC NUMGFN,BOTCON,TOPCON,$RNDFN,$DATCO,$REMCO,NMREL
PUBLIC $CHRFN,$CSNGF,$CDBLF
NUMGFN=(2*MIDTK)-(2*ONEFUN)+1
BOTCON=(SQRTK-ONEFUN)*2
TOPCON=(ATNTK-ONEFUN)*2+1
$RNDFN=$RND-ONEFUN
$DATCO=$DATA-":"
$REMCO=$REM-":"
NMREL=LESSTK-GREATK+1
$CHRFN=$CHR$-ONEFUN
$CSNGF=$CSNG-ONEFUN
$CDBLF=$CDBL-ONEFUN
SUBTTL CRUNCH code to handle extended reserved words
PUBLIC CRUNCX
CRUNCX: POP BX ;GET BACK SOURCE POINTER
PUSH BX ;TO TRY AGAIN
DEC BX ;POINT AT CHARACTER
CALL MAKUPL ;CONVERT TO UPPER CASE
MOV BX,OFFSET ALPTAX ;GET POINTER TO ALPHA DISPATCH TABLE
SUB AL,LOW "A" ;SUBTRACT ALPHA OFFSET
ADD AL,AL ;MULTIPLY BY TWO
MOV CL,AL ;SAVE OFFSET IN [C] FOR DAD.
MOV CH,LOW 0 ;MAKE HIGH PART OF OFFSET ZERO
ADD BX,CX ;ADD TO TABLE ADDRESS
INS86 56
MOV DX,[BX] ;GET POINTER IN [D,E]
POP BX ;GET BACK SOURCE POINTER
TRYAGA: PUSH BX ;SAVE TXTPTR TO START OF SEARCH AREA
LOPPSI:
CALL MAKUPL ;TRANSLATE THIS CHAR TO UPPER CASE
MOV CL,AL ;SAVE CHAR IN [C]
INS86 213,362,56,254 ;FETCH FROM CODE SEGMENT
AND AL,LOW 127 ;GET RID OF HIGH BIT
JNZ SHORT ??L000
JMP NOTRFN ;IF=0 THEN END OF THIS CHARS RESLT
??L000:
INC BX ;BUMP SOURCE POINTER
CMP AL,CL ;COMPARE TO CHAR FROM SOURCE LINE
JNZ SHORT LOPSKP ;IF NO MATCH, SEARCH FOR NEXT RESWRD
INS86 213,362,56,254 ;FETCH FROM CODE SEGMENT
INC DX ;BUMP RESLST POINTER
OR AL,AL ;SET CC'S
JS SHORT ??L001
JMP LOPPSI ;SEE IF REST OF CHARS MATCH
??L001:
INS86 213,362,56,254 ;FETCH FROM CODE SEGMENT
CALL MAKUPL ;GET NEXT CHAR IN LINE (MC 6/22/80)
CMP AL,LOW "." ;IS IT A DOT
JZ SHORT ISVARS ;YES
CALL TSTANM ;IS IT A LETTER IMMEDIATELY
;FOLLOWING RESWRD
ISVARS: MOV AL,LOW 0 ;SET DONUM TO -1
JNAE SHORT ??L002
JMP NOTRFN ;IF ALPHA, CANT BE RESERVED WORD
??L002:
POP AX ;GET RID OF SAVED [H,L]
INS86 213,362,56,254 ;FETCH FROM CODE SEGMENT
OR AL,AL ;SET CC'S
POP CX ;GET CHAR COUNT OFF STACK
POP DX ;GET DEPOSIT POINTER OFF STACK
JNS SHORT ??L003
JMP NOTFNT ;IF MINUS, WASNT FUNCTION TOKEN
??L003:
OR AL,LOW 200O ;MAKE HIGH ORDER BIT ONE
STC ;AND FORCE LEADER BYTE TO BE 375
NOTFNT: PUSH AX ;SAVE FN CHAR
MOV AL,LOW 376O ;GET BYTE WHICH PRECEEDS FNS
SBB AL,LOW 0 ;MAKE FUNCTION LEADER 375
JMP RENCRN ;REENTER CRUNCH WITH NEW RESERVED WORD
LOPSKP: POP BX ;RESTORE UNDEFILED TEXT POINTER
LOPSK2:
INS86 213,362,56,254 ;FETCH FROM CODE SEGMENT
INC DX ;BUMP RESLST POINTER
OR AL,AL ;SET CC'S
JS SHORT ??L004
JMP LOPSK2 ;NOT END OF RESWRD, KEEP SKIPPING
??L004:
INC DX ;POINT AFTER TOKEN
JMP TRYAGA ;TRY ANOTHER RESWRD
SUBTTL LIST code for extended reserved words
BUFRET: RET
NEWFUN: MOV AL,BYTE PTR [BX] ;GET FUNCTION NUMBER
AND AL,LOW 177O ;TAKE OFF HIGH BIT
JMP SHORT BUFCON
PUBLIC LISTX
LISTX: CMP AL,LOW 375O ;IS IT A NEW FUNCTION
JZ SHORT NEWFUN
CMP AL,LOW 376O ;IS IT A NEW STATEMENT
JNZ SHORT BUFRET ;NO, JUST CONTINUE NORMAL PATH
MOV AL,BYTE PTR [BX] ;GET NUMBER OF STATEMENT
BUFCON: POP BX ;Get rid of the return address.
MOV BX,OFFSET RESLSX-1 ;GET PTR TO START OF RESERVED WORD LIST
MOV CH,AL ;SAVE THIS CHAR IN [B]
MOV CL,LOW OFFSET "A"-1 ;INIT LEADING CHAR VALUE
RESSR3: INC CL ;BUMP LEADING CHAR VALUE.
RESSR1: INC BX ;BUMP POINTER INTO RESLST
RESSRC: MOV DH,BH ;SAVE PTR TO START OF THIS RESWRD
MOV DL,BL
RESSR2:
INS86 56 ;FETCH FROM CODE SEGMENT
MOV AL,BYTE PTR [BX] ;GET CHAR FROM RESLST
OR AL,AL ;SET CC'S
JZ SHORT RESSR3 ;IF END OF THIS CHARS TABLE,
;GO BACK & BUMP C
LAHF
INC BX ;BUMP SOURCE PTR
SAHF
JS SHORT ??L005
JMP RESSR2 ;IF NOT END OF THIS RESWRD,
??L005:
;THEN KEEP LOOKING
INS86 56 ;FETCH FROM CODE SEGMENT
MOV AL,BYTE PTR [BX] ;GET PTR TO RESERVED WORD VALUE
CMP AL,CH ;SAME AS THE ONE WE SEARCH FOR?
JNZ SHORT RESSR1 ;NO, KEEP LOOKING.
XCHG BX,DX ;SAVE FOUND PTR IN [H,L]
MOV AL,CL ;GET LEADING CHAR
POP DX ;RESTORE LINE CHAR COUNT
POP CX ;RESTORE DEPOSIT PTR
MOV DL,AL ;SAVE LEADING CHAR IN [E]
;
; CODE BELOW NOT NEEDED SINCE NO SPECIAL REVERVED WORDS IN HOOK TABLE
;
; CPI "Z"+1 ;WAS IT A SPECIAL CHAR?
; JRNZ NTSPCH ;NON-SPECIAL CHAR
; XRA A ;SET NON-SPECIAL
; STA TEMPA
; JMPR MORPUR ;PRINT IT
NTSPCH: MOV AL,BYTE PTR TEMPA ;WHAT DID WE DO LAST?
OR AL,AL ;SPECIAL?
MOV AL,LOW 255 ;FLAG IN RESERVED WORD
MOV BYTE PTR TEMPA,AL ;CLEAR FLAG
MORLNZ: JZ SHORT MORLN0 ;GET CHAR AND PROCEED
MOV AL,LOW " " ;PUT SPACE IN BUFFER
MOV DI,CX
STOSB
INC CX
DEC DH ;ANY SPACE LEFT IN BUFFER
JNZ SHORT ??L006
JMP PPSWRT ;NO, RETURN
??L006:
MORLN0: MOV AL,DL
JMP SHORT MORLN1 ;CONTINUE
MORPUR:
INS86 56 ;FETCH FROM CODE SEGMENT
MOV AL,BYTE PTR [BX] ;GET BYTE FROM RESWRD
INC BX ;BUMP POINTER
MORLNP: MOV DL,AL ;SAVE CHAR
MORLN1: AND AL,LOW 177O ;AND OFF HIGH ORDER BIT FOR DISK & EDIT
MOV DI,CX
STOSB ;STORE THIS CHAR
INC CX ;BUMP PTR
DEC DH ;BUMP DOWN REMAINING CHAR COUNT
JNZ SHORT ??L007
JMP PPSWRT ;IF END OF LINE, JUST RETURN
??L007:
OR AL,DL ;SET CC'S
JS SHORT ??L008
JMP MORPUR ;END OF RESWRD?
??L008:
POP BX ;RESTORE SOURCE PTR.
INC BX ;SKIP OVER RESERVED WORD
JMP PLOOP2 ;GET NEXT CHAR FROM LINE
SUBTTL Extended Statement Dispatching
SNERRS: JMP SNERR
PUBLIC NEWSTX
NEWSTX: CMP AL,LOW OFFSET 376O-201O ;CHECK FOR NEW STATEMENT PREFIX
JZ SHORT GONE4 ;IF SO, DISPATCH
CMP AL,LOW OFFSET 377O-201O ;FUNCTION?
JNZ SHORT GIIRET
POP CX ;Put return address into B.
INC BX
MOV AL,BYTE PTR [BX]
CMP AL,LOW OFFSET $PEN ; PEN as stmt?
JNZ SHORT ??L009
JMP PENV ; Brif so.
??L009:
CMP AL,LOW OFFSET $STRIG ;STRIG as stmt?
JNZ SHORT ??L010
JMP STRIGV ; Brif so.
??L010:
DEC BX
MOV AL,LOW OFFSET 377O-201O
PUSH CX ;Put the return address back on.
GIIRET: RET ;MID$ OR SYNTAX ERROR
PENV: CALL CHRGTR
JMP PENS
STRIGV: CALL CHRGTR
JMP STRIGS
GONE4: POP CX ;Get rid of the return address.
INC BX ;LOOK AT NEXT CHAR
MOV AL,BYTE PTR [BX] ;FETCH IT
SUB AL,LOW 201O ;GET RELATIVE POSITION IN STMDSX
JB SHORT SNERRS ;IF TOO SMALL, SYNTAX ERROR
ADD AL,AL ;TURN BYTE INTO OFFSET
INS86 62,344 ;XOR AH,AH
INS86 213,360 ;MOV SI,AX - GET OFFSET INTO [SI]
INS86 56 ;CODE SEGMENT OVERRIDE
INS86 377,264,STMDSX ;PUSH STMDSP(SI) - PUSH ADDRESS
JMP CHRGTR ;START STATEMENT
SUBTTL EVAL code for extended functions
PUBLIC EVALX
EVALX: CMP AL,LOW 376O
JZ SHORT EVALNS ;Brif possible stmt as function
CMP AL,LOW 375O
JZ SHORT EVALNF ;NEW FUNCTION IF 375 IN FRONT
RET
EVALNS: INC BX
MOV AL,BYTE PTR [BX]
CMP AL,LOW OFFSET $DATE$
JZ SHORT DATEV ;Brif DATE$
CMP AL,LOW OFFSET $TIME$
JZ SHORT TIMEV ;Brif TIME$
DEC BX
MOV AL,BYTE PTR [BX]
RET
DATEV: POP CX ;Get rid of the hook return address.
JMP DATEF ;Do DATE function.
TIMEV: POP CX ;Get rid of the hook return address.
JMP TIMEF ;Do TIME$ function.
EVALNF: POP CX ;Get rid of the return address.
INC BX
MOV AL,BYTE PTR [BX]
SUB AL,LOW 201O
MOV CH,LOW 0
ROL AL,1
MOV CL,AL
PUSH CX
CALL CHRGTR
CALL PARCHK
POP SI ;XTHL
XCHG SI,BX
PUSH SI
MOV DX,OFFSET LABBCK
PUSH DX
MOV AL,LOW 1
MOV BYTE PTR FLGOVC,AL
INS86 213,363 ;MOV SI,BX (GET FUNCTION OFFSET IN SI)
INS86 56
INS86 377,264,FUNDSX
RET
CSEG ENDS
END