File: string.t2

For general comments see here
LineAddressObject Code LabelF1N1BF2N2CommentsCheck
1 0  ; tape1.d/string.t2
2 0  ;------------------
3 0  ;
4 0  ; PackStrChar, add 6-bit character to packed string
5 0  ; character supplied in Acc, current word in W3231,
6 0  ; character in word count in W3234
7 0  ;
8 0  =3564 
9 3564  PkStrChar::; 
10 3564  ;
11 3564  .ent:; 
12 3564 0206237 exa W3231   ;swap with current word @3564
13 3564+1320006 sll 6   ;shift word left
14 3565 0506237 ads W3231   ;and add to character
15 3565+0646242 lis W3234   ;check count
16 3566 1026763 jn .3571   ; @3566
17 3566+0446241 inc W3233   ;increment word count
18 3567 0601443 lod K5a   ;=5
19 3567+0426242 stn W3234   ;set char count back to -5
20 3568 0746237 lzs W3231   ;load and clear current word @3568
21 3568+0206240 exa Pinfo   ;swap with previous word
22 3569 1046763 jz .3571   ;prev word zero, only 1 word
23 3569+  nop     ;
23+13569+1006762 jmp .1    
23+23570  .1:; 
24 3570   call     ;write full word to O-code @3570
24+13570 7306371101532 lnk putFwd.lnk:jmp putFwd.ent 
25 3571  .3571:; 
26 3571   ret     ;
26+13571 0031223000001 o00 PkStrChar.lnk/jmp 1 
27 3572  ;--------------------------------------------------------------------
28 3572  ; compile code to load a string address
29 3572  ;
30 3572  CompStrPtr::; 
31 3572  ;
32 3572  .ent:; 
33 3572 0000000 o00 0   ; @3572
34 3572+0042220 o02 W1168   ;
35 3573   call     ;
35+13573 7307175001640 lnk GenInst.lnk:jmp GenInst.ent 
36 3574 0546243 cls W3235   ; @3574
37 3574+0546241 cls W3233   ;clear word count
38 3575 0546240 cls Pinfo   ;clear previous word
39 3575+0546237 cls W3231   ;clear current packed word
40 3576 0601443 lod K5a   ;=5 @3576
41 3576+0426242 stn W3234   ;set char in word count = -5
42 3577  W3577:; 
43 3577  .3577:call     ; $ special (within string)
43+13577 7303015000604 lnk getchar.lnk:jmp getchar.ent 
44 3578 1006775 jmp .3581   ; @3578
45 3578+1106777 jmp .3583P   ;check for end of string
46 3579 1006775 jmp .3581   ;
47 3579+1006775 jmp .3581   ;
48 3580 1107004 jmp .3588P   ;check for nested string @3580
49 3580+1006775 jmp .3581   ;
50 3581  ;
51 3581 0600575.3581:lod ipshift   ;normal char, convert to 6-bit
52 3581+0100574 add currchar   ;
53 3582  .3582:; 
54 3582   call     ;add to string constant
54+13582 7331221006754 lnk PkStrChar.lnk:jmp PkStrChar.ent 
55 3583 1006771 jmp W3577   ;and loop back for more
56 3583+ ;
57 3583+0600574.3583P:lod currchar   ;punctuation, check for pound/query
58 3584 0100575 add ipshift   ; @3584
59 3584+0124312 sub K20   ;=20 '?'
60 3585 1047002 jz .3586   ;yes, maybe end of string
61 3585+1006775 jmp .3581   ;no, treat as ordinary chars
62 3586  ;
63 3586  ; close quote (?) found, check if nested
64 3586  ;
65 3586 0040000.3586:o02 0   ;=1, test for nesting @3586
66 3586+0766243 o37 W3235   ;decrement count
67 3587 1147010 jz .3592P   ;zero, end of string
68 3587+0042227 o02 K26   ;=26, +1=>27
69 3588 1006776 jmp .3582   ;add to string @3588
70 3588+ ;
71 3588+ ; punct2 character, includes pound sign
72 3588+ ;
73 3588+0600574.3588P:lod currchar   ;other punct, check for pound
74 3589 0100575 add ipshift   ;convert to 6-bit
75 3589+0122227 sub K26   ;=26 'pound-sign'
76 3590 1047007 jz .3591   ;yes, nested chars @3590
77 3590+1006775 jmp .3581   ;no, treat as ordinary
78 3591  ;
79 3591  ; nested open quote (pound) found
80 3591 0646243.3591:lis W3235   ;increment nest count
81 3591+1050565 jz .4469   ;yes, goto patch
82 3592 1104621 jmp _err54   ;pound not allowed in nested string @3592
83 3592+ ;
84 3592+ =4469 
85 4469  .4469:; patch moved in-line 
86 4469 0601460 lod K63   ;=63, special marker for nesting
87 4469+1006776 jmp .3582   ;store shift marker
88 4470  ;
89 4470  ; end of string,
90 4470  =3592+ 
91 3592+0540574.3592P:cls currchar   ;discard closing quote
92 3593 0606242 lod W3234   ;char count
93 3593+0101443 add K5a   ;=5
94 3594 1147020 jz .3600P   ;-> no chars in current word @3594
95 3594+0606240 lod Pinfo   ;previous word
96 3595 1047015 jz .3597   ;only one word
97 3595+  nop     ;
97+13595+1007014 jmp .1    
97+23596  .1:; 
98 3596   call     ;output final word @3596
98+13596 7306371101532 lnk putFwd.lnk:jmp putFwd.ent 
99 3597 0040000.3597:o02 0   ;=1
100 3597+0126242 sub W3234   ;get number of chars to pad
101 3598 1242226 mul K6   ;=6 get number of bits @3598
102 3598+1360000 ara 0   ;
103 3599 1031177320000 exa W3231/sll 0;shift current word to pad
104 3600 1007022 jmp .3602   ; @3600
105 3600+ ;
106 3600+0606240.3600P:lod Pinfo   ;any previous word?
107 3601 1047022 jz .3602   ;no, null string
108 3601+1107022 jmp .3602P   ;yes, write that instead
109 3602  ;
110 3602  .3602:; 
111 3602 0446241 inc W3233   ;bump word count @3602
112 3602+ .3602P:; 
113 3602+0102175 add bit39   ;add terminating flag
114 3603   call     ;output final word
114+13603 7306371101532 lnk putFwd.lnk:jmp putFwd.ent 
115 3604 0606241 lod W3233   ;get word count @3604
116 3604+0401414 sto PCdata   ;save word count
117 3605 0602200 lod K8a   ;=8, number of bits
118 3605+  nop     ;
118+13605+1007026 jmp .1    
118+23606  .1:; 
119 3606   call     ;put word count @3606
119+13606 7306371001477 lnk putcode.lnk:jmp putcode.ent 
120 3607 0602231 lod K11   ;=11, block data o-code key
121 3607+  nop     ;
121+13607+1007030 jmp .1    
121+23608  .1:; 
122 3608   call     ;write o-code key @3608
122+13608 7306371001526 lnk putOpcd.lnk:jmp putOpcd.ent 
123 3609   ret     ;
123+13609 0031157000001 o00 CompStrPtr.lnk/jmp 1 
124 3610  ;--------------------------------------------------------------------