start tok64 d64-3W0A43 0 REM"{delete*7} ponzo*83*waterloo 1 REM"{delete*7} 9 POKE53281,15:POKE53280,12:PRINT"{black}" 10 PRINT"{clear}{space*15}{reverse on}{blue}c64 tutor-6 15 PRINT"{red}{cm a}{sh asterisk*37}{cm s}" 20 PRINT"{sh -} {reverse on}{blue}{space*5}more 6510 machine language{space*4}{red}{reverse off} {sh -}":ms$=" welcome! " 25 PRINT"{red}{cm z}{sh asterisk*37}{cm x}{black}" 35 GOSUB60000:GOSUB63100:GOSUB63000 40 PRINT"{clear}let's look at how basic {down}{left*6}{cm u*6}" 50 PRINT"{reverse on}{space*5}clears the screen{space*6}" 60 PRINT"{down}we'll {reverse on}disassemble{reverse off} the machine language" 70 PRINT"{down}(assumed to be at $e06b)." 80 PRINT"{down*2}it's handy if you have an extended" 90 PRINT"{down}monitor like j.butterfield's {reverse on}supermon{reverse off}!!":GOSUB63000 100 PRINT"{clear}., e068 a9 20{space*4}lda #$20 101 PRINT"., e06a 9d 00 04 sta $0400,x 102 PRINT"., e06d 9d 00 05 sta $0500,x 103 PRINT"., e070 9d 00 06 sta $0600,x 104 PRINT"., e073 9d 00 07 sta $0700,x 105 PRINT"., e076 ca{space*7}dex 106 PRINT"., e077 d0 f1{space*4}bne $e06a":GOSUB63000 110 PRINT"{home}., e068 a9 20{space*4}{reverse on}lda #$20{space*3}" 111 PRINT"., e06a 9d 00 04 {reverse on}sta $0400,x" 112 PRINT"., e06d 9d 00 05 {reverse on}sta $0500,x" 113 PRINT"., e070 9d 00 06 {reverse on}sta $0600,x" 114 PRINT"., e073 9d 00 07 {reverse on}sta $0700,x" 115 PRINT"., e076 ca{space*7}{reverse on}dex{space*8}" 116 PRINT"., e077 d0 f1{space*4}{reverse on}bne $e06a{space*2}" 120 PRINT"{down}Qrecognize the {reverse on}assembler{reverse off} instructions?":GOSUB63000 130 PRINT"{home}., e068 {reverse on}a9 20{space*4}{reverse off}lda #$20{space*3}" 131 PRINT"., e06a {reverse on}9d 00 04 {reverse off}sta $0400,x" 132 PRINT"., e06d {reverse on}9d 00 05 {reverse off}sta $0500,x" 133 PRINT"., e070 {reverse on}9d 00 06 {reverse off}sta $0600,x" 134 PRINT"., e073 {reverse on}9d 00 07 {reverse off}sta $0700,x" 135 PRINT"., e076 {reverse on}ca{space*7}{reverse off}dex{space*8}" 136 PRINT"., e077 {reverse on}d0 f1{space*4}{reverse off}bne $e06a{space*2}" 140 PRINT"{down*4}Qthese are the hex bytes that are{space*6}" 150 PRINT" actually in memory.{space*10}":GOSUB63000 160 PRINT"{home}., {reverse on}e068 {reverse off}a9 20{space*4}lda #$20 161 PRINT"., {reverse on}e06a {reverse off}9d 00 04 sta $0400,x 162 PRINT"., {reverse on}e06d {reverse off}9d 00 05 sta $0500,x 163 PRINT"., {reverse on}e070 {reverse off}9d 00 06 sta $0600,x 164 PRINT"., {reverse on}e073 {reverse off}9d 00 07 sta $0700,x 165 PRINT"., {reverse on}e076 {reverse off}ca{space*7}dex 166 PRINT"., {reverse on}e077 {reverse off}d0 f1{space*4}bne $e06a 170 PRINT"{down*8}Qthese are the locations in memory" 180 PRINT" which contain the m-l code.":GOSUB63000 181 ms$="{space*2}onward{space*2}":GOSUB63100 185 PRINT"{clear}now let's look at how a basic " 186 PRINT"{down}{reverse on}new{reverse off} is done. we'll pretend the" 187 PRINT"{down}code is from $b5d4 to $b5e8." 188 PRINT"{down}recall that the first 3 bytes" 189 PRINT"{down}at $0800/$0801/$0802 must be {reverse on}00 00 00{reverse off}." 190 PRINT"{down}but $0800 always has {reverse on}00{reverse off} anyway so" 191 PRINT"{down}we just fill $0801/$0802 with {reverse on}00{reverse off}." 192 PRINT"{down}Qthe {reverse on}start of basic{reverse off} is kept in $2b/$2c." 193 PRINT"{down}Qthe {reverse on}end of basic{reverse off}, kept in $2d/$2e," 194 PRINT"{down}must be just 2 bytes past the {reverse on}start{reverse off}." 195 PRINT"{down}let's see how it's done..":GOSUB63000 196 PRINT"{clear}{down*6}"; 220 PRINT"{home}{down*6}., b5d4 a9 00{space*4}{reverse on}lda #$00{space*3}{reverse off}{arrow left}" 221 PRINT"., b5d6 a8{space*7}{reverse on}tay{space*8}{reverse off}{arrow left}" 230 GOSUB63400:PRINT"both {reverse on}a{reverse off} and {reverse on}y{reverse off} are filled " 240 PRINT"{down}with #${reverse on}00{reverse off}..to start.":GOSUB63000 250 PRINT"{home}{down*8}., b5d7 91 2b{space*4}{reverse on}sta ($2b),y{reverse off}{up*2} {down}{left} {down}{left}{arrow left}" 260 GOSUB63400:PRINT"{home}since {reverse on}$2b{reverse off} contains the" 270 PRINT"{down}the start of basic,(usually $0801)" 280 PRINT"{down}#${reverse on}00{reverse off} is stored in ($2b)+y.":GOSUB63000 290 GOSUB63400:PRINT"then {reverse on}iny{reverse off} gets ready to store #${reverse on}00{reverse off} into" 300 PRINT"{down}the second byte of 'basic' at (usually)" 310 PRINT"{down}$0802." 320 PRINT"{home}{down*9}., b5d9 c8{space*7}{reverse on}iny{space*8}{reverse off}{up} {down}{left}{arrow left}":GOSUB63000 330 PRINT"{home}{down*10}., b5da 91 2b{space*4}{reverse on}sta ($2b),y{reverse off}{up} {down}{left}{arrow left}" 340 GOSUB63400:PRINT"there she goes!":GOSUB63000 350 GOSUB63400:PRINT"the {reverse on}end{reverse off} of basic now has to" 360 PRINT"{down}be changed to read {reverse on}$0803{reverse off}..and {reverse on}end" 370 PRINT"{down}is stored at {reverse on}$2d/$2e{reverse off}.":GOSUB63000 371 PRINT"{home}{down*11}., b5dc a5 2b{space*4}{reverse on}lda $2b{space*4}{reverse off}{up} {down}{left}{arrow left}" 380 GOSUB63400:PRINT"so we {reverse on}lda $2b{reverse off} getting ready" 390 PRINT"{down}to add 2..":GOSUB63000 400 GOSUB63400:PRINT"but remember to {reverse on}clc{reverse off} first!":GOSUB63000 410 PRINT"{home}{down*12}., b5de 18{space*7}{reverse on}clc{space*8}{reverse off}{up} {down}{left}{arrow left}":GOSUB63000 420 PRINT"{home}{down*13}., b5df 69 02{space*4}{reverse on}adc #$02{space*3}{reverse off}{up} {down}{left}{arrow left}" 430 GOSUB63400:PRINT"see..we add 2.":PRINT"{down}then we store this lo-byte" 440 PRINT"{down}into $2d.":GOSUB63000 450 PRINT"{home}{down*14}., b5e1 85 2d{space*4}{reverse on}sta $2d{space*4}{reverse off}{up} {down}{left}{arrow left}":GOSUB63000 460 GOSUB63400:PRINT"now we must fix up the hi-byte at $2e." 470 PRINT"{down}we {reverse on}lda $2c{reverse off} which will go to $2e.":GOSUB63000 480 PRINT"{home}{down*15}., b5e3 a5 2c{space*4}{reverse on}lda $2c{space*4}{reverse off}{up} {down}{left}{arrow left}":GOSUB63000 490 GOSUB63400:PRINT"but, just in case there's a {reverse on}carry{reverse off}" 500 PRINT"{down}left over from the {reverse on}adc #$02{reverse off} we..":GOSUB63000 510 PRINT"{home}{down*16}., b5e5 69 00{space*4}{reverse on}adc #$00{space*3}{reverse off}{up} {down}{left}{arrow left}":GOSUB63000 520 GOSUB63400:PRINT"now{down}{left*3}{cm u*3}{up} we can stick the hi-byte" 530 PRINT"{down}into $2e.":GOSUB63000 540 PRINT"{home}{down*17}., b5e7 85 2e{space*4}{reverse on}sta $2e{space*4}{reverse off}{up} {down}{left}{arrow left}":GOSUB63000 550 GOSUB63400:ms$="{reverse on}nice!nice!{reverse off}":GOSUB63100:GOSUB63000 560 PRINT"{clear}now let's look at how {reverse on}basic chaining{reverse off}" 570 PRINT"{down}might be accomplished in basic ." 571 PRINT"{down*2}(the statements in basic are {reverse on}linked{reverse off}" 572 PRINT"{down}and these links must be recreated" 573 PRINT"{down}each time we insert or modify." 574 PRINT"{down}that's {reverse on}chaining{reverse off}.)" 580 PRINT"{down*2}recall that basic statements are stored" 590 PRINT"{down}from $0801 in the following format:":GOSUB63000:PRINT"{clear}" 600 ba$="{cm r}{sh asterisk*4}{cm r}{sh asterisk*4}{cm r}{sh asterisk*4}{cm r}{sh asterisk*4}{cm r}{sh asterisk*4}{cm r}{sh asterisk} {cm r}{sh asterisk*4}{cm r}{sh asterisk*4}"+CHR$(13) 610 z$="{sh -}{space*4}{sh -} {sh space*3}{sh -}{sh space*2} {sh space}{sh -}{sh space} {sh space*2}{sh -} {sh space*3}{sh -}--{sh -}{space*4}{sh -}{space*4}{sh -}"+CHR$(13) 620 ba$=ba$+z$+z$+z$+"{cm e}{sh asterisk*4}{cm e}{sh asterisk*4}{cm e}{sh asterisk*4}{cm e}{sh asterisk*4}{cm e}{sh asterisk*4}{cm e}{sh asterisk} {cm e}{sh asterisk*4}{cm e}{sh asterisk*4}"+CHR$(13)+"{right}{up*4}" 630 PRINTbt$"{up*7}"ba$+"link{right}link{right}stmt{right}stmt{right}basic{right*3}zero{right}link" 640 PRINT"{right}byte{right}byte{right}num{right*2}num{right*2}text {right*3}byte{right}byte" 650 PRINT"{right} lo {right} hi {right} lo {right} hi {right}area{right*4}=end{right} lo" 660 m1$=bt$+"{up*2} {reverse on}{^*4} {^*4}{reverse off}":PRINTm1$:PRINT"{home}Qthis is the address of the {reverse on}next" 670 PRINT"{down}basic statement.":GOSUB63000 680 m2$=bt$+"{up*2}{space*11}{reverse on}{^*4} {^*4}{reverse off}":PRINTm2$ 690 PRINT"{home}{down*4}Qthis is basic statement number:" 700 PRINT"{down}lo-byte then hi-byte.":GOSUB63000 710 m3$=bt$+"{up*2}{space*21}{reverse on}{^*4}-^{reverse off}":PRINTm3$ 720 PRINT"{home}{down*8}Qthis is the basic text itself.":GOSUB63000 740 m4$=bt$+"{up*2}{space*29}{reverse on}{^*4}{reverse off}":PRINTm4$ 750 PRINT"{home}{down*10}Qend-of-statement.":GOSUB63000 760 m5$=bt$+"{up*2}{space*34}{reverse on}{^*4}{reverse off}":PRINTm5$ 770 PRINT"{home}{down*13}Qthe next link.":GOSUB63000 775 PRINTm5$"{left*4}{space*4}" 780 GOSUB39000:PRINT"Qwe will look in $2b/$2c to" 790 PRINT"{down}find the start of basic (usually $0801)" 800 PRINT"{down}pointing to the first link (lo-byte).":PRINTm1$"{left*4}{space*4}":GOSUB63000 810 PRINT"{home}{down*6}Qthen we will march through to the end" 820 PRINT"{down}of the first basic statement{.*4}":PRINTm4$ 830 GOSUB63000:PRINT"{home}{down*10}and store the address of the {reverse on}next{reverse off} link.." 840 PRINTm5$:GOSUB63000:PRINT"{home}{down*12}into the links at $0801/$0802." 850 PRINTm5$"{left*4}{space*4}":PRINTm1$:GOSUB63000 860 GOSUB39000:PRINTm1$"{left*4}{space*4}" 870 PRINT"{home}Qin fact, once at the lo-byte of the" 880 PRINT"{down}link we can jump ahead 5 bytes before" 890 PRINT"{down}we test for the {reverse on}00{reverse off} byte marking the" 900 PRINT"{down}end of the current basic statement.":GOSUB63000 910 FORt=1TO200:NEXT:PRINTm2$:FORt=1TO200:NEXT:PRINTm3$:FORt=1TO200:NEXT 915 PRINTm4$:GOSUB63000 920 PRINT"{clear}., b4b6 a5 2b{space*4}{reverse on}lda $2b{space*4}" 921 PRINT"., b4b8 a4 2c{space*4}{reverse on}ldy $2c{space*4}" 922 PRINT"., b4ba 85 22{space*4}{reverse on}sta $22{space*4}" 923 PRINT"., b4bc 84 23{space*4}{reverse on}sty $23{space*4}" 930 PRINT"{down}we get the start-of-basic address from" 940 PRINT"{down}$2b/$2c and store it in $22/$23." 950 PRINT"{down}we will be modifying this address and" 960 PRINT"{down}will do the modifying to the copy at" 970 PRINT"{down}$22/$23." 980 PRINT"{down}$22/$23 will hold the address of the" 990 PRINT"{down}{reverse on}lo-byte link{reverse off} as we march through" 1000 PRINT"{down}the basic statements." 1010 PRINT"{down}to start with it holds $0801.":GOSUB63000 1020 PRINT"{clear}., b4be 18{space*7}{reverse on}clc{space*7}" 1030 PRINT"{down*2}we do this {reverse on}clc{reverse off} in preparation" 1040 PRINT"{down}for an {reverse on}adc{reverse off} later on..":GOSUB63000 1050 PRINT"{clear}., b4bf a0 01{space*4}{reverse on}ldy #$01{space*3}" 1060 PRINT"., b4c1 b1 22{space*4}{reverse on}lda ($22),y" 1070 PRINT"{down*3}now the a-register holds the byte" 1080 PRINT"{down}stored at $0802." 1090 PRINT"{down}that's the {reverse on}hi-byte link{reverse off} to the" 1100 PRINT"{down}next basic statement." 1120 PRINT"{down}if this is {reverse on}00{reverse off} then we must be at" 1130 PRINT"{down}end of the program!" 1140 PRINT"{down}(remember..end-of-program has {reverse on}00{reverse off} {reverse on}00{reverse off} {reverse on}00{reverse off}" 1150 PRINT"{down}which implies a {reverse on}00{reverse off} hi-byte link.":GOSUB63000 1160 PRINT"{home}{down*2}., b4c3 f0 1c{space*4}{reverse on}beq $b4e1{space*2}" 1170 FORt=1TO20:PRINTcl$:NEXT:PRINT"{home}{down*5}..so we test it for zero" 1180 PRINT"{down}and {reverse on}beq{reverse off} to $b4e1 which is an exit" 1190 PRINT"{down}from this routine!":GOSUB63000 1200 PRINT"{clear}., b4b6 a5 2b{space*4}lda $2b 1201 PRINT"., b4b8 a4 2c{space*4}ldy $2c 1202 PRINT"., b4ba 85 22{space*4}sta $22 1203 PRINT"., b4bc 84 23{space*4}sty $23 1204 PRINT"., b4be 18{space*7}clc 1205 PRINT"., b4bf a0 01{space*4}ldy #$01 1206 PRINT"., b4c1 b1 22{space*4}lda ($22),y 1207 PRINT"., b4c3 f0 1c{space*4}beq $b4e1 1210 PRINT"{down}that's what we have so far." 1220 PRINT"{down}now we're going to move ahead 5 bytes" 1230 PRINT"{down}and start checking each byte from there" 1240 PRINT"{down}for the {reverse on}00{reverse off} end-of-statement.":GOSUB63000 1250 PRINT"{clear}., b4c5 a0 04{space*4}{reverse on}ldy #$04{space*3}" 1260 PRINT"., b4c7 c8{space*7}{reverse on}iny{space*8}" 1270 PRINT"., b4c8 b1 22{space*4}{reverse on}lda ($22),y" 1280 PRINT"., b4ca d0 fb{space*4}{reverse on}bne $b4c7{space*2}" 1290 PRINT"{down}here we {reverse on}ldy #$04{reverse off} then {reverse on}iny{reverse off} which" 1300 PRINT"{down}makes {reverse on}$(22),y{reverse off} 5 bytes past our 'base'" 1310 PRINT"{down}at the {reverse on}lo-byte link{reverse off}." 1320 PRINT"{down}we check this byte for {reverse on}00{reverse off}, to see" 1340 PRINT"{down}if it's the end-of-statement, and" 1350 PRINT"{down}{reverse on}b{reverse off}ranch if {reverse on}n{reverse off}ot {reverse on}e{reverse off}qual to zero to the" 1360 PRINT"{down}{reverse on}iny{reverse off} instruction. from now on we move" 1370 PRINT"{down}a byte at a time, looking for {reverse on}00{reverse off}," 1380 PRINT"{down}and stay in this loop until we do!":GOSUB63000 1390 PRINT"{clear}eventually we find the end-of-statement" 1400 PRINT"{down}and must now determine the address of" 1410 PRINT"{down}of the 'next'{down}{left*5}{cm u*4} {up} {reverse on}lo-byte link{reverse off}." 1420 PRINT"{down}two things are done with this address." 1430 PRINT"{down}1:it will be stored in the earlier" 1440 PRINT"{space*2}links (originally $0801/$0802)." 1450 PRINT"{down}2:our 'base' (kept in $22/$23)" 1460 PRINT"{space*2}originally was the link at $0801." 1470 PRINT"{space*2}$22/$23 will be changed to point":PRINT"{space*2}to this 'next' link." 1475 PRINT"{down}at the moment we're (y) bytes past" 1476 PRINT"{down}the address in $22/$23." 1480 PRINT"{down*3}{reverse on}let's forge ahead{reverse off}{.*3}":ms$="{reverse on}go!go!go!{reverse off}":GOSUB63000:GOSUB63100 1490 PRINT"{clear}., b4cc c8{space*7}{reverse on}iny{space*8}" 1500 PRINTsd$"{reverse on}iny{reverse off} advances 1 byte past the {reverse on}00{reverse off}" 1510 PRINT"{down}end-of-statement to the 'next' {reverse on}lo-link{reverse off}." 1520 PRINT"{down}now {reverse on}($22),y{reverse off} points to the 'next'" 1530 PRINT"{down}{reverse on}lo-link{reverse off} and we do our '2 things'" 1540 PRINT"{down}with this address..":GOSUB63000 1541 PRINT"{home}{down}., b4cd 98{space*7}tya{space*8}" 1542 PRINT"., b4ce 65 22{space*4}adc $22{space*4}" 1543 PRINT"., b4d0 aa{space*7}tax{space*8}" 1544 PRINT"., b4d1 a0 00{space*4}ldy #$00{space*3}" 1545 PRINT"., b4d3 91 22{space*4}sta ($22),y" 1550 PRINTsd$;:FORt=1TO10:PRINTcl$:NEXT 1560 PRINTsd$"Qwe {reverse on}adc{reverse off} the address at {reverse on}$22{reverse off} to {reverse on}y{reverse off}.." 1570 PRINT"but {reverse on}adc{reverse off} only works with the a-register" 1580 PRINT"so we {reverse on}tya{reverse off} first then{down}{left*4}{cm y*4}{up} {reverse on}adc $22{reverse off}.":GOSUB63000 1581 PRINT"{home}{down}., b4cd 98{space*7}{reverse on}tya{space*8}" 1582 PRINT"., b4ce 65 22{space*4}{reverse on}adc $22{space*4}":GOSUB63000 1590 PRINTsd$"{down*3}Qnow {reverse on}a{reverse off} contains the lo-byte of the" 1600 PRINT"new 'base' address=the 'next' {reverse on}lo-link{reverse off}." 1605 PRINT"we save this magic byte in 'x'..":GOSUB63000 1606 PRINT"{home}{down*3}., b4d0 aa{space*7}{reverse on}tax{space*8}":GOSUB63000 1610 PRINTsd$"{down*6}Qthen put it into $0801 which is the" 1620 PRINT"address currently held in $22/$23." 1630 PRINT"we do this with {reverse on}sta{reverse off} into {reverse on}($22),0" 1635 PRINT"which requires 'y=0' so we {reverse on}ldy #$00{reverse off}" 1640 PRINT"then{down}{left*4}{cm y*4}{up} {reverse on}sta ($22),y{reverse off}!":GOSUB63000 1641 PRINT"{home}{down*4}., b4d1 a0 00{space*4}{reverse on}ldy #$00{space*3}" 1642 PRINT"., b4d3 91 22{space*4}{reverse on}sta ($22),y":GOSUB63000 1650 PRINTsd$;:FORi=1TO15:PRINTcl$:NEXT 1655 ms$="{reverse on}go!go!go!{reverse off}":GOSUB63100 1660 PRINTsd$;:FORi=1TO15:PRINTcl$:NEXT 1661 PRINT"{home}{down*6}., b4d5 98{space*7}tya{space*8}" 1662 PRINT"., b4d6 65 23{space*4}adc $23{space*5}" 1663 PRINT"., b4d8 c8{space*7}iny{space*9}" 1664 PRINT"., b4d9 91 22{space*4}sta ($22),y" 1670 PRINTsd$"{down*6}we have the lo-link fixed up." 1680 PRINT"{down}now for the hi-link.":GOSUB63000 1690 PRINTsd$"{down*6}";:FORi=1TO8:PRINTcl$:NEXT 1700 PRINTsd$"{down*4}Qwe clear the a-register to 00" 1710 PRINT"{reverse on}without{reverse off} affecting any carry " 1720 PRINT"left over from the earlier {reverse on}adc $22{reverse off}.":GOSUB63000 1721 PRINT"{home}{down*6}., b4d5 98{space*7}{reverse on}tya{space*8}":GOSUB63000 1730 PRINTsd$"{down*7}Qthen we {reverse on}adc $23{reverse off}" 1740 PRINT"adding the carry bit (if any!)" 1750 PRINT"to the hi-byte of our new 'base'" 1760 PRINT"address in $22/$23-which always" 1780 PRINT"points to the lo-link.":GOSUB63000 1781 PRINT"{home}{down*7}., b4d6 65 20{space*4}{reverse on}adc $23{space*4}":GOSUB63000 1790 PRINTsd$"{down*6}";:FORi=1TO8:PRINTcl$:NEXT 1800 PRINTsd$"{down*4}Qwe now have the hi-byte of our" 1810 PRINT"new lo-link address in 'a' and" 1820 PRINT"we need to stuff it into $0802" 1830 PRINT"which is 1 byte past $0801 and" 1840 PRINT"$0801 is held in $22/$23{!*3}":GOSUB63000 1850 ms$=" {reverse on} ouch!! {reverse off}":GOSUB63100 1851 PRINT"{home}{down*8}., b4d8 c8{space*7}{reverse on}iny{space*8}" 1852 PRINT"., b4d9 91 22{space*4}{reverse on}sta ($22),y":GOSUB63000 1890 PRINT"{clear}., b4b6 a5 2b{space*4}lda $2b 1891 PRINT"., b4b8 a4 2c{space*4}ldy $2c 1892 PRINT"., b4ba 85 22{space*4}sta $22 1893 PRINT"., b4bc 84 23{space*4}sty $23 1894 PRINT"., b4be 18{space*7}clc 1895 PRINT"., b4bf a0 01{space*4}ldy #$01 1896 PRINT"., b4c1 b1 22{space*4}lda ($22),y 1897 PRINT"., b4c3 f0 1c{space*4}beq $b4e1 1898 PRINT"., b4c5 a0 04{space*4}ldy #$04 1899 PRINT"., b4c7 c8{space*7}iny 1900 PRINT"., b4c8 b1 22{space*4}lda ($22),y 1901 PRINT"., b4ca d0 fb{space*4}bne $b4c7 1902 PRINT"., b4cc c8{space*7}iny 1903 PRINT"., b4cd 98{space*7}tya 1904 PRINT"., b4ce 65 22{space*4}adc $22 1905 PRINT"., b4d0 aa{space*7}tax 1906 PRINT"., b4d1 a0 00{space*4}ldy #$00 1907 PRINT"., b4d3 91 22{space*4}sta ($22),y 1908 PRINT"., b4d5 98{space*7}tya 1909 PRINT"., b4d6 65 23{space*4}adc $23 1910 PRINT"., b4d8 c8{space*7}iny 1920 PRINT"., b4d9 91 22{space*4}sta ($22),y 1930 PRINTbt$"{up*2}{reverse on}what's left to do{?*3}{reverse off}":GOSUB63000 1940 PRINT"{clear}we've fixed the links at $0801/$0802." 1950 PRINT"{down}they point to the 'next' lo-byte link." 1960 PRINT"{down}that's the first of our '2 things' done." 1970 PRINT"{down}{reverse on}now{reverse off} we store the 'next' lo-link" 1980 PRINT"{down}address into $22/$23 and start all" 1990 PRINT"{down}over again with this {reverse on}new base{reverse off}!!" 2000 PRINT"{down}(at least until we run across {reverse on}00 00 00{reverse off}" 2010 PRINT"{down}signifying the end-of-program).":GOSUB63000 2020 PRINT"{clear}you may not realize it but we have" 2030 PRINT"{down}this 'new base' address(=the address" 2040 PRINT"{down}of the 'next' lo-link) in {reverse on}x{reverse off} and {reverse on}a{reverse off}." 2050 PRINT"{down}x has the lo-byte!":PRINT"{down}a has the hi-byte!!" 2060 ms$="{space*2}{reverse on}clever!{reverse off}{space*2}":GOSUB63000:GOSUB63100 2070 PRINT"{clear}let's see it all..pay attention!":GOSUB63000 2071 PRINT"{clear}., b4b6 a5 2b{space*4}lda $2b 2072 GOSUB63002:PRINT"., b4b8 a4 2c{space*4}ldy $2c 2073 GOSUB63002:PRINT"., b4ba 85 22{space*4}sta $22 2074 GOSUB63002:PRINT"., b4bc 84 23{space*4}sty $23 2075 GOSUB63002:PRINT"., b4be 18{space*7}clc 2076 GOSUB63002:PRINT"., b4bf a0 01{space*4}ldy #$01 2077 GOSUB63002:PRINT"., b4c1 b1 22{space*4}lda ($22),y 2078 GOSUB63002:PRINT"., b4c3 f0 1c{space*4}beq $b4e1 2079 GOSUB63002:PRINT"., b4c5 a0 04{space*4}ldy #$04 2080 GOSUB63002:PRINT"., b4c7 c8{space*7}iny 2081 GOSUB63002:PRINT"., b4c8 b1 22{space*4}lda ($22),y 2082 GOSUB63002:PRINT"., b4ca d0 fb{space*4}bne $b4c7 2083 GOSUB63002:PRINT"., b4cc c8{space*7}iny 2084 GOSUB63002:PRINT"., b4cd 98{space*7}tya 2085 GOSUB63002:PRINT"., b4ce 65 22{space*4}adc $22 2086 GOSUB63002:PRINT"., b4d0 aa{space*7}tax 2087 GOSUB63002:PRINT"., b4d1 a0 00{space*4}ldy #$00 2088 GOSUB63002:PRINT"., b4d3 91 22{space*4}sta ($22),y 2089 GOSUB63002:PRINT"., b4d5 98{space*7}tya 2090 GOSUB63002:PRINT"., b4d6 65 23{space*4}adc $23 2100 GOSUB63002:PRINT"., b4d8 c8{space*7}iny 2101 GOSUB63002:PRINT"., b4d9 91 22{space*4}sta ($22),y 2102 GOSUB63002:PRINT"., b4db 86 22{space*4}{reverse on}stx $22{space*2}" 2103 GOSUB63002:PRINT"., b4dd 85 23{space*4}{reverse on}sta $23{space*2}" 2104 GOSUB63002:PRINT"., b4df 90 de{space*4}{reverse on}bcc $b4bf{reverse off}{arrow left}branch back" 2105 PRINT"{space*27}to $b4bf" 2106 PRINT"{space*27}& repeat!" 4999 PRINT:GOSUB63000:PRINT"{clear}":ms$="{reverse on}au revoir!{reverse off}":GOSUB63100:END 39000 PRINT"{home}";:FORi=1TO17:PRINTcl$:NEXT:PRINT"{home}";:RETURN 40098 POKEa(0),32:FORtt=1TOpp:NEXT:FORi=0TO6:POKEa(i+1),32 40099 POKEa(i),VAL(MID$(n$,i+1,1))+48:FORtt=1TOpp:NEXT:NEXT:POKEa(7),48:RETURN 40110 FORi=0TO7:POKEa(i),160:FORtt=1TOpp:NEXT 40111 POKEa(i),VAL(MID$(n$,i+1,1))+48:NEXT:RETURN 40120 FORi=0TO7:POKEp(i),160:FORtt=1TOpp:NEXT 40121 POKEp(i),VAL(MID$(n$,i+1,1))+48:NEXT:RETURN 40130 FORi=0TO7:POKEx(i),160:FORtt=1TOpp:NEXT 40131 POKEx(i),VAL(MID$(n$,i+1,1))+48:NEXT:RETURN 40140 FORi=0TO7:POKEy(i),160:FORtt=1TOpp:NEXT 40141 POKEy(i),VAL(MID$(n$,i+1,1))+48:NEXT:RETURN 40160 FORi=0TO7:POKEm(i),160:FORtt=1TOpp:NEXT 40161 POKEm(i),VAL(MID$(n$,i+1,1))+48:NEXT:RETURN 41120 FORi=0TO7:POKEp(i),160:FORtt=1TOpp:NEXT 41121 POKEp(i),PEEK(a(i)):NEXT:RETURN 41130 FORi=0TO7:POKEx(i),160:FORtt=1TOpp:NEXT 41131 POKEx(i),PEEK(a(i)):NEXT:RETURN 41140 FORi=0TO7:POKEy(i),160:FORtt=1TOpp:NEXT 41141 POKEy(i),PEEK(a(i)):NEXT:RETURN 41160 FORi=0TO7:POKEm(i),160:FORtt=1TOpp:NEXT 41161 POKEm(i),PEEK(a(i)):NEXT:RETURN 41340 FORi=0TO7:POKEa(i),160:FORtt=1TOpp:NEXT 41341 POKEa(i),PEEK(x(i)):NEXT:RETURN 41360 FORi=0TO7:POKEm(i),160:FORtt=1TOpp:NEXT 41361 POKEm(i),PEEK(x(i)):NEXT:RETURN 41410 FORi=0TO7:POKEa(i),160:FORtt=1TOpp:NEXT 41411 POKEa(i),PEEK(y(i)):NEXT:RETURN 41460 FORi=0TO7:POKEm(i),160:FORtt=1TOpp:NEXT 41461 POKEm(i),PEEK(y(i)):NEXT:RETURN 60000 REM initialize 60001 bt$="{home}":FORi=1TO24:bt$=bt$+"{down}":NEXT 60002 pt$="{red}{cm a}{sh asterisk*10}{cm s}{down}{left*12}{sh -}{right*10}{sh -}{down}{left*12}{cm z}{cm r}{sh asterisk*8}{cm r}{cm x}" 60003 pt$=pt$+"{down}{left*13}N{cm t*12}M{down}{left*14}{cm g}{=*12}{cm m}" 60004 pt$=pt$+"{down}{left*14}PO{cm t*10}PO{up*4}{left*12}" 60005 pt$=bt$+"{up*6}{right*26}"+pt$+"{black}" 60007 ml$="{home}{down*9}{right*27}" 60008 wd=40:crt=1024:PRINTCHR$(142) 60009 w2=wd/2:w3=wd-1:w1$=MID$(STR$(wd),2): 60010 w2$=MID$(STR$(w2),2):w3$=MID$(STR$(w3),2) 60019 sd$="{home}{down*9}":cl$="":FORi=1TOwd-1:cl$=cl$+" ":NEXT 60020 RETURN 63000 PRINTbt$cl$; 63001 PRINTbt$"{reverse on}return{reverse off} to continue"; 63002 GETz$:IFz$<>""THEN63002 63003 GETz$:IFz$=""THEN63003 63004 RETURN 63010 PRINTbt$cl$;:FORtt=1TO50:NEXT 63011 PRINTbt$"{cm +*8}{reverse on}return to see it happen{reverse off}{cm +*8}";:FORtt=1TO50:NEXT 63012 GETz$:IFz$<>""THEN63012 63013 GETz$:IFz$=""THEN63013 63014 RETURN 63100 FORt=1TO5:PRINTpt$ms$; 63101 PRINTpt$"{space*10}"; 63102 PRINTpt$ms$;:NEXT 63103 RETURN 63200 GOSUB63000 63201 PRINTsd$;:FORt=1TO15:PRINTcl$:NEXT:PRINTsd$;:RETURN 63300 GOSUB63100:GOSUB63010:RETURN 63400 PRINT"{home}";:FORi=1TO5:PRINTcl$:NEXT:PRINT"{home}";:RETURN 63999 GOSUB60000:PRINT"{clear}":GOTO2020 stop tok64 (bastext 1.0)