-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathVariableArrayFN.asm
1229 lines (1103 loc) · 65.6 KB
/
VariableArrayFN.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
;;<< VARIABLE ALLOCATION AND ASSIGNMENT
;;< DEFINT/REAL/STR, LET, DIM, ERASE
;;< (Lots more work to do here)
;;===================================
;;=clear all variables
clear_all_variables: ;{{Addr=$d5ea Code Calls/jump count: 2 Data use count: 0}}
call prob_reset_variable_linked_list_pointers;{{d5ea:cdfad5}}
ld hl,(address_after_end_of_program);{{d5ed:2a66ae}}
ld (address_of_start_of_Variables_and_DEF_FN),hl;{{d5f0:2268ae}}
ld (address_of_start_of_Arrays_area_),hl;{{d5f3:226aae}}
ld (address_of_start_of_free_space_),hl;{{d5f6:226cae}}
ret ;{{d5f9:c9}}
;;=prob reset variable linked list pointers
;zero 36h bytes at adb7
prob_reset_variable_linked_list_pointers:;{{Addr=$d5fa Code Calls/jump count: 1 Data use count: 0}}
ld hl,linked_list_headers_for_variables;{{d5fa:21b7ad}}
ld a,$36 ;{{d5fd:3e36}}
call zero_A_bytes_at_HL;{{d5ff:cd07d6}}
;;=reset array linked list headers
;zero 6 bytes at aded
reset_array_linked_list_headers: ;{{Addr=$d602 Code Calls/jump count: 1 Data use count: 0}}
ld hl,real_array_linked_list_head;{{d602:21edad}}
ld a,$06 ;{{d605:3e06}}
;;=zero A bytes at HL
zero_A_bytes_at_HL: ;{{Addr=$d607 Code Calls/jump count: 2 Data use count: 0}}
ld (hl),$00 ;{{d607:3600}}
inc hl ;{{d609:23}}
dec a ;{{d60a:3d}}
jr nz,zero_A_bytes_at_HL;{{d60b:20fa}} (-$06)
ret ;{{d60d:c9}}
;;===================================
;;=clear DEFFN list and reset variable types and pointers
clear_DEFFN_list_and_reset_variable_types_and_pointers:;{{Addr=$d60e Code Calls/jump count: 2 Data use count: 0}}
ld hl,$0000 ;{{d60e:210000}} ##LIT##
ld (DEF_FN_linked_list_head),hl;{{d611:22ebad}}
jp reset_variable_types_and_pointers;{{d614:c34dea}}
;;===================================
;;=get VarFN area and FN list head ptr
get_VarFN_area_and_FN_list_head_ptr:;{{Addr=$d617 Code Calls/jump count: 1 Data use count: 0}}
ld a,$5b ;{{d617:3e5b}} 91 Returns with HL=&ade6
;;=get VarFN area and list head ptr
;Calculates an address for a linked list header relative to &ad35
;Entry: A=a value between &41 .. &5b, i.e. one of 'A'..'Z','[' (that final entry is for DEF FNs)
;Exit: BC=addr of variables/DEF FN area -1
;HL=address (based on A) in the BASIC data area of a pointer to a linked list
;HL=&ad35 + (A*2) = (&adb7 - ('A' * 2)) + (A * 2)
;where &adb7 is the block of data for the variable linked list headers
get_VarFN_area_and_list_head_ptr: ;{{Addr=$d619 Code Calls/jump count: 3 Data use count: 0}}
ld bc,(address_of_start_of_Variables_and_DEF_FN);{{d619:ed4b68ae}}
dec bc ;{{d61d:0b}} A=&41 |&5b
add a,a ;{{d61e:87}} A=&82 |&b6 A=A*2
add a,linked_list_headers_for_variables - ('A' * 2) and $ff;{{d61e:c635}} formula version
;OLDd61f c635 add a,$35 ;A=&b7 |&eb. A=A*2+53
ld l,a ;{{d621:6f}} L=&b7 |&eb
adc a,linked_list_headers_for_variables >> 8;{{d622:cead}} formula version
;OLDd622 cead adc a,$ad ;A=&(1)64|$(1)98 (ie. carry) 173
sub l ;{{d624:95}} A=&ad |$ad
ld h,a ;{{d625:67}} HL=&adb7|&adeb
ret ;{{d626:c9}}
;;===================================
;;=get array area and array list head ptr for type
;Usually (always?) called with A=a variable data type
;Entry: A=variable data type (which equals a variable data size) = 2,3 or 5
;Exit: BC=addr of arrays area -1
;HL=address (based on A) in the BASIC data area (adef, adf1, or aded) of
;a pointer for a linked list of arrays of the given type
;Calculates: HL=&aded + (((A and 3) - 1) * 2)
get_array_area_and_array_list_head_ptr_for_type:;{{Addr=$d627 Code Calls/jump count: 6 Data use count: 0}}
ld bc,(address_of_start_of_Arrays_area_);{{d627:ed4b6aae}}
dec bc ;{{d62b:0b}} A= 2 | 3 | 5 (int|string|real)
and $03 ;{{d62c:e603}} A= 2 | 3 | 1
dec a ;{{d62e:3d}} A= 1 | 2 | 0
add a,a ;{{d62f:87}} A= 2 | 4 | 0
add a,real_array_linked_list_head and 255;{{d630:c6ed}} formula version
;OLDd630 c6ed add a,$ed ;A= $ef |$f1 |$ed I.e add a,$aded and $ff
ld l,a ;{{d632:6f}} L= $ef |$f1 |$ed
adc a,real_array_linked_list_head >> 8;{{d633:cead}} formula version
;OLDd633 cead adc a,$ad ;A= $19c |$19e |$19a (i.e. carry) I.e. adc a,&aded shr 8
sub l ;{{d635:95}} A= $ad |$ad |$ad
ld h,a ;{{d636:67}} HL=$adef|$adf1|$aded -> addresses in BASIC data area!
ret ;{{d637:c9}}
;;===================================
;;=defreal a to z
defreal_a_to_z: ;{{Addr=$d638 Code Calls/jump count: 1 Data use count: 0}}
ld bc,$415a ;{{d638:015a41}} 'A''Z' - letter range
ld e,$05 ;{{d63b:1e05}} REAL data type
;;=def letters BC to type E
;DEFs the type of a range of variables
;B=start of letter range ('A' to 'Z')
;C=end of letter range ('A' to 'Z')
;E=variable type (2,3,5)
def_letters_BC_to_type_E: ;{{Addr=$d63d Code Calls/jump count: 1 Data use count: 0}}
ld a,c ;{{d63d:79}}
sub b ;{{d63e:90}} calc number of items to set
jr c,raise_syntax_error_B;{{d63f:383d}} (+$3d)
push hl ;{{d641:e5}}
inc a ;{{d642:3c}}
ld hl,table_of_DEFINT_ - 'A';{{d643:21b2ad}} Relative to start of DEFxxxx table
ld b,$00 ;{{d646:0600}}
add hl,bc ;{{d648:09}} HL=last item in range
_def_letters_bc_to_type_e_8: ;{{Addr=$d649 Code Calls/jump count: 1 Data use count: 0}}
ld (hl),e ;{{d649:73}}
dec hl ;{{d64a:2b}}
dec a ;{{d64b:3d}}
jr nz,_def_letters_bc_to_type_e_8;{{d64c:20fb}} (-$05) Loop
pop hl ;{{d64e:e1}}
ret ;{{d64f:c9}}
;;======================================================
;; command DEFSTR
;DEFSTR <list of: <letter range>>
;where <letter range> is <letter> or <letter>-<letter>
;Defines the default type for variables starting with the given letter(s)
;Letter ranges are inclusive
command_DEFSTR: ;{{Addr=$d650 Code Calls/jump count: 0 Data use count: 1}}
ld e,$03 ;{{d650:1e03}} String type
jr do_DEFtype ;{{d652:1806}} (+$06)
;;=============================================================================
;; command DEFINT
;DEFINT <list of: <letter range>>
;As DEFSTR
command_DEFINT: ;{{Addr=$d654 Code Calls/jump count: 0 Data use count: 1}}
ld e,$02 ;{{d654:1e02}} Int type
jr do_DEFtype ;{{d656:1802}} (+$02)
;;=============================================================================
;; command DEFREAL
;DEFREAL <list of: <letter range>>
;As DEFSTR
command_DEFREAL: ;{{Addr=$d658 Code Calls/jump count: 0 Data use count: 1}}
ld e,$05 ;{{d658:1e05}} Real type
;;-----------------------------------------------------------------------------
;;=do DEFtype
do_DEFtype: ;{{Addr=$d65a Code Calls/jump count: 3 Data use count: 0}}
ld a,(hl) ;{{d65a:7e}}
call test_if_upcase_letter;{{d65b:cd92ff}} is a alphabetical letter?
jr nc,raise_syntax_error_B;{{d65e:301e}} (+$1e)
ld c,a ;{{d660:4f}}
ld b,a ;{{d661:47}}
call get_next_token_skipping_space;{{d662:cd2cde}} get next token skipping space
cp $2d ;{{d665:fe2d}} '-' - range of values
jr nz,_do_deftype_13 ;{{d667:200c}} (+$0c)
call get_next_token_skipping_space;{{d669:cd2cde}} get next token skipping space
call test_if_upcase_letter;{{d66c:cd92ff}} is a alphabetical letter?
jr nc,raise_syntax_error_B;{{d66f:300d}} (+$0d)
ld c,a ;{{d671:4f}}
call get_next_token_skipping_space;{{d672:cd2cde}} get next token skipping space
_do_deftype_13: ;{{Addr=$d675 Code Calls/jump count: 1 Data use count: 0}}
call def_letters_BC_to_type_E;{{d675:cd3dd6}}
call next_token_if_prev_is_comma;{{d678:cd41de}}
jr c,do_DEFtype ;{{d67b:38dd}} (-$23) comma = more items in list
ret ;{{d67d:c9}}
;;=raise Syntax Error
raise_syntax_error_B: ;{{Addr=$d67e Code Calls/jump count: 3 Data use count: 0}}
jp Error_Syntax_Error;{{d67e:c349cb}} Error: Syntax Error
;;=raise Subscript out of range
raise_Subscript_out_of_range: ;{{Addr=$d681 Code Calls/jump count: 3 Data use count: 0}}
call byte_following_call_is_error_code;{{d681:cd45cb}}
defb $09 ;Inline error code: Subscript out of range
;;=raise Array already dimensioned
raise_Array_already_dimensioned: ;{{Addr=$d685 Code Calls/jump count: 1 Data use count: 0}}
call byte_following_call_is_error_code;{{d685:cd45cb}}
defb $0a ;Inline error code: Array already dimensioned
;;========================================================================
;; BAR command or implicit LET
BAR_command_or_implicit_LET: ;{{Addr=$d689 Code Calls/jump count: 1 Data use count: 0}}
cp $f8 ;{{d689:fef8}} '|'
jp z,BAR_command ;{{d68b:ca45f2}}
;;========================================================================
;; command LET
;LET <variable>=<expression>
;Assign a value to a variable
command_LET: ;{{Addr=$d68e Code Calls/jump count: 0 Data use count: 1}}
call parse_and_find_or_create_a_var;{{d68e:cdbfd6}} Find (or alloc) the variables
push de ;{{d691:d5}} Preserve address(?)
call next_token_if_equals_sign;{{d692:cd21de}} Test for '=' sign
call eval_expression ;{{d695:cd62cf}} Evaluate the new value
ld a,b ;{{d698:78}}
ex (sp),hl ;{{d699:e3}} Retrieve the address
call copy_accumulator_to_atHL_as_type_B;{{d69a:cd9fd6}} Store the new value (also stores a string if appropriate)
pop hl ;{{d69d:e1}} Retrieve code pointer
ret ;{{d69e:c9}}
;;=copy accumulator to atHL as type B
copy_accumulator_to_atHL_as_type_B:;{{Addr=$d69f Code Calls/jump count: 3 Data use count: 0}}
ld b,a ;{{d69f:47}}
call get_accumulator_data_type;{{d6a0:cd4bff}}
cp b ;{{d6a3:b8}}
ld a,b ;{{d6a4:78}}
call nz,convert_accumulator_to_type_in_A;{{d6a5:c4fffe}}
;;=copy accumulator to atHL
copy_accumulator_to_atHL: ;{{Addr=$d6a8 Code Calls/jump count: 1 Data use count: 0}}
call is_accumulator_a_string;{{d6a8:cd66ff}}
jp nz,copy_numeric_accumulator_to_atHL;{{d6ab:c283ff}} It's a number
push hl ;{{d6ae:e5}} Otherwise it's a string
call prob_copy_to_strings_area_if_not_const_in_program_or_ROM;{{d6af:cd94fb}} Store string to strings area
pop de ;{{d6b2:d1}}
jp copy_value_atHL_to_atDE_accumulator_type;{{d6b3:c387ff}}
;;========================================================================
;; command DIM
;DIM <list of: <subscripted variable>>
;Where <subscripted variable> is <variable name>(<dimension list>)
;and <dimension list> is <list of: <integer expression>>
;Declare array dimensions
command_DIM: ;{{Addr=$d6b6 Code Calls/jump count: 1 Data use count: 1}}
call do_DIM_item ;{{d6b6:cde0d7}}
call next_token_if_prev_is_comma;{{d6b9:cd41de}}
jr c,command_DIM ;{{d6bc:38f8}} (-$08) Comma = more items in list
ret ;{{d6be:c9}}
;;===================================================
;The variable/array/deffn token is followed by a pointer into the variables/arrays/deffn area.
;At reset this value is cleared to zero. Here we read the value. If it's set then add it to the base address,
;if not the search the relevant linked list to: find it; store the found value (and possibly clarify the variables type);
;(depeding on the routine) allocate space if the item isn't already created.
;;=parse and find or create a var
;Returns DE = address of variables value
parse_and_find_or_create_a_var: ;{{Addr=$d6bf Code Calls/jump count: 7 Data use count: 0}}
call parse_var_type_and_name;{{d6bf:cd31d9}}
call convert_var_or_array_offset_into_address;{{d6c2:cd06d8}}
jr c,get_accum_data_type_in_A_B_and_C;{{d6c5:3842}} (+$42) variable offset set -> return
jr find_var_and_alloc_if_not_found;{{d6c7:1828}} (+$28) variable offset not set -> find (and maybe alloc)
;;=parse and find var
parse_and_find_var: ;{{Addr=$d6c9 Code Calls/jump count: 2 Data use count: 0}}
call parse_var_type_and_name;{{d6c9:cd31d9}}
call convert_var_or_array_offset_into_address;{{d6cc:cd06d8}}
jr c,get_accum_data_type_in_A_B_and_C;{{d6cf:3838}} (+$38) variable offset set -> return
push hl ;{{d6d1:e5}}
ld a,c ;{{d6d2:79}}
call get_VarFN_area_and_list_head_ptr;{{d6d3:cd19d6}} search list of vars (list depends on type)
call find_var_in_FN_or_var_linked_lists;{{d6d6:cd17d7}}
jr pop_hl_and_get_accum_data_type_in_A_B_and_C_;{{d6d9:182d}} (+$2d) return
;;=parse and find or create an FN
parse_and_find_or_create_an_FN: ;{{Addr=$d6db Code Calls/jump count: 2 Data use count: 0}}
call parse_var_type_and_name;{{d6db:cd31d9}}
jr c,add_offset_to_addr_in_var_FN_area;{{d6de:3821}} (+$21) variable offset set -> add offset and return
push hl ;{{d6e0:e5}}
call get_VarFN_area_and_FN_list_head_ptr;{{d6e1:cd17d6}} search list of DEF FNs
call _prob_find_item_in_linked_list_2;{{d6e4:cd32d7}}
call nc,prob_alloc_space_for_a_DEF_FN;{{d6e7:d46fd7}} not found - alloc
jr pop_hl_and_get_accum_data_type_in_A_B_and_C_;{{d6ea:181c}} (+$1c)
;;=parse and find or alloc FOR var
parse_and_find_or_alloc_FOR_var: ;{{Addr=$d6ec Code Calls/jump count: 1 Data use count: 0}}
call parse_var_type_and_name;{{d6ec:cd31d9}}
jr c,add_offset_to_addr_in_var_FN_area;{{d6ef:3810}} (+$10) variable offset set -> return
;;=find var and alloc if not found
find_var_and_alloc_if_not_found: ;{{Addr=$d6f1 Code Calls/jump count: 1 Data use count: 0}}
push hl ;{{d6f1:e5}}
ld a,c ;{{d6f2:79}}
call get_VarFN_area_and_list_head_ptr;{{d6f3:cd19d6}} search list of variables (list depends on type)
call find_var_in_FN_or_var_linked_lists;{{d6f6:cd17d7}}
ld a,(accumulator_data_type);{{d6f9:3a9fb0}}
call nc,prob_alloc_space_for_new_var;{{d6fc:d47bd7}} not found - alloc
jr pop_hl_and_get_accum_data_type_in_A_B_and_C_;{{d6ff:1807}} (+$07)
;;=add offset to addr in var FN area
add_offset_to_addr_in_var_FN_area:;{{Addr=$d701 Code Calls/jump count: 2 Data use count: 0}}
push hl ;{{d701:e5}}
ld hl,(address_of_start_of_Variables_and_DEF_FN);{{d702:2a68ae}}
dec hl ;{{d705:2b}}
add hl,de ;{{d706:19}}
ex de,hl ;{{d707:eb}}
;;=pop hl and get accum data type in A B and C
pop_hl_and_get_accum_data_type_in_A_B_and_C_:;{{Addr=$d708 Code Calls/jump count: 3 Data use count: 0}}
pop hl ;{{d708:e1}}
;;=get accum data type in A B and C
get_accum_data_type_in_A_B_and_C: ;{{Addr=$d709 Code Calls/jump count: 3 Data use count: 0}}
ld a,(accumulator_data_type);{{d709:3a9fb0}}
ld b,a ;{{d70c:47}}
ld c,a ;{{d70d:4f}}
ret ;{{d70e:c9}}
;;============================
;;prob just skip over variable
prob_just_skip_over_variable: ;{{Addr=$d70f Code Calls/jump count: 1 Data use count: 0}}
call parse_var_type_and_name;{{d70f:cd31d9}}
call skip_over_matched_braces;{{d712:cd7ae9}}
jr get_accum_data_type_in_A_B_and_C;{{d715:18f2}} (-$0e)
;;==================================
;;=find var in FN or var linked lists
;Appears to check multiple lists? Maybe depends on variable type
find_var_in_FN_or_var_linked_lists:;{{Addr=$d717 Code Calls/jump count: 2 Data use count: 0}}
push de ;{{d717:d5}}
push hl ;{{d718:e5}}
ld hl,(FN_param_end) ;{{d719:2a12ae}} Are we in an FN?
ld a,h ;{{d71c:7c}}
or l ;{{d71d:b5}}
jr z,prob_find_item_in_linked_list;{{d71e:2810}} (+$10) Nope - just check regular variables
inc hl ;{{d720:23}} otherwise check variable linked list for the FN...
inc hl ;{{d721:23}}
push bc ;{{d722:c5}}
ld bc,$0000 ;{{d723:010000}} which uses an absolute address (well, an offset from zero) ##LIT##
call find_named_item_in_linked_list;{{d726:cd40d7}}
pop bc ;{{d729:c1}} and then check the regular variable linked list
jr nc,prob_find_item_in_linked_list;{{d72a:3004}} (+$04)
pop af ;{{d72c:f1}}
pop af ;{{d72d:f1}}
scf ;{{d72e:37}}
ret ;{{d72f:c9}}
;;=prob find item in linked list
;finds an item within a single list
prob_find_item_in_linked_list: ;{{Addr=$d730 Code Calls/jump count: 2 Data use count: 0}}
pop hl ;{{d730:e1}}
pop de ;{{d731:d1}}
_prob_find_item_in_linked_list_2: ;{{Addr=$d732 Code Calls/jump count: 1 Data use count: 0}}
push de ;{{d732:d5}} this entry point searches DEF FNs list
push hl ;{{d733:e5}}
call find_named_item_in_linked_list;{{d734:cd40d7}}
pop hl ;{{d737:e1}}
jr c,_prob_find_item_in_linked_list_9;{{d738:3802}} (+$02)
pop de ;{{d73a:d1}}
ret ;{{d73b:c9}}
_prob_find_item_in_linked_list_9: ;{{Addr=$d73c Code Calls/jump count: 1 Data use count: 0}}
pop hl ;{{d73c:e1}}
jp prob_store_offset_into_code;{{d73d:c39ed7}}
;;==================================
;;find named item in linked list
;BC=start of linked list
;HL=ptr to offset into list - item is at BC + (HL)
;($AE0E) addr of ASCIIZ name to compare to
;Type must match that of the accumulator
;EXIT: Carry set if item found
;(If found):
;HL = address of start of item
;DE = address of items data area (address after type specifier)
;Table format:
;Word: Offset (from BC) of next item in table (or zero if end of list)
;ASCIIZ string: item name
;Byte: Item type (2/3/5)
;Data area
find_named_item_in_linked_list: ;{{Addr=$d740 Code Calls/jump count: 6 Data use count: 0}}
ld a,(hl) ;{{d740:7e}}
inc hl ;{{d741:23}}
ld h,(hl) ;{{d742:66}}
ld l,a ;{{d743:6f}}
or h ;{{d744:b4}}
ret z ;{{d745:c8}} Offset? is zero - end of list (or empty list)
add hl,bc ;{{d746:09}} Add offset to start of table
push hl ;{{d747:e5}}
inc hl ;{{d748:23}} Step over (pointer) to string (var name)
inc hl ;{{d749:23}} Ptr = offset of next item?
ld de,(poss_cached_addrvariable_name_address_o);{{d74a:ed5b0eae}} Address of another string
_find_named_item_in_linked_list_11:;{{Addr=$d74e Code Calls/jump count: 1 Data use count: 0}}
ld a,(de) ;{{d74e:1a}} Compare ASCII7 string at HL to that at DE
cp (hl) ;{{d74f:be}}
jr nz,_find_named_item_in_linked_list_23;{{d750:200d}} (+$0d) Char doesn't match - fail
inc hl ;{{d752:23}} Next char
inc de ;{{d753:13}}
rla ;{{d754:17}} Is bit 7 set?
jr nc,_find_named_item_in_linked_list_11;{{d755:30f7}} (-$09) Loop for next char if not
ld a,(accumulator_data_type);{{d757:3a9fb0}} Does the type also match?
dec a ;{{d75a:3d}}
xor (hl) ;{{d75b:ae}}
and $07 ;{{d75c:e607}}
ex de,hl ;{{d75e:eb}}
_find_named_item_in_linked_list_23:;{{Addr=$d75f Code Calls/jump count: 1 Data use count: 0}}
pop hl ;{{d75f:e1}} Retrieve start address of item = ptr to next item
jr nz,find_named_item_in_linked_list;{{d760:20de}} (-$22) Not a match, loop.
inc de ;{{d762:13}} DE = ptr to the items data
scf ;{{d763:37}}
ret ;{{d764:c9}}
;;=poss step over string
poss_step_over_string: ;{{Addr=$d765 Code Calls/jump count: 3 Data use count: 0}}
ld d,h ;{{d765:54}}
ld e,l ;{{d766:5d}}
inc hl ;{{d767:23}}
inc hl ;{{d768:23}}
_poss_step_over_string_4: ;{{Addr=$d769 Code Calls/jump count: 1 Data use count: 0}}
bit 7,(hl) ;{{d769:cb7e}}
inc hl ;{{d76b:23}}
jr z,_poss_step_over_string_4;{{d76c:28fb}} (-$05)
ret ;{{d76e:c9}}
;;=prob alloc space for a DEF FN
prob_alloc_space_for_a_DEF_FN: ;{{Addr=$d76f Code Calls/jump count: 1 Data use count: 0}}
ld a,$02 ;{{d76f:3e02}}
call prob_alloc_space_for_new_var;{{d771:cd7bd7}}
dec de ;{{d774:1b}}
ld a,(de) ;{{d775:1a}}
or $40 ;{{d776:f640}}
ld (de),a ;{{d778:12}}
inc de ;{{d779:13}}
ret ;{{d77a:c9}}
;;=prob alloc space for new var
prob_alloc_space_for_new_var: ;{{Addr=$d77b Code Calls/jump count: 2 Data use count: 0}}
push de ;{{d77b:d5}}
push hl ;{{d77c:e5}}
push bc ;{{d77d:c5}}
push af ;{{d77e:f5}}
call count_length_of_cached_string;{{d77f:cda8d7}}
push af ;{{d782:f5}}
ld hl,(address_of_start_of_Arrays_area_);{{d783:2a6aae}}
ex de,hl ;{{d786:eb}}
call move_lower_memory_up;{{d787:cdb8f6}}
call prob_grow_variables_space_ptrs_by_BC;{{d78a:cd1af6}}
pop af ;{{d78d:f1}}
call copy_cached_string_and_store_data_type;{{d78e:cdb8d7}}
pop bc ;{{d791:c1}}
xor a ;{{d792:af}} Zero B bytes
_prob_alloc_space_for_new_var_14: ;{{Addr=$d793 Code Calls/jump count: 1 Data use count: 0}}
dec hl ;{{d793:2b}}
ld (hl),a ;{{d794:77}}
djnz _prob_alloc_space_for_new_var_14;{{d795:10fc}} (-$04)
pop bc ;{{d797:c1}}
ex (sp),hl ;{{d798:e3}}
call poss_update_list_headers;{{d799:cdd0d7}}
pop de ;{{d79c:d1}}
pop hl ;{{d79d:e1}}
;;=prob store offset into code
;stores the newly found/created variable/fn/array offset into the code where it is referenced
prob_store_offset_into_code: ;{{Addr=$d79e Code Calls/jump count: 3 Data use count: 0}}
inc hl ;{{d79e:23}}
ld a,e ;{{d79f:7b}}
sub c ;{{d7a0:91}}
ld (hl),a ;{{d7a1:77}}
inc hl ;{{d7a2:23}}
ld a,d ;{{d7a3:7a}}
sbc a,b ;{{d7a4:98}}
ld (hl),a ;{{d7a5:77}}
scf ;{{d7a6:37}}
ret ;{{d7a7:c9}}
;;=count length of cached string
count_length_of_cached_string: ;{{Addr=$d7a8 Code Calls/jump count: 2 Data use count: 0}}
add a,$03 ;{{d7a8:c603}}
ld c,a ;{{d7aa:4f}}
ld hl,(poss_cached_addrvariable_name_address_o);{{d7ab:2a0eae}} Address of cached string
xor a ;{{d7ae:af}} Count length of string
ld b,a ;{{d7af:47}}
_count_length_of_cached_string_5: ;{{Addr=$d7b0 Code Calls/jump count: 1 Data use count: 0}}
inc bc ;{{d7b0:03}}
inc a ;{{d7b1:3c}}
bit 7,(hl) ;{{d7b2:cb7e}}
inc hl ;{{d7b4:23}}
jr z,_count_length_of_cached_string_5;{{d7b5:28f9}} (-$07)
ret ;{{d7b7:c9}}
;;=copy cached string and store data type
copy_cached_string_and_store_data_type:;{{Addr=$d7b8 Code Calls/jump count: 2 Data use count: 0}}
ld h,d ;{{d7b8:62}}
ld l,e ;{{d7b9:6b}}
add hl,bc ;{{d7ba:09}}
push hl ;{{d7bb:e5}}
push de ;{{d7bc:d5}}
inc de ;{{d7bd:13}}
inc de ;{{d7be:13}}
ld hl,(poss_cached_addrvariable_name_address_o);{{d7bf:2a0eae}}
call copy_bytes_LDIR__Acount_HLsource_DEdest;{{d7c2:cdecff}} ; copy bytes (A=count, HL=source, DE=dest)
ld a,(accumulator_data_type);{{d7c5:3a9fb0}}
dec a ;{{d7c8:3d}}
ld (de),a ;{{d7c9:12}}
inc de ;{{d7ca:13}}
ld b,d ;{{d7cb:42}}
ld c,e ;{{d7cc:4b}}
pop de ;{{d7cd:d1}}
pop hl ;{{d7ce:e1}}
ret ;{{d7cf:c9}}
;;=poss update list headers
poss_update_list_headers: ;{{Addr=$d7d0 Code Calls/jump count: 4 Data use count: 0}}
ld a,(hl) ;{{d7d0:7e}}
ld (de),a ;{{d7d1:12}}
ld a,e ;{{d7d2:7b}}
sub c ;{{d7d3:91}}
ld (hl),a ;{{d7d4:77}}
inc hl ;{{d7d5:23}}
ld a,(hl) ;{{d7d6:7e}}
push af ;{{d7d7:f5}}
ld a,d ;{{d7d8:7a}}
sbc a,b ;{{d7d9:98}}
ld (hl),a ;{{d7da:77}}
pop af ;{{d7db:f1}}
inc de ;{{d7dc:13}}
ld (de),a ;{{d7dd:12}}
inc de ;{{d7de:13}}
ret ;{{d7df:c9}}
;;==================================
;;do DIM item
do_DIM_item: ;{{Addr=$d7e0 Code Calls/jump count: 1 Data use count: 0}}
call parse_var_type_and_name;{{d7e0:cd31d9}} skip over the array name...
ld a,(hl) ;{{d7e3:7e}} ...and we should have an open brace (either type)
cp $28 ;{{d7e4:fe28}} '('
jr z,_do_dim_item_6 ;{{d7e6:2805}} (+$05)
xor $5b ;{{d7e8:ee5b}} '['
jp nz,Error_Syntax_Error;{{d7ea:c249cb}} Error: Syntax Error
_do_dim_item_6: ;{{Addr=$d7ed Code Calls/jump count: 1 Data use count: 0}}
call read_array_dimensions;{{d7ed:cd83d8}}
push hl ;{{d7f0:e5}}
push bc ;{{d7f1:c5}}
ld a,(accumulator_data_type);{{d7f2:3a9fb0}}
call get_array_area_and_array_list_head_ptr_for_type;{{d7f5:cd27d6}} Is the array already dimmed? Go look for it
call find_named_item_in_linked_list;{{d7f8:cd40d7}}
jp c,raise_Array_already_dimensioned;{{d7fb:da85d6}} if so, error
pop bc ;{{d7fe:c1}}
ld a,$ff ;{{d7ff:3eff}}
call create_and_alloc_space_for_array;{{d801:cdb3d8}} and create it
pop hl ;{{d804:e1}}
ret ;{{d805:c9}}
;;=convert var or array offset into address
;allocates space for array if needed
;Entry: DE=offset into variables or arrays tables, unless:
;Carry set if the address has stored in the code, and DE = offset of element
;Exit: DE=absolute address of var/FN/array element data
convert_var_or_array_offset_into_address:;{{Addr=$d806 Code Calls/jump count: 2 Data use count: 0}}
push af ;{{d806:f5}}
ld a,(hl) ;{{d807:7e}} token after variable name/type
cp $28 ;{{d808:fe28}} '('
jr z,get_array_element_address;{{d80a:2810}} (+$10)
xor $5b ;{{d80c:ee5b}} '['
jr z,get_array_element_address;{{d80e:280c}} (+$0c)
pop af ;{{d810:f1}}
ret nc ;{{d811:d0}}
push hl ;{{d812:e5}} variable of FN
ld hl,(address_of_start_of_Variables_and_DEF_FN);{{d813:2a68ae}}
dec hl ;{{d816:2b}}
add hl,de ;{{d817:19}}
ex de,hl ;{{d818:eb}}
pop hl ;{{d819:e1}}
scf ;{{d81a:37}}
ret ;{{d81b:c9}}
;;=get array element address
;allocates space for array if needed
get_array_element_address: ;{{Addr=$d81c Code Calls/jump count: 2 Data use count: 0}}
call read_array_dimensions;{{d81c:cd83d8}} push array dimensions onto execution stack;count in B
pop af ;{{d81f:f1}}
push hl ;{{d820:e5}}
jr nc,_get_array_element_address_8;{{d821:3007}} (+$07)
ld hl,(address_of_start_of_Arrays_area_);{{d823:2a6aae}} address stored in code (which means it's a constant value??)
dec hl ;{{d826:2b}}
add hl,de ;{{d827:19}} get absolute address
jr _get_array_element_address_20;{{d828:1815}} (+$15)
_get_array_element_address_8: ;{{Addr=$d82a Code Calls/jump count: 1 Data use count: 0}}
push bc ;{{d82a:c5}}
push de ;{{d82b:d5}}
ld a,(accumulator_data_type);{{d82c:3a9fb0}}
call get_array_area_and_array_list_head_ptr_for_type;{{d82f:cd27d6}} try and find the array
call find_named_item_in_linked_list;{{d832:cd40d7}}
jr nc,_get_array_element_address_24;{{d835:300f}} (+$0f) not found - create it
inc de ;{{d837:13}}
inc de ;{{d838:13}}
pop hl ;{{d839:e1}}
call prob_store_offset_into_code;{{d83a:cd9ed7}}
pop bc ;{{d83d:c1}}
ex de,hl ;{{d83e:eb}}
_get_array_element_address_20: ;{{Addr=$d83f Code Calls/jump count: 1 Data use count: 0}}
ld a,b ;{{d83f:78}} number of dimensions
sub (hl) ;{{d840:96}} compare with stored value
jp nz,raise_Subscript_out_of_range;{{d841:c281d6}}
jr _get_array_element_address_30;{{d844:180a}} (+$0a)
_get_array_element_address_24: ;{{Addr=$d846 Code Calls/jump count: 1 Data use count: 0}}
pop hl ;{{d846:e1}} create array
pop bc ;{{d847:c1}}
xor a ;{{d848:af}}
call create_and_alloc_space_for_array;{{d849:cdb3d8}}
call prob_store_offset_into_code;{{d84c:cd9ed7}}
ex de,hl ;{{d84f:eb}}
_get_array_element_address_30: ;{{Addr=$d850 Code Calls/jump count: 1 Data use count: 0}}
ld de,$0000 ;{{d850:110000}} we now have the address of the array ##LIT##
ld b,(hl) ;{{d853:46}} get number of dimensions
inc hl ;{{d854:23}} point to size of first dimension
_get_array_element_address_33: ;{{Addr=$d855 Code Calls/jump count: 1 Data use count: 0}}
push hl ;{{d855:e5}} read size of dimension
push de ;{{d856:d5}}
ld e,(hl) ;{{d857:5e}}
inc hl ;{{d858:23}}
ld d,(hl) ;{{d859:56}}
call pop_word_off_execution_stack;{{d85a:cd27d9}} pop index into dimension
call compare_HL_DE ;{{d85d:cdd8ff}} HL=DE? validate
jp nc,raise_Subscript_out_of_range;{{d860:d281d6}} index * size of dimension?
ex (sp),hl ;{{d863:e3}}
call do_16x16_multiply_with_overflow;{{d864:cd72dd}}
pop de ;{{d867:d1}}
add hl,de ;{{d868:19}} add to offset -> new offset
ex de,hl ;{{d869:eb}}
pop hl ;{{d86a:e1}}
inc hl ;{{d86b:23}}
inc hl ;{{d86c:23}}
djnz _get_array_element_address_33;{{d86d:10e6}} (-$1a) loop for more dimensions
ex de,hl ;{{d86f:eb}}
ld b,h ;{{d870:44}} Multiply index by element size
ld c,l ;{{d871:4d}}
ld a,(accumulator_data_type);{{d872:3a9fb0}}
sub $03 ;{{d875:d603}}
jr c,_get_array_element_address_59;{{d877:3804}} (+$04)
add hl,hl ;{{d879:29}}
jr z,_get_array_element_address_59;{{d87a:2801}} (+$01)
add hl,hl ;{{d87c:29}}
_get_array_element_address_59: ;{{Addr=$d87d Code Calls/jump count: 2 Data use count: 0}}
add hl,bc ;{{d87d:09}}
add hl,de ;{{d87e:19}}
ex de,hl ;{{d87f:eb}}
pop hl ;{{d880:e1}}
scf ;{{d881:37}}
ret ;{{d882:c9}}
;;=read array dimensions
;reads array dimensions and pushes them onto the execution stack
;B returns the number of dimensions
read_array_dimensions: ;{{Addr=$d883 Code Calls/jump count: 2 Data use count: 0}}
push de ;{{d883:d5}}
call get_next_token_skipping_space;{{d884:cd2cde}} get next token skipping space
ld a,(accumulator_data_type);{{d887:3a9fb0}}
push af ;{{d88a:f5}}
ld b,$00 ;{{d88b:0600}} B=number of dimensions
_read_array_dimensions_5: ;{{Addr=$d88d Code Calls/jump count: 1 Data use count: 0}}
call eval_expr_as_positive_int_or_error;{{d88d:cdcece}} Read value
push hl ;{{d890:e5}}
ld a,$02 ;{{d891:3e02}} push value onto the execution stack
call possibly_alloc_A_bytes_on_execution_stack;{{d893:cd72f6}}
ld (hl),e ;{{d896:73}}
inc hl ;{{d897:23}}
ld (hl),d ;{{d898:72}}
pop hl ;{{d899:e1}}
inc b ;{{d89a:04}} inc dimension counter
call next_token_if_prev_is_comma;{{d89b:cd41de}} any more?
jr c,_read_array_dimensions_5;{{d89e:38ed}} (-$13) if so, loop
ld a,(hl) ;{{d8a0:7e}} finish list with brackets of either type
cp $29 ;{{d8a1:fe29}} ')'
jr z,_read_array_dimensions_21;{{d8a3:2805}} (+$05)
cp $5d ;{{d8a5:fe5d}} ']'
jp nz,Error_Syntax_Error;{{d8a7:c249cb}} otherwise, Error: Syntax Error
_read_array_dimensions_21: ;{{Addr=$d8aa Code Calls/jump count: 1 Data use count: 0}}
call get_next_token_skipping_space;{{d8aa:cd2cde}} get next token skipping space
pop af ;{{d8ad:f1}}
ld (accumulator_data_type),a;{{d8ae:329fb0}}
pop de ;{{d8b1:d1}}
ret ;{{d8b2:c9}}
;;=create and alloc space for array
;A=dimensions flag: $00=we're creating the array from a DIM statement and the dimensions are on the execution stack
; $ff=we're creating a 'default' 10 item array due to the array being used,
;B=number of dimensions
;If A=$00 then the array bounds (dimensions) are pushed on the execution stack
create_and_alloc_space_for_array: ;{{Addr=$d8b3 Code Calls/jump count: 2 Data use count: 0}}
push hl ;{{d8b3:e5}}
ld (array_creation_flag_),a;{{d8b4:320dae}}
push bc ;{{d8b7:c5}}
ld a,b ;{{d8b8:78}}
add a,a ;{{d8b9:87}}
add a,$03 ;{{d8ba:c603}}
call count_length_of_cached_string;{{d8bc:cda8d7}}
push af ;{{d8bf:f5}}
ld hl,(address_of_start_of_free_space_);{{d8c0:2a6cae}}
ex de,hl ;{{d8c3:eb}}
call move_lower_memory_up;{{d8c4:cdb8f6}} Move data up out of the way
pop af ;{{d8c7:f1}}
call copy_cached_string_and_store_data_type;{{d8c8:cdb8d7}} Copy/store array name and type
ld h,b ;{{d8cb:60}}
ld l,c ;{{d8cc:69}}
pop bc ;{{d8cd:c1}}
push de ;{{d8ce:d5}}
inc hl ;{{d8cf:23}}
inc hl ;{{d8d0:23}}
ld a,(accumulator_data_type);{{d8d1:3a9fb0}}
ld e,a ;{{d8d4:5f}}
ld d,$00 ;{{d8d5:1600}}
ld (hl),b ;{{d8d7:70}} number of dimensions (and loop counter)
push hl ;{{d8d8:e5}}
inc hl ;{{d8d9:23}}
_create_and_alloc_space_for_array_25:;{{Addr=$d8da Code Calls/jump count: 1 Data use count: 0}}
push de ;{{d8da:d5}} Loop for each dimension
ld a,(array_creation_flag_);{{d8db:3a0dae}}
or a ;{{d8de:b7}}
ld de,$000a ;{{d8df:110a00}}
ex de,hl ;{{d8e2:eb}}
call nz,pop_word_off_execution_stack;{{d8e3:c427d9}} pop size of this dimension
ex de,hl ;{{d8e6:eb}}
inc de ;{{d8e7:13}}
ld (hl),e ;{{d8e8:73}} store dimension size
inc hl ;{{d8e9:23}}
ld (hl),d ;{{d8ea:72}}
inc hl ;{{d8eb:23}}
ex (sp),hl ;{{d8ec:e3}}
call do_16x16_multiply_with_overflow;{{d8ed:cd72dd}} size of this dimension?
jp c,raise_Subscript_out_of_range;{{d8f0:da81d6}}
ex de,hl ;{{d8f3:eb}}
pop hl ;{{d8f4:e1}}
djnz _create_and_alloc_space_for_array_25;{{d8f5:10e3}} (-$1d) loop for more dimensions
ld b,d ;{{d8f7:42}} Restore the following memory
ld c,e ;{{d8f8:4b}}
ld d,h ;{{d8f9:54}}
ld e,l ;{{d8fa:5d}}
call _move_lower_memory_up_1;{{d8fb:cdbbf6}}
ld (address_of_start_of_free_space_),hl;{{d8fe:226cae}}
push bc ;{{d901:c5}} Clear BC bytes of memory - cleanup? zero allocated space?
_create_and_alloc_space_for_array_50:;{{Addr=$d902 Code Calls/jump count: 1 Data use count: 0}}
dec hl ;{{d902:2b}}
ld (hl),$00 ;{{d903:3600}}
dec bc ;{{d905:0b}}
ld a,b ;{{d906:78}}
or c ;{{d907:b1}}
jr nz,_create_and_alloc_space_for_array_50;{{d908:20f8}} (-$08)
pop bc ;{{d90a:c1}}
pop hl ;{{d90b:e1}}
ld e,(hl) ;{{d90c:5e}}
ld d,a ;{{d90d:57}}
ex de,hl ;{{d90e:eb}}
add hl,hl ;{{d90f:29}}
inc hl ;{{d910:23}}
add hl,bc ;{{d911:09}}
ex de,hl ;{{d912:eb}}
dec hl ;{{d913:2b}}
dec hl ;{{d914:2b}}
ld (hl),e ;{{d915:73}} store pointer to next item in list?
inc hl ;{{d916:23}}
ld (hl),d ;{{d917:72}}
inc hl ;{{d918:23}}
ex (sp),hl ;{{d919:e3}}
ex de,hl ;{{d91a:eb}}
ld a,(accumulator_data_type);{{d91b:3a9fb0}}
call get_array_area_and_array_list_head_ptr_for_type;{{d91e:cd27d6}}
call poss_update_list_headers;{{d921:cdd0d7}} and update list header?
pop de ;{{d924:d1}}
pop hl ;{{d925:e1}}
ret ;{{d926:c9}}
;;=pop word off execution stack
pop_word_off_execution_stack: ;{{Addr=$d927 Code Calls/jump count: 2 Data use count: 0}}
ld a,$02 ;{{d927:3e02}}
call probably_remove_A_bytes_off_execution_stack_and_get_address;{{d929:cd62f6}}
ld a,(hl) ;{{d92c:7e}}
inc hl ;{{d92d:23}}
ld h,(hl) ;{{d92e:66}}
ld l,a ;{{d92f:6f}}
ret ;{{d930:c9}}
;;=================================
;;parse var type and name
;if the offset is set within the variables token data, returns it in DE and skips over the name,
;otherwise copies the variables name onto the execution stack and sets (&ae0e) to point to the first char,
;and returns the first letter in uppercase in C
;Carry set if we're returning the offset.
;Entry: HL=pointer to variable definition, token data
;Exit:DE=value (offset)
;C=first letter of name converted to upper case
;Carry set if offset found
parse_var_type_and_name: ;{{Addr=$d931 Code Calls/jump count: 7 Data use count: 0}}
call set_accum_type_from_variable_type_atHL;{{d931:cdafd9}} Set accumulator to match variable token type
inc hl ;{{d934:23}}
ld e,(hl) ;{{d935:5e}} read var offset into DE
inc hl ;{{d936:23}}
ld d,(hl) ;{{d937:56}}
ld a,d ;{{d938:7a}}
or e ;{{d939:b3}}
jr z,copy_var_name_onto_exec_stack;{{d93a:280a}} (+$0a) if offset is zero we need to find offset
_parse_var_type_and_name_8: ;{{Addr=$d93c Code Calls/jump count: 1 Data use count: 0}}
inc hl ;{{d93c:23}} skip over var name (ends with bit 7 set)
ld a,(hl) ;{{d93d:7e}}
rla ;{{d93e:17}}
jr nc,_parse_var_type_and_name_8;{{d93f:30fb}} (-$05)
call get_next_token_skipping_space;{{d941:cd2cde}} get next token skipping space
scf ;{{d944:37}}
ret ;{{d945:c9}}
;;=copy var name onto exec stack
;;Parse variable name onto execution stack, set (AE0E) as a poiner to it
;Exit: C=first letter of name converted to uppercase
copy_var_name_onto_exec_stack: ;{{Addr=$d946 Code Calls/jump count: 1 Data use count: 0}}
dec hl ;{{d946:2b}}
dec hl ;{{d947:2b}} HL now ponts to variable type token
ex de,hl ;{{d948:eb}}
pop bc ;{{d949:c1}}
ld hl,(poss_cached_addrvariable_name_address_o);{{d94a:2a0eae}} Old top of execution stack?
push hl ;{{d94d:e5}}
ld hl,_copy_var_name_onto_exec_stack_15;{{d94e:215ed9}} ##LABEL##
push hl ;{{d951:e5}} !!!Push code address onto stack - not sure where this comes out!!!
push bc ;{{d952:c5}}
ex de,hl ;{{d953:eb}}
push hl ;{{d954:e5}}
call copy_var_name_onto_execution_stack;{{d955:cd6cd9}}
ld (poss_cached_addrvariable_name_address_o),de;{{d958:ed530eae}}
pop de ;{{d95c:d1}}
ret ;{{d95d:c9}}
_copy_var_name_onto_exec_stack_15:;{{Addr=$d95e Code Calls/jump count: 0 Data use count: 1}}
push hl ;{{d95e:e5}}
ld hl,(poss_cached_addrvariable_name_address_o);{{d95f:2a0eae}}
call set_execution_stack_next_free_ptr;{{d962:cd6ef6}}
pop hl ;{{d965:e1}}
ex (sp),hl ;{{d966:e3}}
ld (poss_cached_addrvariable_name_address_o),hl;{{d967:220eae}}
pop hl ;{{d96a:e1}}
ret ;{{d96b:c9}}
;;=======================================
;;=copy var name onto execution stack
;Entry: DE=address of a variable type token
;Exit: C=first letter of name converted to uppercase
copy_var_name_onto_execution_stack:;{{Addr=$d96c Code Calls/jump count: 2 Data use count: 0}}
push hl ;{{d96c:e5}}
ld a,(hl) ;{{d96d:7e}} Get var type
inc hl ;{{d96e:23}}
inc hl ;{{d96f:23}}
inc hl ;{{d970:23}} HL=pointer to var name
ld c,(hl) ;{{d971:4e}} First char of name
res 5,c ;{{d972:cba9}} To upper case
ex (sp),hl ;{{d974:e3}}
cp $0b ;{{d975:fe0b}}
jr c,do_the_name_copying;{{d977:3817}} (+$17) variable type is known
;establish the variables type ... and poke that into the variables token data
ld a,c ;{{d979:79}} Get index into DEFtype table...
and $1f ;{{d97a:e61f}}
add a,$f2 ;{{d97c:c6f2}} ...which starts at ADF3
ld e,a ;{{d97e:5f}}
adc a,$ad ;{{d97f:cead}}
sub e ;{{d981:93}}
ld d,a ;{{d982:57}}
ld a,(de) ;{{d983:1a}} Type from DEFtype table
ld (accumulator_data_type),a;{{d984:329fb0}}
ld (hl),$0d ;{{d987:360d}} Set the vars type as real/unspecified
cp $05 ;{{d989:fe05}} Real?
jr z,do_the_name_copying;{{d98b:2803}} (+$03)
add a,$09 ;{{d98d:c609}} Set the variables type (as no suffix defined)
ld (hl),a ;{{d98f:77}}
;;=do the name copying
do_the_name_copying: ;{{Addr=$d990 Code Calls/jump count: 2 Data use count: 0}}
pop de ;{{d990:d1}}
ld a,$28 ;{{d991:3e28}} Max name length??
call possibly_alloc_A_bytes_on_execution_stack;{{d993:cd72f6}}
push hl ;{{d996:e5}}
ld b,$29 ;{{d997:0629}}
_do_the_name_copying_5: ;{{Addr=$d999 Code Calls/jump count: 1 Data use count: 0}}
dec b ;{{d999:05}}
jp z,Error_Syntax_Error;{{d99a:ca49cb}} Error: Syntax Error (name too long)
ld a,(de) ;{{d99d:1a}} Copy char
inc de ;{{d99e:13}}
and $df ;{{d99f:e6df}} Convert to upper case
ld (hl),a ;{{d9a1:77}}
inc hl ;{{d9a2:23}}
rla ;{{d9a3:17}} Bit 7 set? (Last char)
jr nc,_do_the_name_copying_5;{{d9a4:30f3}} (-$0d) Loop for next char
call set_execution_stack_next_free_ptr;{{d9a6:cd6ef6}} Push onto execution stack
ex de,hl ;{{d9a9:eb}}
dec hl ;{{d9aa:2b}}
pop de ;{{d9ab:d1}}
jp get_next_token_skipping_space;{{d9ac:c32cde}} get next token skipping space
;;==============================================
;;=set accum type from variable type atHL
;variable data type tokens = 2/3/4 if have suffix, $b/$c/$d if no suffix
set_accum_type_from_variable_type_atHL:;{{Addr=$d9af Code Calls/jump count: 2 Data use count: 0}}
ld a,(hl) ;{{d9af:7e}}
cp $0b ;{{d9b0:fe0b}} No suffix
jr c,_set_accum_type_from_variable_type_athl_4;{{d9b2:3802}} (+$02)
add a,$f7 ;{{d9b4:c6f7}} Subtract 9
_set_accum_type_from_variable_type_athl_4:;{{Addr=$d9b6 Code Calls/jump count: 1 Data use count: 0}}
cp $04 ;{{d9b6:fe04}} REAL type token
jr z,set_accum_type_as_REAL;{{d9b8:2809}} (+$09)
jr nc,raise_syntax_error_C;{{d9ba:3004}} (+$04)
cp $02 ;{{d9bc:fe02}} INT type token
jr nc,set_accumulator_type;{{d9be:3005}} (+$05)
;;=raise Syntax Error
raise_syntax_error_C: ;{{Addr=$d9c0 Code Calls/jump count: 1 Data use count: 0}}
jp Error_Syntax_Error;{{d9c0:c349cb}} Error: Syntax Error
;;=set accum type as REAL
set_accum_type_as_REAL: ;{{Addr=$d9c3 Code Calls/jump count: 1 Data use count: 0}}
ld a,$05 ;{{d9c3:3e05}}
;;=set accumulator type
set_accumulator_type: ;{{Addr=$d9c5 Code Calls/jump count: 1 Data use count: 0}}
ld (accumulator_data_type),a;{{d9c5:329fb0}}
ret ;{{d9c8:c9}}
;;=========================================
;;=update array list heads
;iterate over all arrays and update the list heads (there's one for each data type 2,3,5)
;works by:
;reset heads to nil
;works from start to arrays area
;for each array, update list head for that type
;until end of arrays area
;so, each list head will now point to the last array for it's type
update_array_list_heads: ;{{Addr=$d9c9 Code Calls/jump count: 1 Data use count: 0}}
call reset_array_linked_list_headers;{{d9c9:cd02d6}}
ld hl,(address_of_start_of_free_space_);{{d9cc:2a6cae}} get bounds of arrays area
ex de,hl ;{{d9cf:eb}}
ld hl,(address_of_start_of_Arrays_area_);{{d9d0:2a6aae}}
_update_array_list_heads_4: ;{{Addr=$d9d3 Code Calls/jump count: 1 Data use count: 0}}
call compare_HL_DE ;{{d9d3:cdd8ff}} HL=DE?
ret z ;{{d9d6:c8}} end once we go beyond end of arrays area
push de ;{{d9d7:d5}} DE = start of arrays area
call poss_step_over_string;{{d9d8:cd65d7}} skip over array name...
ld a,(hl) ;{{d9db:7e}} ...to get to type
inc hl ;{{d9dc:23}}
and $07 ;{{d9dd:e607}}
inc a ;{{d9df:3c}}
push hl ;{{d9e0:e5}} HL=start of current item
call get_array_area_and_array_list_head_ptr_for_type;{{d9e1:cd27d6}} get list head ptr for item type
call poss_update_list_headers;{{d9e4:cdd0d7}} update head ptr to current item
pop hl ;{{d9e7:e1}} back to start of item
ld e,(hl) ;{{d9e8:5e}} read offset ptr to next item
inc hl ;{{d9e9:23}}
ld d,(hl) ;{{d9ea:56}}
inc hl ;{{d9eb:23}}
add hl,de ;{{d9ec:19}} add offset to start of arrays area
pop de ;{{d9ed:d1}} retrieve start of arrays area
jr _update_array_list_heads_4;{{d9ee:18e3}} (-$1d) next
;;========================================================================
;; command ERASE
;ERASE <list of: <variable name>>
;Erases array(s)
command_ERASE: ;{{Addr=$d9f0 Code Calls/jump count: 0 Data use count: 1}}
call reset_variable_types_and_pointers;{{d9f0:cd4dea}}
_command_erase_1: ;{{Addr=$d9f3 Code Calls/jump count: 1 Data use count: 0}}
call do_ERASE_parameter;{{d9f3:cdfcd9}}
call next_token_if_prev_is_comma;{{d9f6:cd41de}}
jr c,_command_erase_1;{{d9f9:38f8}} (-$08) loop if more parameters
ret ;{{d9fb:c9}}
;;=do ERASE parameter
do_ERASE_parameter: ;{{Addr=$d9fc Code Calls/jump count: 1 Data use count: 0}}
call parse_var_type_and_name;{{d9fc:cd31d9}} find the array
push hl ;{{d9ff:e5}}
ld a,(accumulator_data_type);{{da00:3a9fb0}}
call get_array_area_and_array_list_head_ptr_for_type;{{da03:cd27d6}}
call find_named_item_in_linked_list;{{da06:cd40d7}}
jp nc,Error_Improper_Argument;{{da09:d24dcb}} Error: Improper Argument (array not dimmed)