Kidsgrove Algol Compiler - Brick 81
This assembler listing has hot links for all references to subroutines.
You can click on the routine name in code such as JS.pproc;
and jump to the routine.
When you have seen enough of it, you can use the back button to carry on where you left off.
Started
Loaded 10895 bytes for KAB81.k4
Reached end of file
=============== Second pass
===========================
!begin
/ KAB81 reads the paper tape and makes chennel 6 tape
/ the input paper tape must have been propared by mkchan.c
/ as a PT images of a POST mag tape
/ enhancement as of Jluy 2020
/ Initial lines beginning with Z have the form (optional)
/ Z38: 16 octal digits
/ and set the specified Z-store to the value indicated
prog=0: /form B-block
0/0: 202 266 144|000 000 000 J.main; =H 0;
1/0: 000 052 374|000 000 000 =H 11004; =H 0;
2/0: 034 053 102 256 030 230 =P *n *c M *c KAB8;
3/0: 106 112 031 147 134 065 =P 1DH99UPU;
4/0: 200 326 115|200 326 115 prog=4: JS.crash; JS.crash; /restart
5/0: 000 000 000 000 000 000|000 000 000 000 000 000 =0; =0;
7/0: 000 000 006 100 006 370 = Q 0/1600/chbuff;
prog=1600:
/ -------------------------------------------------------------------
Z0 = 11103: / Z11 should be accessed as F.Z0-11
Z38 = Z0-38: / Z38 communicates compilatin options, etc
/ N.B. variable nextz is held in M8, and I8 = -1
/ -------------------------------------------------------------------
sprint:
/ prints a string embedded in code, call sequence must be
/ *JS.sprint; *= #30; =P 8 chars ending in 02
!begin
3100/0: 173 000|033|027|042|170 363|140 360|042|170 364|174 000 FLINK; NOT; NEG; DUP; SRM15; M+I15; DUP; SI15; SLINK;
3102/2: 171 376|304 000 010|200 220 000|202 360 002 FQ15; SET8; OUT; EXIT.2;
!end
/ -------------------------------------------------------------------
n1print:
/ prints a string embedded in code followed by bottom bits of n1
/ call sequence must be *JS.cwprint; *= #30; =P 8 chars; =0;
!begin
3104/1: 173 000|033|027|042|170 363|140 360|140 360|042|170 364|174 000
FLINK; NOT; NEG; DUP; SRM15; M+I15; M+I15; DUP; SI15; SLINK;
3106/5: 300 006 113|065|067|300 006 114|011|101 360 F.radix; REV; FRB; F.digits; OR; SMM15/0;
3110/4: 171 376|304 000 010|200 220 000|202 360 003 FQ15; SET8; OUT; EXIT.3;
3112/3: 017|017|017|040 202 001 020 202 001 *radix: =#1010100104101001;
3114/0: 101 004 000 101 004 002 digits: =#2020200020202002;
!end
/ -------------------------------------------------------------------
crash:
/ // disaster
3115/0: 200 326 100|017|017|017|000 000 000 000 000 030 *JS.sprint; *=#30;
3117/0: 171 350 362 207 072 002 =P --crash*c;
3120/0: 136 010 MRWDQ0;
/ -------------------------------------------------------------------
!begin !label readch; / exorts label readch outside the block
3120/2: 052 rdch0: ERASE;
readch:
3120/3: 262 126 125 JCNZ5.samewd;
3121/0: 265 046 123 JCNZ2.noread;
3121/3: 125 140|121 140 PREQ6; PARQ6;
3122/1: 304 000 040|170 051|304 006 367|170 123 SET32; SRC2; SET.chbuff-1; SRM5;
noread:
3123/5: 304 377 320|170 130|140 120|143 040 SET-48; SC5; M+I5; DC2;
3125/2: 100 120|304 000 006|172 130|164 120|304 000 077|054 samewd: FMM5/0; SET6; S+C5; SHLC5; SET#77; AND;
3127/3: 042|033|027|164 371|222 146 120 DUP; NOT; NEG; SHL-4; J=Z.rdch0; / ignore all characters before / :
3130/5: 200 360 000 EXITH;
!end
!begin !label ch7open, ch7write, ch7close; / output to channel 7
3131/2: 017|017|017|017|007 030 007 067 242 107 *V0: =Q opbuff/opbuff+31/#121107;
3133/0: 007 070 007 127 000 000 V1: =Q opbuff+32/opbuff+63/0;
ch7write:
3134/0: 304 340 007|200 320 106|200 326 115|052|200 360 000 SET#160007; JS.70; JS.crash; ERASE; EXITH;
ch7open:
3136/1: 300 006 133|300 006 132 F.V1; F.V0;
3137/1: 200 320 106|200 326 115|052|200 360 000 JS.70; JS.crash; ERASE; EXITH;
ch7close:
3140/5: 304 007 067|170 365|304 140 007|170 362 SET.opbuff+31; SRI15; SET#60007; SM15;
3142/3: 171 376|200 320 106|200 326 115|200 360 000 FQ15; JS.70; JS.crash; EXITH;
!end
!begin !label main, opop;
main: /main(int argc, char **argv)
3144/2: 320 013 071|164 035|220 046 330 F.Z38; SHL+14; J<Z.kal4; / J if source is KAL4
3145/4: 201 326 136 JS.ch7open; / claim output tape
3146/1: 304 000 002|304 000 005|200 220 000|170 151 SET2; SET5; OUT; SRC6; / paper tape reader
3150/0: 304 006 370|170 144|140 140 SET.chbuff; SI6; M+I6;
3151/1: 304 000 037|172 142 SET31; S+M6;
3152/0: 157 002 QFRQ0/2; / word counter
3152/2: 157 005 QFRQ0/5; / char counter
3152/4: 304 007 030|170 102 SET.opbuff; SM4;
3153/3: 203 326 120 wz: JS.readch;
3154/0: 304 000 072|205 026 201|052 SET#72; JNE.nozinfo; ERASE;/ J if not Z-store prefix
3155/1: 203 326 120|304 000 017|054 JS.readch; SET#17; AND; / first digit
3156/2: 203 326 120|304 000 017|221 026 162 JS.readch; SET#17; J=.d1; / J if colon or slash, i.e. just 1 digit
3157/5: 304 000 017|054 SET#17; AND; / second digit
3160/3: 065|304 000 012|034|050|056 REV; SET10; MULTD; CONT; +;
3161/4: 203 326 120 JS.readch; / should be another colon or slash - ignore
3162/1: 052|027|170 362 d1: ERASE; NEG; SM15; / Z-store number
3162/5: 304 000 020|170 110|041 SET16; SC4; ZERO; / for i := 1 step 1 until 16 do (approx)
3163/5: 164 007|203 326 120|304 000 017|054|011 f1: SHL+3; JS.readch; SET#17; AND; OR;
3165/3: 143 100|265 106 163 DC4; JCNZ4.f1;
3166/2: 321 373 137|203 266 153 SM15.Z0; J.wz; / multiple Z-store specs allowed
3167/2: 320 013 071 opop: F.Z38; / output options to LP and to TTY
3167/5: 304 000 020|170 371 SET16; SRC15;
3170/4: 164 003|047|033|300 366 233|011|303 367 031|264 366 170|052 w3: SHL+1; STR; NOT; FM15.z38tab; OR; SMQ15.opbuff+1; JCNZ15.w3; ERASE;
3173/1: 304 000 030|301 007 030|304 377 302|301 367 031 SET#30; S.opbuff; SET#177702; SM15.opbuff+1;
3175/1: 300 006 253|171 362|056|042|304 000 010|200 220 000 F.v11; FM15; +; DUP; SET8; OUT;
3177/2: 041|301 007 030|027|033|304 000 010|200 220 000 ZERO; S.opbuff; NEG; NOT; SET8; OUT; / remove last word with newline
3201/2: 200 360 000 EXITH;
3201/5: 202 326 167 nozinfo: JS.opop; / output options to LP and to TTY
3202/2: 304 000 034|224 026 221 w0: SET#34; J=.stop; / while ch != semi-colon
3203/2: 304 000 100|170 071 SET64; SRC3; / assemble 64 half words -- last 2 words are overwritten
3204/1: 304 000 007|170 110 w2: SET7; SC4;
3205/0: 304 000 007|054 SET#7; AND;
3205/4: 164 007|203 326 120|304 000 007|054|011|143 100|264 106 205 w1: SHL+3; JS.readch; SET#7; AND; OR; DC4; JCNZ4.w1;
3210/1: 164 061|107 064 SHL+24; SMMQH3/4;
3210/5: 203 326 120|261 066 204 JS.readch; JCNZ3.w2;
3211/5: 304 000 036|170 031 SET30; SRC1; / block size - 2
3212/4: 151 101 MFRQ4/1; / address of data
3213/0: 041|041 ZERO; ZERO;
3213/2: 102 020|047|057|262 026 213 s1: FMMQ1/0; STR; +D; JCNZ1.s1;
3214/3: 300 006 254|033|027|042|301 006 254 F.blk; NOT; NEG; DUP; S.blk; / block number
3216/0: 042|170 024 DUP; SI1;
3216/3: 041|057 ZERO; +D; / add in the block no
3216/5: 164 041|171 024 SHL+16; FI1; / and also put it in the top 16 bits
3217/3: 166 341|052 SHLD-16; ERASE;
3220/0: 101 020|111 020 SMM1/0; SMMN1/0; / of the KDF9 checksum
3220/4: 200 326 134 JS.ch7write;
/ SET#55; SHL+16;
/ FM4; DUP; SHL+16; OR; SET31; +; SHL+16; SET70; OUT;
3221/1: 202 266 202 J.w0;
3221/4: 052|205 326 140 stop: ERASE; JS.ch7close;
3222/2: 171 150|304 000 006|200 220 000 FC6; SET6; OUT; / deallocate paper tape reader
3223/4: 320 013 071|164 035|220 046 330 F.Z38; SHL+14; J<Z.kal4; / allow KAL4 to be specified as Z38: 0400100000000000
3225/0: 304 006 024 SET#3024; / to call brick 84 to translate Usercode
3225/3: 320 013 071|164 027|220 046 231 F.Z38; SHL+11; J<Z.usercode; / J if source is Usercode
3226/5: 052 ERASE; / not Usercode, so discard brick number
3227/0: 304 344 006|200 320 106|200 326 115 SET#162006; JS.70; JS.crash; / interchange to produce channel 6
3230/3: 304 004 021 SET#2021; / to call brick 01
usercode: / enter next brick, either KAB01 or KAB84
3231/0: 170 364|304 336 010|170 362 SI15; SET#157010; SM15;
3232/1: 171 376|200 260 106 FQ15; J.70;
*z38tab: / table of bits in Z38 (all these words are -ve)
3233/0: 216 327 154 300 017 377 = P CM+LP*s; / D1 TINT;B100
3234/0: 322 030 254 227 060 077 = P TABLES*s; / D2 TINT;B040
3235/0: 277 052 147 173 075 300 = P ORIG-SW*s; / D3 TINT;B020 indicates use of original software for assembly
3236/0: 322 136 064 003 377 377 = P TEXT*s; / D4 TINT;B010
3237/0: 272 367 257 303 100 077 = P NO-OPT*s; / D5 TINT;B004
3240/0: 272 367 264 227 075 000 = P NO-TEST*s; / D6 TINT;B002
3241/0: 272 367 267 207 053 200 = P NO-WARN*s; / D7 TINT;B001
3242/0: 261 331 377 377 377 300 = P L+G*4d*s; / D8 TINT;B200000
3243/0: 256 033 047 276 300 077 = P KALGOL*s; / D9 TINT;B100000
3244/0: 336 033 047 276 300 077 = P WALGOL*s; / D10 TINT;B40000
3245/0: 327 071 162 216 371 045 = P USERCODE; / D11 TINT;B20000
3246/0: 232 374 264 312 033 200 = P FORTRAN*s; / D12 TINT;B10000
3247/0: 326 063 362 262 040 077 = P UC/RLB*s; / D13 TINT;B4000
3250/0: 256 033 024 003 377 377 = P KAL4*s; / D14 TINT;B2000
3251/0: 221 025 100 377 377 377 = P D15*s; / D15 TINT;B1000
3252/0: 221 025 200 377 377 377 = P D16*s; / D16 TINT;B400
3253/0: 000 000 007 030 007 031 v11: = Q 0/opbuff/opbuff+1;
3254/0: 000 000 000 000 000 000 *blk: =0;
!end // of main
///////// under development for inclusion of KAL4
block: / Job queue block to simulate Eldon2 JQ initiation of KAL4
3255/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|165 123 323 127 377 377
= 0; = 0; = 0; = 0; = P +5/35;
3262/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000
= 0; = 0; = 0; = 0; = 0;
3267/0: 000 000 000 000 000 000|034 055 002 353 256 272|352 112 020 101 114 065
= 0; = #0702640272727272; = #7244502020246065; / bogus file ID
3272/0: 000 001 000 001 000 001|000 000 000 000 000 000 = Q 1/1/1; = 0; / bogus F.O.C.
3274/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 222 000 000 000
= 0; = 0; = #22200000000; / TL/ST
3277/0: 000 000 000 000 000 000|000 000 000 000 000 000 = 0; = 0;
3301/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000
= 0; = 0; = 0; = 0; = 0;
3306/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000
= 0; = 0; = 0; = 0; = 0;
3313/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000
= 0; = 0; = 0; = 0; = 0;
3320/0: 000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000|000 000 000 000 000 000
= 0; = 0; = 0; = 0; = 0;
3325/0: 034 053 102 226 113 253 *kal4id: = #07025502 45445653; / cn cr M cr EDNK
3326/0: 121 347 236 171 347 236 = #24363636 36363636; / 4-------
3327/0: 006 325 006 326 337 000 findkal4: =Q kal4id / kal4id+1 / #157400;
kal4: / code to integrate KAL4 into the KAB00 system
!begin / KAL4 was really a PROMPT facility and needs special use of mkchan.c
3330/0: 320 013 071|164 007|201 046 360 go: F.Z38; SHL+3; JGEZ.usenew; / J to use kal4.c assembler
3331/2: 202 326 167 JS.opop;
3331/5: 041|174 000 ZERO; SLINK; / simulate job queue entry
3332/2: 110 000|301 006 276 FMMN0/0; S.block+17; / store and time limits
3333/1: 304 006 274|170 362 SET.block+15; SM15;
3334/0: 320 013 071|304 000 003|011 F.Z38; SET3; OR; / 2 mystery bits in Z38 for KAL4
3335/1: 301 006 274 S.block+15; / Set bits in "Z38"
3335/4: 110 000|304 000 050|042|170 371|036|170 343 FMMN0/0; SET40; DUP; SRC15; -; SRM14;
3337/3: 300 366 255|103 376 cp: FM15.block; SMMQ15/14; / copy job queue entry to top of store
3340/2: 263 366 337 JCNZ15.cp; / the emulation of OUT 34 copies it from here
// extract from KAB84
3340/5: 300 006 327|200 320 106|200 320 004 F.findkal4; JS.70; JS.4; / locate the KAL4 assembler
3342/2: 304 000 100|200 320 106|200 260 004 SET#100; JS.70; J.4; / get device number for channel 0
3343/5: 170 356|304 000 010|170 344|304 000 001|170 342 SQ14; SET8; SI14; SET1; SM14;
3345/5: 136 340|121 340 MBSKQ14; PARQ14; / back skip to re-read the B-block
3346/3: 152 016|304 000 007|170 342 IFRQ0/14; SET7; SM14;
3347/4: 300 000 007|110 000 F.7; FMMN0/0; / preserve date and store limit
3350/3: 124 340|121 340 MFRQ14; PARQ14; / read B=block
3351/1: 300 000 007|042|170 376|170 323 F.7; DUP; SQ15; SRM13;
3352/3: 111 000|301 000 007 SMMN0/0; S.7; / reinstate ST and date
3353/2: 265 366 357 JCNZ15.oldtape; / J if C-block fragmented
final:
3353/5: 154 357 CFRQ14/15;
// next copy read order up above code to be read in
3354/1: 300 006 367|300 006 366 F.readc+1; F.readc;
3355/1: 043 DUPD;
3355/2: 113 320|171 322|174 000 SMMQN13/0; FM13; SLINK; / M13 points at word beyond C-block
3356/2: 111 320|101 320|111 320 SMMN13/0; SMM13/0; SMMN13/0; / and store it twice to flush buffers
3357/2: 202 360 000 EXIT; / jump to code at end of C-block
oldtape:
3357/5: 136 010 MRWDQ0; // diagnostic deliberate fail
usenew: / use kal4.c assembler by copying input prog to ptp.txt (i.e. paper tape punch)
3360/1: 304 006 255|170 025|140 020 SET.block; SRI1; M+I1;
3361/2: 304 000 001|304 000 005|200 220 000|170 030 SET1; SET5; OUT; SC1;
3363/1: 131 020|121 020 PWEQ1; PARQ1; / leave a marker file
3363/5: 171 030|304 000 006|200 220 000 FC1; SET6; OUT;
3365/1: 041|200 220 000 ZERO; OUT; / Leave ptp.txt file for xbin2 to pick up
3365/5: 017 *readc:
3366/0: 124 360|121 360|200 260 000 MFRQ15; PARQ15; J.0; / read C-block and enter program
!end / of KAL4 blister
3367/1: 017|017|017|017|017 *chbuff:
prog=prog+32:
opbuff:
Reached end of file
C-block from 1600 to 1784
No of ID table entries = 327 (10%)