-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJUMP.ASM
3152 lines (2640 loc) · 44.4 KB
/
JUMP.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
;JUMP.ASM
INCLUDE UBDEF.H
INCLUDE UB.H
DATA SEGMENT WORD PUBLIC
public contadr,contcsp
public overloadaddadr,overloadsubadr,overloadmuladr
public overloaddivadr,overloadidivadr,overloadratdivadr
public overloadmodadr,overloadpoweradr
EXTRN compilegoto_sw:BYTE,compilejp_sw:BYTE
extrn compilevar_sw:byte,directflg:byte,schoolflg:byte
EXTRN CALCSP:WORD,UNLPT:BYTE
EXTRN MAXWORD:WORD,maxall:word,pointword:word
EXTRN ENDMEM:WORD,STACKPTR:WORD
EXTRN TXTTOP:WORD,TXTEND:WORD,calcsp_limit:word
extrn base_sp:word,editptr:word
extrn labelend:word
extrn arrayseg:word,limitseg:word,emanow:word
extrn out_dev:byte,contout_dev:byte
contadr dw ?
contcsp dw ? ;calcsp
overloadaddadr dw 0
overloadsubadr dw 0
overloadmuladr dw 0
overloaddivadr dw 0
overloadidivadr dw 0
overloadratdivadr dw 0
overloadmodadr dw 0
overloadpoweradr dw 0
DATA ENDS
CODE SEGMENT PUBLIC
ASSUME CS:CODE,DS:DATA
; following values are illegal values for attribute
; thus can be used for IDmark for passing parameteres
markofadr equ 0ff00h
markofarray equ 0ff01h
;PUBLIC LABELS
PUBLIC ENDIN,CANCEL,FUNCTION,GOSUB,RETURN,WHILE,WEND
PUBLIC REPEAT,UNTIL,FORIN,NEXT,DATAIN,contin
PUBLIC GOTO,RUN,JUMPIN,LOOPIN,ENDLOOP
PUBLIC HEXCX
PUBLIC IFIN,THENIN,ELSEIN,ELSEIFIN,IF2IN
public PASSTOKEN,farPasstoken,pasnxt_rem,farpass1sentence
public deffnreturn
public setoverloadadr
public overloadadd,overloadsub,overloadmul
public overloaddiv,overloadidiv,overloadratdiv
public overloadmod,overloadpower
public farpush_calcstack,farpop_calcstack
;EXTERNAL LABELS
EXTRN MAINLP:NEAR,LPRNSUB:NEAR,READY:NEAR
EXTRN FORMUL:NEAR,KAKKO:NEAR
EXTRN BACKSP:NEAR,AHEDSP:NEAR,INTER1:NEAR,SRCLIN:NEAR
EXTRN INILOOP:NEAR,DIMSUB:NEAR
EXTRN farINITWP:far,LINEND:NEAR,GO_ENDIN:NEAR
EXTRN SUBIN:NEAR,chg2cap:near
EXTRN LWADD:NEAR,LWSUB:NEAR,CLOSEALL:NEAR
extrn LOADMP:NEAR
EXTRN GETSAVADR:NEAR,GETLAVADR:NEAR,GETLLAVADR:NEAR
EXTRN PUSHSHORTSUB:NEAR,PUSHLONGSUB:NEAR
EXTRN POPSHORTSUB:NEAR,POPLONGSUB:NEAR,POPXLONGSUB:NEAR
extrn CHGOUT_INIT:near
extrn resvar:near,kanji1st?:near
extrn compilevar:near
extrn discompileall:near,discompilejp:near
extrn discompilegoto:near,discompilevar:near
extrn MAKE_LABEL_TABLE:near,getlabeladr:near
extrn label_table:byte
EXTRN FORSP:WORD,FORSPEND:WORD
EXTRN GOSUBSP:WORD,GOSUBSPEND:WORD
EXTRN SYNERR:NEAR,NOFOR:NEAR,NOWHILE:NEAR,SPERR:NEAR
EXTRN OVRERR:NEAR,NOGOSUB:NEAR,conterr:near,labelfull:near
EXTRN CALCSTKERR:NEAR,USRSTKERR:NEAR,ILGLET:NEAR
EXTRN NORETURN:NEAR,NONEXT:NEAR,NOWEND:NEAR,NOUNTIL:NEAR
EXTRN NOREPEAT:NEAR,NOLERR:NEAR,FORNEXTERR:NEAR
EXTRN ILGERR:NEAR,NOFILE:NEAR,DISKERR:NEAR,BIGPROG:NEAR
EXTRN NOMARK:NEAR,NOLOOP:NEAR,STACKFULL:NEAR,STACKEMPTY:NEAR
EXTRN UNDEFERR:NEAR,TYPEERR:NEAR,PASSERR:NEAR,fullerr:near
extrn localerr:near,cantdo:near,nooverload:near
extrn conditionerr:near
;
;☆次の行までスキップ(REM 行用)
;全てアスキーコードとみなす
PASNXT_REM:
MOV AX,[BP]
OR AX,AX
JZ PASNXT_REMIN
MOV BP,AX
JMP MAINLP
PASNXT_REMIN:
MOV SI,BP ;change pointer
inc si ;PASS 2 BYTES WORK
pasnxt_rem5:
inc si
PASNXT_REM10:
LODSB
CMP AL,CR
JNE PASNXT_REM10
mov dx,si ;memo CRadr+1
LODSW
OR AX,AX
JZ GO_GO_ENDIN ;実行終了
ADD SI,3 ;PASS LINE#
MOV AL,[SI]
CMP AL,NCODE_LABEL
JNE PASNXT_REM20
;PASSLABEL
INC SI
LODSB
XOR AH,AH
ADD AX,2
ADD SI,AX
PASNXT_REM20:
cmp byte ptr [si],98h
je pasnxt_rem5
mov si,dx
dec si
MOV [BP],SI ;CR adr次の行の先頭をセット
MOV [compilejp_sw],-1
MOV BP,SI
JMP MAINLP
GO_GO_ENDIN:
MOV BP,SI
JMP GO_ENDIN
;
;☆ DATA
;次の行までスキップ
DATAIN:
MOV SI,BP ;change pointer
LODSB
CMP AL,CR
JE DATAPAS5B ;行の終わりなので行番号と次先頭をパス
DATALP:
CALL PASSTOKEN
LODSB
CMP AL,CR
JNE DATALP
DATAPAS5B: ;先頭 5BYTES をパス
LODSW
ADD SI,3
OR AX,AX
JNZ DATARET
SUB SI,6 ;CR の位置にする
DATARET:
MOV BP,SI
JMP MAINLP
;
;☆CANCELの処理
;
CANCEL:
MOV AL,[BP]
INC BP
CMP AL,89H ;FOR
JE CANFOR
JMP SYNERR
CANFOR:
MOV BX,CS:[FORSP]
CMP BX,OFFSET FORSP
JBE CANF_ERR ;FOR がないのに CANCEL した
SUB BX,forunitbyte
MOV CS:[FORSP],BX
CMP BYTE PTR [BP],0C2H ;code of ,
JNE CANFOUT
INC BP
JMP CANCEL
CANFOUT:
JMP MAINLP
CANF_ERR:
JMP NOFOR
;
;* operator overload
;
setoverloaddefault:
inc bp
mov word ptr [bx],0
jmp mainlp
setoverloadsynerr:
jmp synerr
setoverloadadd:
inc bp
mov ax,[bp]
cmp ah,CR
je setoverloaddefault
cmp ah,0c0h ;code of ':'
je setoverloaddefault
cmp ax,0b3d1h ;code of '=fn'
jne setoverloadsynerr
winc bp
jmp setoverloadjp
setoverloadadr:
mov al,[bp]
mov bx,offset overloadaddadr
cmp al,codeofadd
je setoverloadadd
mov bx,offset overloadsubadr
cmp al,codeofsub
je setoverloadin
mov bx,offset overloadmuladr
cmp al,codeofmul
je setoverloadin
mov bx,offset overloaddivadr
cmp al,codeofdiv
je setoverloadin
mov bx,offset overloadidivadr
cmp al,codeofidiv
je setoverloadin
mov bx,offset overloadratdivadr
cmp al,codeofratdiv
je setoverloadin
mov bx,offset overloadmodadr
cmp al,codeofmod
je setoverloadin
mov bx,offset overloadpoweradr
cmp al,codeofpower
jne setoverloadsynerr
setoverloadin:
inc bp
cmp word ptr [bp],0b3d1h ;code of '=fn'
jne setoverloadsynerr
winc bp
setoverloadjp:
mov al,[bp]
cmp al,Ncode_LABEL
jne setoverloadsynerr
push bx
call getlabeladr
pop bx
mov [bx],ax
jmp mainlp
overload_undef:
jmp nooverload
overloadpower:
mov di,[overloadpoweradr]
jmp overloadin
overloadsub:
mov di,[overloadsubadr]
jmp overloadin
overloadmul:
mov di,[overloadmuladr]
jmp overloadin
overloaddiv:
mov di,[overloaddivadr]
jmp overloadin
overloadidiv:
mov di,[overloadidivadr]
jmp overloadin
overloadratdiv:
mov di,[overloadratdivadr]
jmp overloadin
overloadmod:
mov di,[overloadmodadr]
jmp overloadin
overloadadd:
mov di,[overloadaddadr]
overloadin:
or di,di
jz overload_undef
push [base_sp]
mov [base_sp],sp ;current base stack pointer
push di ;/*
MOV SI,CS:[GOSUBSP]
ADD SI,GOSUBUNITBYTE
CMP SI,OFFSET GOSUBSPEND-GOSUBUNITBYTE
JA GOSUBSPERR
MOV CS:[GOSUBSP],SI
MOV word ptr CS:[SI+4],0
MOV AX,[CALCSP]
;SUB AX,UNITBYTE
MOV CS:[SI+6],AX
MOV AX,[arrayseg]
MOV CS:[SI+8],AX ;variable segment now
mov ax,[emanow]
MOV cs:[SI+10],AX ;ema address_low now
mov ax,[emanow+2]
MOV cs:[SI+12],AX ;ema address_high now
mov ax,[pointword]
mov cs:[si+14],ax
mov ax,cs:[FORSP]
mov cs:[si+16],ax
xor ax,ax
call usrpushax ;USR STACK END MARK(will be used by RETURN)
pop di ;*/
cmp byte ptr [di],'('
jne overloadargerr
inc di
mov bx,[gosubsp]
mov cs:[bx],bp ;set return address
mov ax,[calcsp]
add ax,unitbyte
mov [calcsp],ax
; add ax,unitbyte
; mov cs:[bx+4],ax ;base adr of parameter stack
mov al,[di]
cmp al,'&'
je overloadargerrdi
call getvalue ;call by value
ahedsp_mac
cmp byte ptr [di],0c2h ;code of ','
jne overloadargerr
inc di
mov al,[di]
cmp al,'&'
je overloadargerrDI
call getvalue ;call by value
add [calcsp],unitbyte
; mov bx,[gosubsp]
; mov ax,[calcsp]
; sub ax,unitbyte
; mov cs:[bx+4],ax ;base adr of parameter stack
cmp byte ptr [di],')'
jne overloadargerrDI
inc di
jmp go_getlocal
overloadargerrDI:
mov bp,di
overloadargerr:
jmp ilgerr
;
;☆ FNの処理
;
myalign
FUNCTION:
push [base_sp]
mov [base_sp],sp ;current base stack pointer
MOV SI,CS:[GOSUBSP]
ADD SI,GOSUBUNITBYTE
CMP SI,OFFSET GOSUBSPEND-GOSUBUNITBYTE
JA GOSUBSPERR
MOV CS:[GOSUBSP],SI
MOV word ptr CS:[SI+4],0
MOV AX,[CALCSP]
SUB AX,UNITBYTE
MOV CS:[SI+6],AX
MOV AX,[arrayseg]
MOV CS:[SI+8],AX ;variable segment now
mov ax,[emanow]
MOV cs:[SI+10],AX ;ema address_low now
mov ax,[emanow+2]
MOV cs:[SI+12],AX ;ema address_high now
mov ax,[pointword]
mov cs:[si+14],ax
mov ax,cs:[FORSP]
mov cs:[si+16],ax
MOV AL,[BP]
CMP AL,Ncode_LABEL
JAE GOSUB_LABEL
JMP SYNERR
;
; * push all the calc stacks to user stack
farpush_calcstack:
push es
xor ax,ax ;counter
mov si,[calcsp]
cmp si,LIMIT
je pushcalcst100
pushcalcst10:
push ax
call pushlongsub
pop ax
inc ax
mov si,[calcsp]
add si,UNITBYTE
mov [calcsp],si
cmp si,LIMIT
jb pushcalcst10
pushcalcst100:
call usrpushax ;number of data
mov ax,'&'+3 ;mark of calc_stack data
call usrpushax
pop es
retf
;
; * pop all the calc stacks from user stack
;
farpop_calcstack:
push ds
mov ss:[calcsp],LIMIT
call usrpopax
cmp ax,'&'+3 ;mark of calc_stack data
jne retusrstkerr
call usrpopax
or ax,ax
jz popcalcst100
popcalcst10:
push ax
mov di,ss:[calcsp]
sub di,UNITBYTE
mov ss:[calcsp],di
call poplongsub
pop ax
dec ax
jnz popcalcst10
popcalcst100:
pop ds
retf
;
;☆ GOSUBの処理
;
GOSUBSPERR:
JMP SPERR
GOSUBNOLERR:
JMP NOLERR
myalign
GOSUB:
MOV AX,OFFSET MAINLP
PUSH AX ;push for return
push [base_sp]
mov [base_sp],sp ;current base stack pointer
MOV SI,CS:[GOSUBSP]
ADD SI,GOSUBUNITBYTE
CMP SI,OFFSET GOSUBSPEND-GOSUBUNITBYTE
JA GOSUBSPERR
MOV CS:[GOSUBSP],SI
MOV word ptr CS:[SI+4],0
MOV AX,[CALCSP]
MOV CS:[SI+6],AX ;no_function mark
MOV AX,[arrayseg]
MOV CS:[SI+8],AX ;array segment now
mov ax,[emanow]
MOV CS:[SI+10],AX ;ema address_low now
mov ax,[emanow+2]
MOV CS:[SI+12],AX ;ema address_high now
mov ax,[pointword]
mov cs:[si+14],ax
mov ax,cs:[FORSP]
mov cs:[si+16],ax
MOV AL,[BP]
CMP AL,Ncode_LABEL
JAE GOSUB_LABEL
;* LINE NUMBER CASE
GOSUB_LINNUM:
INC BP
CMP AL,Ncode_ADR
JE GOSUB_LN2ND
GOSUB_LN1ST:
CMP AL,NCODE1
JNE SYNERRSI
;* LINE NUMBER CASE OF 1ST TIME
MOV CX,[BP] ;行番号をアドレスに変える
CALL SRCLIN
JNZ GOSUBNOLERR
ADD BX,5 ;番地・番号をパスするのみ
MOV [compilegoto_sw],-1
MOV BYTE PTR[BP-1],Ncode_ADR
MOV [BP],BX ;飛び先番地
LEA SI,[BP+2]
MOV DI,BX
JMP SETARG
;* LINE NUMBER CASE OF 2ND TIME
GOSUB_LN2ND:
MOV DI,[BP] ;アドレスになっている場合
LEA SI,[BP+2]
JMP SETARG
;* LABEL CASE
GOSUB_LABEL:
CMP AL,NCODE_ADR2
JE GOSUB_LABEL2ND
JNB SYNERRSI
;* LABEL CASE OF 1ST TIME
GOSUB_LABEL1ST:
MOV [compilegoto_sw],-1
MOV BYTE PTR [BP],Ncode_ADR2
CALL GETLABELADR
MOV SI,BP
SUB BP,2 ;BP=jump address area in text
MOV [BP],DI ;set adr where jump adr stored
mov di,ax ;jump adr
JMP SETARG
;* LABEL CASE OF 2ND TIME
GOSUB_LABEL2ND:
XOR BX,BX
MOV BL,[BP+1]
ADD BX,2
ADD BP,BX ;BP=jump address area in text
LEA SI,[BP+2]
MOV DI,[BP]
mov di,cs:[di]
jmp setarg
synerrsi:
LEA BP,[SI-1]
JMP ilgerr
;
;* set parameters in CALCSP
;
myalign
SETARG:
XOR AX,AX
CALL USRPUSHAX ;USR STACK END MARK(will be used by RETURN)
CMP BYTE PTR [SI],'('
JE setarg5
cmp byte ptr [di],'('
je synerrSI
setarg2:
mov bx,[gosubsp]
mov cs:[bx],si ;set return address
jmp go_getlocal ;no parameters
setarg3:
inc si
cmp word ptr [di],')('
jne synerrSI
add di,2
jmp setarg2
setarg5:
INC SI
CMP BYTE PTR [SI],')'
je setarg3 ;no parameter
CMP BYTE PTR [DI],'('
JNE SYNERRSI
MOV BX,[GOSUBSP]
mov ax,[calcsp]
mov cs:[bx+4],ax ;base adr of parameter stack
INC DI
push di ;*
SETARGLP:
MOV AL,[SI]
CMP AL,'&'
JE SETARG10
cmp al,vcode1
je setargwholearray?
cmp al,vcode3
je setargwholearray?
cmp al,vcode5
je setargwholearray?
setarg7:
MOV BP,SI ;call by value
CALL FORMUL
mov si,bp
JMP SETARG20
setargwholearray?:
lea bx,[si+1]
xor ax,ax
mov al,[bx]
inc bx
add bx,ax
mov al,[bx]
cmp al,29h ;')'
je gosetargarray
cmp al,0c2h ;','
je gosetargarray
jmp setarg7
passerrsi:
LEA BP,[SI-1]
jmp passerr
gosetargarray:
jmp setargwholearray
SETARG10:
mov ax,si ;call by address
call ahedsp
mov di,si
mov si,ax
mov ax,markofadr ;address mark
stosw
inc si ;pass '&'
lodsb
stosb ;store varcode
cmp al,0b3h ;code of fn
je setarg_fn
cmp al,ncode_label
jae setarg_proc
SUB AL,VCODE
JB go_synerrsi
JE passerrsi ;simple short not passed by address
CMP AL,6
JAE go_synerrsi
xor ax,ax
lodsb
mov bx,[si]
add si,ax ;new text ptr
inc byte ptr cs:[bx-2] ;depth of '&'-used
mov ax,bx
stosw ;store table adr(new)
MOV ax,cs:[BX] ;get offset/segment
or ax,ax
jz setargundef ;undefined array
stosw ;store it
SETARG20:
CMP BYTE PTR [SI],0C2H ;code of ','
JNE SETARGOUT
INC SI
JMP SETARGLP
setargundef:
jmp undeferr
go_synerrsi:
jmp synerrsi
setarg_proc:
dec si
setarg_fn:
mov bp,si
mov al,[bp]
cmp al,ncode_label
je setargfn1st
cmp al,ncode_adr2
jne go_synerrsi
setargfn2nd:
xor ax,ax
inc si
lodsb
add si,ax
lodsw
mov bx,ax
mov ax,cs:[bx]
stosw ;store table adr
setargfnout:
lodsw
cmp ax,2928H ;()
je setarg20
sub si,2
jmp setarg20
setargfn1st:
mov [compilegoto_sw],-1
mov byte ptr [BP],Ncode_ADR2
push di
call getlabeladr
or ax,ax
jz setargundef
mov si,bp
mov [si-2],di ;set table adr
pop di
stosw ;store function adr
jmp setargfnout
SETARGOUT:
CMP BYTE PTR [SI],')'
JNE go_SYNERRSI
INC SI
pop di ;*
setarg100:
MOV BX,[GOSUBSP]
MOV CS:[BX],SI ;set return address
;
;* get parameters from CALCSP
;
getarg:
mov ax,[calcsp]
mov bx,[gosubsp]
mov cx,cs:[bx+4]
mov [calcsp],cx
getarglp:
push ax ;* final calcsp
MOV AL,[di]
CMP AL,'&'
JE getarg10
call getvalue ;call by value
ahedsp_mac
JMP getarg20
getarg10:
inc di
call getaddress
getarg20:
CMP BYTE PTR [di],0C2H ;code of ','
JNE getargOUT
INC di
pop ax ;*
cmp ax,[calcsp]
jae ilgerrdi ;check parameter numbers
JMP getargLP
ilgerrdi:
lea bp,[di-1]
jmp ilgerr
getargOUT:
CMP BYTE PTR [di],')'
JNE SYNERRdi
INC di
pop ax ;*
cmp ax,[calcsp]
jne ilgerrdi ;check parameter numbers
mov bx,[gosubsp]
mov ax,cs:[bx+4]
mov [calcsp],ax
go_getlocal:
CMP WORD PTR [DI],98C0H ;':REM'
JNE goloc105
ADD DI,2
CALL PASSREM_DI
JMP goloc110
goloc105:
CMP BYTE PTR [DI],CR
JNE goloc110
CMP WORD PTR [DI+1],0
JE SYNERRDI
ADD DI,6
CMP BYTE PTR [DI],98H ;'REM
JNE goloc110
INC DI
CALL PASSREM_DI
goloc110:
mov al,[di]
jmp branch
synerrdi:
LEA BP,[DI-1]
JMP ilgerr
;*
;* BRANCH TO LOCAL & LOCAL_DIM
;*
branchlp:
cmp al,CR
je branch_cr
cmp al,0c0h ;':'
jne branch
inc di
mov al,[di]
jmp branchlp
branch_cr:
cmp word ptr [di+1],0
je synerrdi
add di,6
mov al,[di]
jmp branchlp
go_setlocaldim:
jmp setlocaldim
BRANCH:
cmp al,0bah ;local
je setlocal
cmp al,0a4h ;dim
je go_setlocaldim
cmp al,98h ;REM
je branch_rem
MOV BX,CS:[GOSUBSP]
MOV AX,[STACKPTR]
MOV CS:[BX+2],AX ;user stack pointer
MOV BP,DI
JMP INTER1
branch_rem:
INC DI
CALL PASSREM_DI
mov al,[di]
jmp branchlp
;
;* pass all values of an array
;
setargwholearray:
push di
mov ax,si
call ahedsp
mov di,si
mov si,ax
mov ax,markofarray
stosw
movsb ;store varcode
xor ax,ax
lodsb
mov bx,[si]
add si,ax ;new text ptr
MOV ax,cs:[BX] ;get offset/segment
or ax,ax
jz argwholeundef ;undefined array
stosw ;store it
pop di
jmp setarg20
argwholeundef:
jmp undeferr
;*
;* SET LOCAL VARIABLES
;*
golocalerr:
mov bp,bx
jmp localerr
SETLOCAL:
INC DI
lea bx,[di+1]
xor ax,ax
mov al,[bx]
inc bx
mov si,[bx]
cmp byte ptr cs:[si-2],0
jne golocalerr
add bx,ax
cmp byte ptr [bx],codeofequal
jne setlocal50
lea bp,[bx+1] ;initial value is assigned
push di
call formul
pop di
push bp
call setvaluein ;di is pointer
pop di
jmp setlocal100
setlocal50: ;initial value default(=0)
CALL AHEDSP
MOV WORD PTR [SI],0
CALL SETVALUEIN ;set 0
setlocal100:
mov al,[di]
cmp al,0c2h ;','
je setlocal
jmp branchlp
;*
;* SET LOCAL ARRAYS
;*
setlocaldim:
INC DI
push di
CALL SETLARADDRESS
POP BP
CALL DIMSUB
MOV DI,BP
MOV AX,[DI]
CMP AL,0C2H ;','
je setlocaldim
jmp branchlp
PASSREM_DI:
MOV AX,[DI]
OR AX,AX
JZ PASSREMDI10
MOV DI,AX
RET
PASSREMDI10:
MOV BX,DI
PASSREMDI20:
INC DI
PASSREMDI30:
INC DI
MOV AL,CR
MOV CX,8000H
REPNE SCASB
CMP WORD PTR [DI],0
JE synerrdi2
ADD DI,5
CMP BYTE PTR [DI],98H
JNE PASSREMDI40
INC DI
MOV AX,[DI]
OR AX,AX
JZ PASSREMDI20
MOV DI,AX
PASSREMDI40:
MOV [BX],DI
RET
SYNERRSI2:
LEA BP,[SI-1]
JMP ilgerr
SYNERRDI2:
LEA BP,[DI-1]
JMP ilgerr
;*
;* SUBROUTINE FOR SET PARAMETERS
;*
;* CALL BY ADDRESS
getadrilgerrdi:
lea bp,[di-1]
jmp ilgerr
go_getadr_proc: