/
MAIN.asm
2776 lines (2570 loc) · 68.3 KB
/
MAIN.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
; *************************************************************************
;
; Monty programming language for the Z80
;
; by John Hardy 2023
;
; GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
;
; see the LICENSE file in this repo for more information
;
; Incorporating code from the MINT project by Ken Boak and Craig Jones.
; Inspiration from Charles H. Moore, Peter Jakacki and André Staltz
;
; *****************************************************************************
TRUE equ -1 ; C-style true
FALSE equ 0
NUL equ 0 ; exit code
DQ equ $22 ; " double quote char
CTRL_C equ 3
CTRL_E equ 5
CTRL_H equ 8
CTRL_J equ 10
CTRL_L equ 12
CTRL_P equ 16
CTRL_S equ 19
ESC equ 27
; macros for inlining a onty function in assembly
; follow immediately with a null terminated block of Monty code
.macro FUNC,name,numLocals,argsStr
name:
call go
dw NUL ; NUL closure
dw name%%M
dw $+2
db numLocals ; num_locals
.pstr argsStr
name%%M:
.endm
.macro PERFORM,name
ld ix,perform%%M
jp name
perform%%M:
.endm
.org ROMSTART + $180 ; 0+180 put monty code from here
;********************** PAGE 1 BEGIN *********************************************
opcodes:
DB lsb(bang_) ; ! 1
DB lsb(dquote_) ; " 2
DB lsb(hash_) ; # 1
DB lsb(dollar_) ; $ 1
DB lsb(percent_) ; % 1
DB lsb(amper_) ; & 1
DB lsb(quote_) ; ' 2
DB lsb(lparen_) ; ( 1
DB lsb(rparen_) ; ) 1
DB lsb(star_) ; * 1
DB lsb(plus_) ; + 1
DB lsb(comma_) ; , 2
DB lsb(minus_) ; - 1
DB lsb(dot_) ; . 2
DB lsb(slash_) ; / 1
DB lsb(num_) ; 0 1
DB lsb(num_) ; 1
DB lsb(num_) ; 2
DB lsb(num_) ; 3
DB lsb(num_) ; 4
DB lsb(num_) ; 5
DB lsb(num_) ; 6
DB lsb(num_) ; 7
DB lsb(num_) ; 8
DB lsb(num_) ; 9
DB lsb(colon_) ; : 2
DB lsb(semicolon_) ; ; 2
DB lsb(lt_) ; < 1
DB lsb(eq_) ; = 1
DB lsb(gt_) ; > 1
DB lsb(question_) ; ? 1
DB lsb(at_) ; @ 2
DB lsb(upcase_) ; A 1
DB lsb(upcase_) ; B
DB lsb(upcase_) ; C
DB lsb(upcase_) ; D
DB lsb(upcase_) ; E
DB lsb(upcase_) ; F
DB lsb(upcase_) ; G
DB lsb(upcase_) ; h
DB lsb(upcase_) ; I
DB lsb(upcase_) ; J
DB lsb(upcase_) ; K
DB lsb(upcase_) ; L
DB lsb(upcase_) ; M
DB lsb(upcase_) ; N
DB lsb(upcase_) ; O
DB lsb(upcase_) ; p
DB lsb(upcase_) ; Q
DB lsb(upcase_) ; R
DB lsb(upcase_) ; S
DB lsb(upcase_) ; T
DB lsb(upcase_) ; U
DB lsb(upcase_) ; V
DB lsb(upcase_) ; W
DB lsb(upcase_) ; X
DB lsb(upcase_) ; Y
DB lsb(upcase_) ; Z
DB lsb(lbrack_) ; [ 2
DB lsb(backslash_) ; \ 2
DB lsb(rbrack_) ; ] 2
DB lsb(caret_) ; ^ 1
DB lsb(underscore_) ; _ 2
DB lsb(grave_) ; ` 2
DB lsb(lowcase_) ; a 1
DB lsb(lowcase_) ; b
DB lsb(lowcase_) ; c
DB lsb(lowcase_) ; d
DB lsb(lowcase_) ; e
DB lsb(lowcase_) ; f
DB lsb(lowcase_) ; g
DB lsb(lowcase_) ; h
DB lsb(lowcase_) ; i
DB lsb(lowcase_) ; j
DB lsb(lowcase_) ; k
DB lsb(lowcase_) ; l
DB lsb(lowcase_) ; m
DB lsb(lowcase_) ; n
DB lsb(lowcase_) ; o
DB lsb(lowcase_) ; p
DB lsb(lowcase_) ; q
DB lsb(lowcase_) ; r
DB lsb(lowcase_) ; s
DB lsb(lowcase_) ; t
DB lsb(lowcase_) ; u
DB lsb(lowcase_) ; v
DB lsb(lowcase_) ; w
DB lsb(lowcase_) ; x
DB lsb(lowcase_) ; y
DB lsb(lowcase_) ; z
DB lsb(lbrace_) ; { 1
DB lsb(pipe_) ; | 1
DB lsb(rbrace_) ; } 1
DB lsb(tilde_) ; ~ 1
;********************** PAGE 1 END *********************************************
; ***********************************************************************
; Initial values for system vars
; ***********************************************************************
isysVars:
dw TIB ; vTIBPtr pointer into TIB
dw BUFFER ; vBufPtr pointer into BUF
dw HEAP ; vHeapPtr \h start of the free mem
dw NUL ; vRecurPtr
db 2 ; vDataWidth in bytes of array operations (default 1 byte)
db 10 ; vNumBase = 10
db "$" ; vHexPrefix
db TRUE ; vEcho
db FALSE ; vStrMode
db 0
db 0
db 0
db 0
db 0
; **********************************************************************
; title string (also used by warm boot)
; **********************************************************************
titleStr:
.cstr ESC,"[2JMonty V0.1\r\n",0,0,0
;********************** PAGE 2 BEGIN ***********************************
colon_:
jp (ix)
comma_:
jp comma
dollar_:
jp dollar
dquote_:
quote_:
jp quote
dot_:
jp dot
percent_:
jp percent
question_:
jp question
lparen_:
jp lbrace
slash_:
jp slash
num_:
jp num
bang_:
bang: ; logical invert, any non zero value
inc bc
ld a,(bc)
cp "="
jr nz,not
pop hl
pop de
jp notequals
not:
dec bc
ld hl,0 ; is considered true
jr eq1
eq_:
eq:
inc bc
ld a,(bc)
cp "="
jr z,eq0
dec bc
jp assign
eq0:
pop hl
eq1:
pop de
jp equals
gt_:
gt:
inc bc
ld a,(bc)
cp ">"
jp z,shiftRight
pop de
pop hl
jr lt1
lt_:
lt:
inc bc
ld a,(bc)
cp "<"
jp z,shiftLeft
pop hl
pop de
lt1:
cp "="
jp z,lessthaneq
dec bc
jp lessthan
; index of an array, based on vDataWidth 22
; array* num -- value ; also sets vPointer to address
hash_:
semicolon_:
semicolon:
arrayIndex:
pop hl ; hl = index
pop de ; de = array
ld a,(vDataWidth) ; a = data width
dec a
jr z,arrayIndex1
arrayIndex0:
add hl,hl ; if data width = 2 then double
arrayIndex1:
add hl,de ; add addr
jp variable
; 4
rparen_:
; jp rparen
rparen:
ld c,(iy+8) ; IP = block* just under stack frame
ld b,(iy+9)
jp (ix)
; & and 14
; a b -- c
amper_:
amper:
and:
pop de ; Bitwise and the top 2 elements of the stack
pop hl
ld a,e
and l
ld l,a
ld a,d
and h
ld h,a
jr add3
; - sub
; a b -- c
; -- sub
; b1 -- b2
; -= sub
; a b1 -- b2
minus_:
minus:
inc bc ; check if sign of a number
ld a,(bc)
dec bc
cp "0"
jr c,sub
cp "9"+1
jp c,num
sub: ; Subtract the value 2nd on stack from top of stack
pop hl ; hl = arg_b
inc bc
cp "-"
jr nz,sub1
dec hl ; --
jp assign0
sub1:
pop de ; de = arg_a
cp "="
jr z,sub2
dec bc ; -
ex de,hl
sub2:
or a ; -=
sbc hl,de
sub3:
cp "="
jp z,assign0
push hl
jp (ix)
star_: ; 21
star:
inc bc ; check for ** spread
ld a,(bc)
cp "*"
jp z,spread
dec bc
mul:
pop de ; get first value
pop hl
mul2:
push bc ; Preserve the IP
ld bc,hl ; bc = 2nd value
ld hl,0
ld a,16
mul3:
add hl,hl
rl e
rl d
jr nc,$+6
add hl,bc
jr nc,$+3
inc de
dec a
jr nz,mul3
pop bc ; Restore the IP
jp add3
; + add 25
; a b -- c
plus_:
plus:
add:
inc bc
ld a,(bc)
cp "+" ; ++ increment variable
jr nz,add1
pop hl
inc hl
jp assign0
add1:
dec bc
pop de ; second term
pop hl ; first term
add hl,de
add3:
inc bc
ld a,(bc)
cp "="
jr z,add4
dec bc
push hl
jp (ix)
add4:
jp assign0
; 18
upcase_:
upcase:
ld a,(bc) ; a = identifier char
sub 'A' ; 'A' = 0
jr ident1
;********************** PAGE 2 END *********************************************
.align $100
;********************** PAGE 3 BEGIN *********************************************
lowcase_:
lowcase:
ld a,(bc)
sub 'a'
add a,26
ident1:
add a,a ; l = a * 2
ld l,a
ld h,msb(VARS)
ld (vPointer),hl ; store address in setter
ld e,(hl)
inc hl
ld d,(hl)
push de
jp (ix)
; [ 14
lbrack_:
lbrack:
arrayStart:
ld de,0 ; create stack frame
push de ; push null for IP
ld e,(iy+4) ; push arg_list* from parent stack frame
ld d,(iy+5) ;
push de ;
ld e,(iy+2) ; push first_arg* from parent stack frame
ld d,(iy+3) ;
push de ;
push iy ; push BP
ld iy,0 ; BP = SP
add iy,sp
jp (ix)
; \ 19
backslash_:
backslash:
lambda:
push ix
call parseArgs
lambda1:
inc bc ; arg_list must ve immediately followed by {
ld a,(bc)
cp " "+1 ; skip white space
jr c,lambda1
cp "{"
jr z,lambda2
ld hl,2 ; error 2: parse error
jp error
lambda2:
call parseBlock
call createFunc
pop hl
pop ix
push hl
jp (ix)
rbrack_:
rbrack:
arrayEnd: ; 53
ld d,iyh ; de = BP
ld e,iyl
ld (vTemp1),bc ; save IP
ld hl,de ; hl = de = BP
or a
sbc hl,sp ; hl = array count (items on stack)
srl h ;
rr l
ld bc,hl ; bc = count
ld hl,(vHeapPtr) ; hl = array[-4]
ld (hl),c ; write num items in length word
inc hl
ld (hl),b
inc hl ; hl = array[0], bc = count
; de = BP, hl = array[0], bc = count
jr arrayEnd3
arrayEnd1:
ld a,(iy-2) ; a = lsb of stack item
ld (hl),a ; write lsb of array item
inc hl ; move to msb of array item
ld a,(vDataWidth) ; vDataWidth=1?
dec a
jr z,arrayEnd2
ld a,(iy-1) ; a = msb of stack item
ld (hl),a ; write msb of array item
inc hl ; move to next word in array
arrayEnd2:
dec iy ; move to next word on stack
dec iy
dec bc ; dec items count
arrayEnd3:
ld a,c ; if not zero loop
or b
jr nz,arrayEnd1
ex de,hl ; de = end of array, hl = BP
ld sp,hl ; sp = BP
pop hl ; de = end of array, hl = old BP
ex de,hl ; iy = de = old BP, hl = end of array
ld iyh,d
ld iyl,e
pop de ; pop arg_list (discard)
pop de ; pop first_arg* (discard)
pop de ; pop IP (discard)
ld de,(vHeapPtr) ; de = array[-2]
inc de
inc de
push de ; return array[0]
ld (vHeapPtr),hl ; move heap* to end of array
ld bc,(vTemp1) ; restore IP
jp (ix)
caret_:
; execute a block of code which ends with } 116
; creates a root scope if BP == stack
; else uses outer scope
caret:
go:
pop de ; de = block*
go1:
ld a,e ; if block* == null, exit
or d
jr nz,go2
jp (ix)
go2:
ld a,(de)
cp "{"
jp z,goBlock
cp "("
jp nz,goFunc
push de ; push de just before stack frame
jp z,goBlock
grave_:
grave:
printLiteral:
inc bc ; move to first char
ld de,(vBufPtr) ; de = buffer*
jr printLiteral1
printLiteral0:
ld (de),a ; a -> buffer*
inc de ; string*++,
inc bc
printLiteral1:
ld a,(bc) ; a <- string*
cp "`" ; if ` exit loop
jr nz,printLiteral0
ld (vBufPtr),de ; save buffer*' in pointer
jp dotNext
lbrace_:
lbrace:
call parseBlock
jp (ix)
; | or 11
; a b -- c
pipe_:
pipe:
or:
pop de ; Bitwise or the top 2 elements of the stack
pop hl
ld a,e
or l
ld l,a
ld a,d
or h
ld h,a
jp add3
rbrace_:
jp rbrace
; ~ char 8
tilde_:
jp tilde
underscore_:
char:
inc bc ; point to next char
ld a,(bc)
ld l,a
ld h,0
push hl
jp (ix)
at_:
at:
addr:
ld de,(vPointer)
ld hl,vPointer
jp variable
;********************** PAGE 3 END *********************************************
.align $100
;********************** PAGE 4 BEGIN *********************************************
; 67
dot:
print:
call cmdTable
db "a",0 ; .a print array
dw printArray
db "c",0 ; .c print char
dw printChar
db "s",0 ; .s print string
dw printString
dw 0 ; . print number, fall through
dw printNumber
; .c print char
; char --
printChar:
pop hl ; a = char
ld a,l
ld de,(vBufPtr) ; de = buffer*
ld (de),a
inc de
ld (vBufPtr),de ; save buffer*'
jp dotNext
; .s print string
; string* --
printString:
pop hl ; hl = string*
ld de,(vBufPtr) ; de = buffer*
jr printString1
printString0:
ld (de),a ; a -> buffer*
inc de ; string*++,
inc hl
printString1:
ld a,(hl) ; a <- string*
or a ; if NUL exit loop
jr nz,printString0
ld (vBufPtr),de ; save buffer*' in pointer
jp dotNext
; . print decimal
; value --
printNumber:
ld a,(vNumBase)
cp 16
jp z,printHex ; else falls through
jp printDec
; print decimal ; 70
; value --
printDec:
ld de,(vBufPtr) ; de'= buffer* bc' = IP
exx
pop hl ; hl = value
ld a,(vDataWidth)
dec a
jr nz,printDec1
ld h,0
printDec1:
call formatDec
exx ; de = buffer*' bc = IP
ld a," " ; append space to buffer
ld (de),a
inc de ; string*++,
ld (vBufPtr),de ; update buffer* with buffer*'
jp dotNext
; buffer hex 37
; value --
printHex:
ld de,(vBufPtr)
ld a,(vHexPrefix) ; "$"
or a ; skip if null
jr z,printHex1
ld (de),a
inc de ; string*++,
printHex1:
pop hl ; hl = value
ld a,(vDataWidth)
dec a
jr z,printHex2
ld a,h
call printHex3
printHex2:
ld a,l
call printHex3
ld a," " ; append space to buffer
ld (de),a
inc de ; string*++,
ld (vBufPtr),de
jp dotNext
printHex3:
push af
rra
rra
rra
rra
call printHex4
pop af
printHex4:
and 0x0F
add a,0x90
daa
adc a,0x40
daa
ld (de),a
inc de ; string*++,
ret
;********************** PAGE 4 END *********************************************
.align $100
;********************** PAGE 5 BEGIN *********************************************
slash:
command:
inc bc
ld a,(bc)
cp "/" ; // comment
jp z,comment
dec bc
call charTable
db lsb(command_a_)
db lsb(command_b_)
db lsb(command_c_)
db lsb(command_d_)
db lsb(command_e_)
db lsb(command_f_)
db 0
db lsb(command_h_)
db lsb(command_i_)
db 0
db 0
db 0
db lsb(command_m_)
db 0
db lsb(comand_o_)
db 0
db 0
db lsb(command_r_)
db lsb(command_s_)
db lsb(command_t_)
db 0
db lsb(command_v_)
db lsb(command_w_)
db lsb(command_x_)
db 0
db 0
db lsb(command_default_)
; 12
command_a_:
call cmdTable
db "bs" ; /abs absolute
dw absolute
db "dr" ; /adr address of
dw addrOf
db "it" ; /ait array iterator
dw arrayIter
db "lc" ; /alc mem allocate
dw memAllocate
db "ln" ; /aln array length
dw arrayLength
dw 0
dw error1
command_b_:
call cmdTable
db "ye" ; /bye cold reboot
dw coldStart
db "yt" ; /byt byte mode
dw byteMode
dw 0
dw error1
command_c_:
call cmdTable
db "ll" ; /cll clear screen
dw clearLine
db "ls" ; /cls clear screen
dw clearScreen
db "mv" ; /cmv cursor move
dw cursorMove
db "ur" ; /cur cursor show
dw cursorShow
db "go" ; /cur cursor go
dw cursorGo
dw 0
dw error1
command_d_:
call cmdTable
db "ec" ; /dec decimal
dw decBase
dw 0
dw error1
command_e_:
call cmdTable
db "ch"
dw echo
dw 0
dw error1
command_f_:
call cmdTable
db "al" ; /fal false
dw false1
db "or" ; /for forEach
dw forEach
db "re" ; /fre free memory
dw memFree
db "ra" ; /fra free memory array
dw memFreeArray
db "tr" ; /ftr filter
dw filter
db "1",0
dw f1
db "2",0
dw f2
db "3",0
dw f3
db "4",0
dw f4
dw 0
dw error1
command_h_:
call cmdTable
db "ex" ; /hex hex
dw hexBase
dw 0
dw error1
command_i_:
call cmdTable
db "n",0 ; /in input
dw input
dw 0
dw error1
command_m_:
call cmdTable
db "ap" ; /map map
dw map
db "ax" ; /max maximum
dw maximum
db "in" ; /min minimum
dw minimum
dw 0
dw error1
comand_o_:
call cmdTable
db "ut" ; /out out
dw output
dw 0
dw error1
command_r_:
jr command_r
command_s_:
jr command_s
command_t_:
jr command_t
command_v_:
jr command_v
command_w_:
jr command_w
command_x_:
jr command_x
; 3
command_default_:
jp command_default
;********************** PAGE 5 END *********************************************
; .align $100
command_r:
call cmdTable
db "ec" ; /rec tail call optimisation
dw recur
db "em" ; /rem remainder
dw remain
db "et" ; /ret return
dw return
db "ng" ; /rng range src
dw rangeSrc
dw 0
dw error1
command_s:
call cmdTable
db "bb" ; /sbb string builder begin
dw stringBegin ; /sbe string builder end
db "be"
dw stringEnd
db "cn" ; /scn scan stream
dw scan1
db "cp" ; /scp string compare
dw stringCompare
db "el" ; /sel select
dw select
db "it" ; /sit string iterator
dw stringIter
db "ln" ; /sln string length
dw stringLength
db "rc" ; /src source block* --
dw source
dw 0
dw error1
command_t:
call cmdTable
db "ru" ; /tru true
dw true1
dw 0
dw error1
command_v:
call cmdTable
db "ar" ; /var constant vars
dw vars
db "oi" ; /voi void function return
dw void
dw 0
dw error1
command_w:
call cmdTable
db "hi" ; /whi while true else break from loop
dw while
db "rd" ; /wrd word mode
dw wordMode
dw 0
dw error1
command_x:
call cmdTable
db "or" ; /xor exclsuive or
dw xor
dw 0
dw error1
command_default:
call cmdTable
dw 0
dw div
; 32
div:
pop hl ; hl = arg_b
pop de ; de = arg_a
inc bc
ld a,(bc)
cp "="
jr z,div2
dec bc ; /
ex de,hl
div2:
push af ; preserve af, bc
push bc
ld bc,hl
call divide
ex de,hl
ld (vRemain),de
pop bc ; restore
pop af
jp sub3
; /abs absolute
; num -- num
absolute:
pop hl
bit 7,h
jr z,absolute1
xor a
sub l
ld l,a
sbc a,a
sub h
ld h,a
absolute1:
push hl
jp (ix)
; /adr addrOf
; char -- addr
addrOf:
pop hl ; a = char