Home » CEEFAX disks » telesoftware3.adl » 27_11_87/B\OSB06
27_11_87/B\OSB06
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware3.adl |
Filename: | 27_11_87/B\OSB06 |
Read OK: | ✔ |
File size: | 0F5D bytes |
Load address: | 0800 |
Exec address: | 8023 |
File contents
10REM OSbits Module B/osb06 20REM Printing a byte as a binary, hex and decimal number 30REM Version 1.1 25.12.86 40 50*KEY1MO.3|M|NL.|M 60 70osbyte=&FFF4 80osrdch=&FFE0 90oswrch=&FFEE 100osnewl=&FFE7 110DIM code% 200 120 130FOR pass%=0 TO 3 STEP 3 140P%=code% 150 160[OPT pass% 170 180.start 190JSR osrdch \ Put a character into A 200STA accustore \ Store for A during whole routine 210 220CMP #27 \ Check for ESCAPE (&1B/27) 230BNE print_binary \ If not then print byte 240 250LDA #126 \ If ESCAPE then acknowledge 260JSR osbyte 270RTS \ And return to BASIC 280 290.accustore BRK 300.temp BRK 310.zero_flag BRK 320 330\ This part prints the byte out in binary 340\ --------------------------------------- 350 360.print_binary 370STA temp \ Store value to be written in temp 380LDX #8 390 400.binary_loop 410LDA #ASC"0" 420ROL temp \ Transfers highest bit into Carry 430ADC #0 \ This adds 0 if HSB was 0 1 if HSB was 1 440JSR oswrch \ Prints 0 or 1 450DEX \ X started with 8 loaded, this counts down 460BNE binary_loop \ Loops back if X>0 470JSR space 480 490LDA accustore 500 510\ This part prints the byte out in hexadecimal 520\ -------------------------------------------- 530 540.print_hex 550PHA \ Push A onto stack for temp storage 560LSR A \ Shift A right 4 times 570LSR A 580LSR A 590LSR A \ A now contains higher nybble 600JSR print_nybble \ Sends the HEX value of the nybble 610PLA \ Pull original value of A from stack 620AND #&F \ Mask out higher nybble 630JSR print_nybble \ Sends the HEX value of the nybble 640JSR space 650 660LDA accustore 670JMP print_decimal 680 690.print_nybble 700CLC \ Clear Carry flag prior to addition 710SED \ This next trick works in DECIMAL mode 720ADC #&90 \ 0-9 ~ &90-&99 A-F ~ &0-&5 (+Carry set) 730ADC #&40 \ 0-9 ~ &30-&39 A-F ~ &41-&46 740CLD \ Clear Decimal flag 750JSR oswrch 760RTS 770 780\ This part prints the byte out in decimal, stripping leading zeros 790\ ----------------------------------------------------------------- 800 810.print_decimal 820LDY #0 830STY zero_flag \ Clear zero_flag i.e. don't print zeros yet 840LDY #100 850JSR digit \ Calculate number of 100s 860LDY #10 870JSR digit \ Calculate number of 10s 880LDY #1 890STY zero_flag \ We always want this last zero 900JSR digit \ Calculate number of units 910JSR osnewl 920JMP start 930 940.digit \ Calculates number of times Y fits into A 950STY temp 960LDX #0 970 980.digit_loop 990CMP temp \ Is A < temp? 1000BCC over_digit \ If so don't subtract any more 1010INX 1020SEC 1030SBC temp \ Subtract temp from A 1040JMP digit_loop 1050 1060.over_digit \ X now holds number of times Y fitted into A 1070PHA 1080TXA \ Transfer X into A, setting flags 1090BEQ no_flag_set \ If X>0 then don't set flag 1100INC zero_flag \ Otherwise increase flag by 1, i.e. set it 1110.no_flag_set 1120LDY zero_flag \ Load flag into Y, if it is zero ... 1130BEQ end_digit \ ... then don't bother printing the 0 1140CLC 1150ADC #ASC "0" \ Otherwise add ASC"0" (48) 1160JSR oswrch \ And print digit 1170 1180.end_digit 1190PLA \ Pull remaining part of number from stack 1200RTS 1210 1220.space \ Subroutine prints a space 1230LDA #32 1240JSR oswrch 1250RTS 1260] 1270NEXT 1280CALL code%
� OSbits Module B/osb06 :� Printing a byte as a binary, hex and decimal number � Version 1.1 25.12.86 ( 2*KEY1MO.3|M|NL.|M < Fosbyte=&FFF4 Posrdch=&FFE0 Zoswrch=&FFEE dosnewl=&FFE7 n� code% 200 x �� pass%=0 � 3 � 3 �P%=code% � �[OPT pass% � � .start �7JSR osrdch \ Put a character into A �ASTA accustore \ Store for A during whole routine � �:CMP #27 \ Check for ESCAPE (&1B/27) �7BNE print_binary \ If not then print byte � �;LDA #126 \ If ESCAPE then acknowledge JSR osbyte 4RTS \ And return to BASIC ".accustore BRK , .temp BRK 6.zero_flag BRK @ J1\ This part prints the byte out in binary T1\ --------------------------------------- ^ h.print_binary rBSTA temp \ Store value to be written in temp | LDX #8 � �.binary_loop � LDA #�"0" �AROL temp \ Transfers highest bit into Carry �HADC #0 \ This adds 0 if HSB was 0 1 if HSB was 1 �.JSR oswrch \ Prints 0 or 1 �JDEX \ X started with 8 loaded, this counts down �2BNE binary_loop \ Loops back if X>0 � JSR space � �LDA accustore � �6\ This part prints the byte out in hexadecimal 6\ -------------------------------------------- .print_hex &CPHA \ Push A onto stack for temp storage 06LSR A \ Shift A right 4 times : LSR A D LSR A N=LSR A \ A now contains higher nybble XBJSR print_nybble \ Sends the HEX value of the nybble bDPLA \ Pull original value of A from stack l5� #&F \ Mask out higher nybble vBJSR print_nybble \ Sends the HEX value of the nybble � JSR space � �LDA accustore �JMP print_decimal � �.print_nybble �CCLC \ Clear Carry flag prior to addition �FSED \ This next trick works in DECIMAL mode �HADC #&90 \ 0-9 ~ &90-&99 A-F ~ &0-&5 (+Carry set) �=ADC #&40 \ 0-9 ~ &30-&39 A-F ~ &41-&46 �3CLD \ Clear Decimal flag �JSR oswrch �RTS K\ This part prints the byte out in decimal, stripping leading zeros K\ ----------------------------------------------------------------- *.print_decimal 4 LDY #0 >KSTY zero_flag \ Clear zero_flag i.e. don't print zeros yet HLDY #100 R9JSR digit \ Calculate number of 100s \LDY #10 f8JSR digit \ Calculate number of 10s p LDY #1 z>STY zero_flag \ We always want this last zero �:JSR digit \ Calculate number of units �JSR osnewl � JMP start � �I.digit \ Calculates number of times Y fits into A �STY temp � LDX #0 � �.digit_loop �-CMP temp \ Is A < temp? �>BCC over_digit \ If so don't subtract any more �INX �SEC 5SBC temp \ Subtract temp from A JMP digit_loop $L.over_digit \ X now holds number of times Y fitted into A .PHA 8ATXA \ Transfer X into A, setting flags B;BEQ no_flag_set \ If X>0 then don't set flag LJINC zero_flag \ Otherwise increase flag by 1, i.e. set it V.no_flag_set `DLDY zero_flag \ Load flag into Y, if it is zero ... jEBEQ end_digit \ ... then don't bother printing the 0 tCLC ~6ADC #� "0" \ Otherwise add �"0" (48) �0JSR oswrch \ And print digit � �.end_digit �IPLA \ Pull remaining part of number from stack �RTS � �:.space \ Subroutine prints a space �LDA #32 �JSR oswrch �RTS �] �� � code% �
00000000 0d 00 0a 1c f4 20 20 4f 53 62 69 74 73 20 4d 6f |..... OSbits Mo| 00000010 64 75 6c 65 20 42 2f 6f 73 62 30 36 0d 00 14 3a |dule B/osb06...:| 00000020 f4 20 20 50 72 69 6e 74 69 6e 67 20 61 20 62 79 |. Printing a by| 00000030 74 65 20 61 73 20 61 20 62 69 6e 61 72 79 2c 20 |te as a binary, | 00000040 68 65 78 20 61 6e 64 20 64 65 63 69 6d 61 6c 20 |hex and decimal | 00000050 6e 75 6d 62 65 72 0d 00 1e 1b f4 20 20 56 65 72 |number..... Ver| 00000060 73 69 6f 6e 20 31 2e 31 20 32 35 2e 31 32 2e 38 |sion 1.1 25.12.8| 00000070 36 0d 00 28 05 20 0d 00 32 15 2a 4b 45 59 31 4d |6..(. ..2.*KEY1M| 00000080 4f 2e 33 7c 4d 7c 4e 4c 2e 7c 4d 0d 00 3c 05 20 |O.3|M|NL.|M..<. | 00000090 0d 00 46 10 6f 73 62 79 74 65 3d 26 46 46 46 34 |..F.osbyte=&FFF4| 000000a0 0d 00 50 10 6f 73 72 64 63 68 3d 26 46 46 45 30 |..P.osrdch=&FFE0| 000000b0 0d 00 5a 10 6f 73 77 72 63 68 3d 26 46 46 45 45 |..Z.oswrch=&FFEE| 000000c0 0d 00 64 10 6f 73 6e 65 77 6c 3d 26 46 46 45 37 |..d.osnewl=&FFE7| 000000d0 0d 00 6e 0f de 20 63 6f 64 65 25 20 32 30 30 0d |..n.. code% 200.| 000000e0 00 78 05 20 0d 00 82 15 e3 20 70 61 73 73 25 3d |.x. ..... pass%=| 000000f0 30 20 b8 20 33 20 88 20 33 0d 00 8c 0c 50 25 3d |0 . 3 . 3....P%=| 00000100 63 6f 64 65 25 0d 00 96 05 20 0d 00 a0 0e 5b 4f |code%.... ....[O| 00000110 50 54 20 70 61 73 73 25 0d 00 aa 05 20 0d 00 b4 |PT pass%.... ...| 00000120 0a 2e 73 74 61 72 74 0d 00 be 37 4a 53 52 20 6f |..start...7JSR o| 00000130 73 72 64 63 68 20 20 20 20 20 20 20 20 20 20 20 |srdch | 00000140 20 20 20 20 20 20 5c 20 50 75 74 20 61 20 63 68 | \ Put a ch| 00000150 61 72 61 63 74 65 72 20 69 6e 74 6f 20 41 0d 00 |aracter into A..| 00000160 c8 41 53 54 41 20 61 63 63 75 73 74 6f 72 65 20 |.ASTA accustore | 00000170 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 53 | \ S| 00000180 74 6f 72 65 20 66 6f 72 20 41 20 64 75 72 69 6e |tore for A durin| 00000190 67 20 77 68 6f 6c 65 20 72 6f 75 74 69 6e 65 0d |g whole routine.| 000001a0 00 d2 05 20 0d 00 dc 3a 43 4d 50 20 23 32 37 20 |... ...:CMP #27 | 000001b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000001c0 20 20 20 5c 20 43 68 65 63 6b 20 66 6f 72 20 45 | \ Check for E| 000001d0 53 43 41 50 45 20 28 26 31 42 2f 32 37 29 0d 00 |SCAPE (&1B/27)..| 000001e0 e6 37 42 4e 45 20 70 72 69 6e 74 5f 62 69 6e 61 |.7BNE print_bina| 000001f0 72 79 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 |ry \ I| 00000200 66 20 6e 6f 74 20 74 68 65 6e 20 70 72 69 6e 74 |f not then print| 00000210 20 62 79 74 65 0d 00 f0 05 20 0d 00 fa 3b 4c 44 | byte.... ...;LD| 00000220 41 20 23 31 32 36 20 20 20 20 20 20 20 20 20 20 |A #126 | 00000230 20 20 20 20 20 20 20 20 20 5c 20 49 66 20 45 53 | \ If ES| 00000240 43 41 50 45 20 74 68 65 6e 20 61 63 6b 6e 6f 77 |CAPE then acknow| 00000250 6c 65 64 67 65 0d 01 04 0e 4a 53 52 20 6f 73 62 |ledge....JSR osb| 00000260 79 74 65 0d 01 0e 34 52 54 53 20 20 20 20 20 20 |yte...4RTS | 00000270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000280 20 20 5c 20 41 6e 64 20 72 65 74 75 72 6e 20 74 | \ And return t| 00000290 6f 20 42 41 53 49 43 0d 01 18 05 20 0d 01 22 12 |o BASIC.... ..".| 000002a0 2e 61 63 63 75 73 74 6f 72 65 20 42 52 4b 0d 01 |.accustore BRK..| 000002b0 2c 0d 2e 74 65 6d 70 20 42 52 4b 0d 01 36 12 2e |,..temp BRK..6..| 000002c0 7a 65 72 6f 5f 66 6c 61 67 20 42 52 4b 0d 01 40 |zero_flag BRK..@| 000002d0 05 20 0d 01 4a 31 5c 20 20 20 20 20 54 68 69 73 |. ..J1\ This| 000002e0 20 70 61 72 74 20 70 72 69 6e 74 73 20 74 68 65 | part prints the| 000002f0 20 62 79 74 65 20 6f 75 74 20 69 6e 20 62 69 6e | byte out in bin| 00000300 61 72 79 0d 01 54 31 5c 20 20 20 20 20 2d 2d 2d |ary..T1\ ---| 00000310 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000330 2d 2d 2d 2d 0d 01 5e 05 20 0d 01 68 11 2e 70 72 |----..^. ..h..pr| 00000340 69 6e 74 5f 62 69 6e 61 72 79 0d 01 72 42 53 54 |int_binary..rBST| 00000350 41 20 74 65 6d 70 20 20 20 20 20 20 20 20 20 20 |A temp | 00000360 20 20 20 20 20 20 20 20 20 5c 20 53 74 6f 72 65 | \ Store| 00000370 20 76 61 6c 75 65 20 74 6f 20 62 65 20 77 72 69 | value to be wri| 00000380 74 74 65 6e 20 69 6e 20 74 65 6d 70 0d 01 7c 0a |tten in temp..|.| 00000390 4c 44 58 20 23 38 0d 01 86 05 20 0d 01 90 10 2e |LDX #8.... .....| 000003a0 62 69 6e 61 72 79 5f 6c 6f 6f 70 0d 01 9a 0d 4c |binary_loop....L| 000003b0 44 41 20 23 97 22 30 22 0d 01 a4 41 52 4f 4c 20 |DA #."0"...AROL | 000003c0 74 65 6d 70 20 20 20 20 20 20 20 20 20 20 20 20 |temp | 000003d0 20 20 20 20 20 20 20 5c 20 54 72 61 6e 73 66 65 | \ Transfe| 000003e0 72 73 20 68 69 67 68 65 73 74 20 62 69 74 20 69 |rs highest bit i| 000003f0 6e 74 6f 20 43 61 72 72 79 0d 01 ae 48 41 44 43 |nto Carry...HADC| 00000400 20 23 30 20 20 20 20 20 20 20 20 20 20 20 20 20 | #0 | 00000410 20 20 20 20 20 20 20 20 5c 20 54 68 69 73 20 61 | \ This a| 00000420 64 64 73 20 30 20 69 66 20 48 53 42 20 77 61 73 |dds 0 if HSB was| 00000430 20 30 20 31 20 69 66 20 48 53 42 20 77 61 73 20 | 0 1 if HSB was | 00000440 31 0d 01 b8 2e 4a 53 52 20 6f 73 77 72 63 68 20 |1....JSR oswrch | 00000450 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000460 5c 20 50 72 69 6e 74 73 20 30 20 6f 72 20 31 0d |\ Prints 0 or 1.| 00000470 01 c2 4a 44 45 58 20 20 20 20 20 20 20 20 20 20 |..JDEX | 00000480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00000490 58 20 73 74 61 72 74 65 64 20 77 69 74 68 20 38 |X started with 8| 000004a0 20 6c 6f 61 64 65 64 2c 20 74 68 69 73 20 63 6f | loaded, this co| 000004b0 75 6e 74 73 20 64 6f 77 6e 0d 01 cc 32 42 4e 45 |unts down...2BNE| 000004c0 20 62 69 6e 61 72 79 5f 6c 6f 6f 70 20 20 20 20 | binary_loop | 000004d0 20 20 20 20 20 20 20 20 5c 20 4c 6f 6f 70 73 20 | \ Loops | 000004e0 62 61 63 6b 20 69 66 20 58 3e 30 0d 01 d6 0d 4a |back if X>0....J| 000004f0 53 52 20 73 70 61 63 65 0d 01 e0 05 20 0d 01 ea |SR space.... ...| 00000500 11 4c 44 41 20 61 63 63 75 73 74 6f 72 65 0d 01 |.LDA accustore..| 00000510 f4 05 20 0d 01 fe 36 5c 20 20 20 20 20 54 68 69 |.. ...6\ Thi| 00000520 73 20 70 61 72 74 20 70 72 69 6e 74 73 20 74 68 |s part prints th| 00000530 65 20 62 79 74 65 20 6f 75 74 20 69 6e 20 68 65 |e byte out in he| 00000540 78 61 64 65 63 69 6d 61 6c 0d 02 08 36 5c 20 20 |xadecimal...6\ | 00000550 20 20 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d | -------------| 00000560 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000570 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d |---------------.| 00000580 02 12 05 20 0d 02 1c 0e 2e 70 72 69 6e 74 5f 68 |... .....print_h| 00000590 65 78 0d 02 26 43 50 48 41 20 20 20 20 20 20 20 |ex..&CPHA | 000005a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000005b0 20 5c 20 50 75 73 68 20 41 20 6f 6e 74 6f 20 73 | \ Push A onto s| 000005c0 74 61 63 6b 20 66 6f 72 20 74 65 6d 70 20 73 74 |tack for temp st| 000005d0 6f 72 61 67 65 0d 02 30 36 4c 53 52 20 41 20 20 |orage..06LSR A | 000005e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000005f0 20 20 20 20 5c 20 53 68 69 66 74 20 41 20 72 69 | \ Shift A ri| 00000600 67 68 74 20 34 20 74 69 6d 65 73 0d 02 3a 09 4c |ght 4 times..:.L| 00000610 53 52 20 41 0d 02 44 09 4c 53 52 20 41 0d 02 4e |SR A..D.LSR A..N| 00000620 3d 4c 53 52 20 41 20 20 20 20 20 20 20 20 20 20 |=LSR A | 00000630 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 41 20 | \ A | 00000640 6e 6f 77 20 63 6f 6e 74 61 69 6e 73 20 68 69 67 |now contains hig| 00000650 68 65 72 20 6e 79 62 62 6c 65 0d 02 58 42 4a 53 |her nybble..XBJS| 00000660 52 20 70 72 69 6e 74 5f 6e 79 62 62 6c 65 20 20 |R print_nybble | 00000670 20 20 20 20 20 20 20 20 20 5c 20 53 65 6e 64 73 | \ Sends| 00000680 20 74 68 65 20 48 45 58 20 76 61 6c 75 65 20 6f | the HEX value o| 00000690 66 20 74 68 65 20 6e 79 62 62 6c 65 0d 02 62 44 |f the nybble..bD| 000006a0 50 4c 41 20 20 20 20 20 20 20 20 20 20 20 20 20 |PLA | 000006b0 20 20 20 20 20 20 20 20 20 20 20 5c 20 50 75 6c | \ Pul| 000006c0 6c 20 6f 72 69 67 69 6e 61 6c 20 76 61 6c 75 65 |l original value| 000006d0 20 6f 66 20 41 20 66 72 6f 6d 20 73 74 61 63 6b | of A from stack| 000006e0 0d 02 6c 35 80 20 23 26 46 20 20 20 20 20 20 20 |..l5. #&F | 000006f0 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 4d | \ M| 00000700 61 73 6b 20 6f 75 74 20 68 69 67 68 65 72 20 6e |ask out higher n| 00000710 79 62 62 6c 65 0d 02 76 42 4a 53 52 20 70 72 69 |ybble..vBJSR pri| 00000720 6e 74 5f 6e 79 62 62 6c 65 20 20 20 20 20 20 20 |nt_nybble | 00000730 20 20 20 20 5c 20 53 65 6e 64 73 20 74 68 65 20 | \ Sends the | 00000740 48 45 58 20 76 61 6c 75 65 20 6f 66 20 74 68 65 |HEX value of the| 00000750 20 6e 79 62 62 6c 65 0d 02 80 0d 4a 53 52 20 73 | nybble....JSR s| 00000760 70 61 63 65 0d 02 8a 05 20 0d 02 94 11 4c 44 41 |pace.... ....LDA| 00000770 20 61 63 63 75 73 74 6f 72 65 0d 02 9e 15 4a 4d | accustore....JM| 00000780 50 20 70 72 69 6e 74 5f 64 65 63 69 6d 61 6c 0d |P print_decimal.| 00000790 02 a8 06 20 20 0d 02 b2 11 2e 70 72 69 6e 74 5f |... .....print_| 000007a0 6e 79 62 62 6c 65 0d 02 bc 43 43 4c 43 20 20 20 |nybble...CCLC | 000007b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000007c0 20 20 20 20 20 5c 20 43 6c 65 61 72 20 43 61 72 | \ Clear Car| 000007d0 72 79 20 66 6c 61 67 20 70 72 69 6f 72 20 74 6f |ry flag prior to| 000007e0 20 61 64 64 69 74 69 6f 6e 0d 02 c6 46 53 45 44 | addition...FSED| 000007f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000800 20 20 20 20 20 20 20 20 5c 20 54 68 69 73 20 6e | \ This n| 00000810 65 78 74 20 74 72 69 63 6b 20 77 6f 72 6b 73 20 |ext trick works | 00000820 69 6e 20 44 45 43 49 4d 41 4c 20 6d 6f 64 65 0d |in DECIMAL mode.| 00000830 02 d0 48 41 44 43 20 23 26 39 30 20 20 20 20 20 |..HADC #&90 | 00000840 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00000850 30 2d 39 20 7e 20 26 39 30 2d 26 39 39 20 20 41 |0-9 ~ &90-&99 A| 00000860 2d 46 20 7e 20 26 30 2d 26 35 20 28 2b 43 61 72 |-F ~ &0-&5 (+Car| 00000870 72 79 20 73 65 74 29 0d 02 da 3d 41 44 43 20 23 |ry set)...=ADC #| 00000880 26 34 30 20 20 20 20 20 20 20 20 20 20 20 20 20 |&40 | 00000890 20 20 20 20 20 20 5c 20 30 2d 39 20 7e 20 26 33 | \ 0-9 ~ &3| 000008a0 30 2d 26 33 39 20 20 41 2d 46 20 7e 20 26 34 31 |0-&39 A-F ~ &41| 000008b0 2d 26 34 36 0d 02 e4 33 43 4c 44 20 20 20 20 20 |-&46...3CLD | 000008c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000008d0 20 20 20 5c 20 43 6c 65 61 72 20 44 65 63 69 6d | \ Clear Decim| 000008e0 61 6c 20 66 6c 61 67 0d 02 ee 0e 4a 53 52 20 6f |al flag....JSR o| 000008f0 73 77 72 63 68 0d 02 f8 07 52 54 53 0d 03 02 05 |swrch....RTS....| 00000900 20 0d 03 0c 4b 5c 20 20 20 20 20 54 68 69 73 20 | ...K\ This | 00000910 70 61 72 74 20 70 72 69 6e 74 73 20 74 68 65 20 |part prints the | 00000920 62 79 74 65 20 6f 75 74 20 69 6e 20 64 65 63 69 |byte out in deci| 00000930 6d 61 6c 2c 20 73 74 72 69 70 70 69 6e 67 20 6c |mal, stripping l| 00000940 65 61 64 69 6e 67 20 7a 65 72 6f 73 0d 03 16 4b |eading zeros...K| 00000950 5c 20 20 20 20 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |\ ----------| 00000960 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000990 2d 2d 2d 2d 2d 2d 2d 0d 03 20 05 20 0d 03 2a 12 |-------.. . ..*.| 000009a0 2e 70 72 69 6e 74 5f 64 65 63 69 6d 61 6c 0d 03 |.print_decimal..| 000009b0 34 0a 4c 44 59 20 23 30 0d 03 3e 4b 53 54 59 20 |4.LDY #0..>KSTY | 000009c0 7a 65 72 6f 5f 66 6c 61 67 20 20 20 20 20 20 20 |zero_flag | 000009d0 20 20 20 20 20 20 20 5c 20 43 6c 65 61 72 20 7a | \ Clear z| 000009e0 65 72 6f 5f 66 6c 61 67 20 69 2e 65 2e 20 64 6f |ero_flag i.e. do| 000009f0 6e 27 74 20 70 72 69 6e 74 20 7a 65 72 6f 73 20 |n't print zeros | 00000a00 79 65 74 0d 03 48 0c 4c 44 59 20 23 31 30 30 0d |yet..H.LDY #100.| 00000a10 03 52 39 4a 53 52 20 64 69 67 69 74 20 20 20 20 |.R9JSR digit | 00000a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00000a30 43 61 6c 63 75 6c 61 74 65 20 6e 75 6d 62 65 72 |Calculate number| 00000a40 20 6f 66 20 31 30 30 73 0d 03 5c 0b 4c 44 59 20 | of 100s..\.LDY | 00000a50 23 31 30 0d 03 66 38 4a 53 52 20 64 69 67 69 74 |#10..f8JSR digit| 00000a60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000a70 20 20 5c 20 43 61 6c 63 75 6c 61 74 65 20 6e 75 | \ Calculate nu| 00000a80 6d 62 65 72 20 6f 66 20 31 30 73 0d 03 70 0a 4c |mber of 10s..p.L| 00000a90 44 59 20 23 31 0d 03 7a 3e 53 54 59 20 7a 65 72 |DY #1..z>STY zer| 00000aa0 6f 5f 66 6c 61 67 20 20 20 20 20 20 20 20 20 20 |o_flag | 00000ab0 20 20 20 20 5c 20 57 65 20 61 6c 77 61 79 73 20 | \ We always | 00000ac0 77 61 6e 74 20 74 68 69 73 20 6c 61 73 74 20 7a |want this last z| 00000ad0 65 72 6f 0d 03 84 3a 4a 53 52 20 64 69 67 69 74 |ero...:JSR digit| 00000ae0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000af0 20 20 5c 20 43 61 6c 63 75 6c 61 74 65 20 6e 75 | \ Calculate nu| 00000b00 6d 62 65 72 20 6f 66 20 75 6e 69 74 73 0d 03 8e |mber of units...| 00000b10 0e 4a 53 52 20 6f 73 6e 65 77 6c 0d 03 98 0d 4a |.JSR osnewl....J| 00000b20 4d 50 20 73 74 61 72 74 0d 03 a2 05 20 0d 03 ac |MP start.... ...| 00000b30 49 2e 64 69 67 69 74 20 20 20 20 20 20 20 20 20 |I.digit | 00000b40 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 43 61 | \ Ca| 00000b50 6c 63 75 6c 61 74 65 73 20 6e 75 6d 62 65 72 20 |lculates number | 00000b60 6f 66 20 74 69 6d 65 73 20 59 20 66 69 74 73 20 |of times Y fits | 00000b70 69 6e 74 6f 20 41 0d 03 b6 0c 53 54 59 20 74 65 |into A....STY te| 00000b80 6d 70 0d 03 c0 0a 4c 44 58 20 23 30 0d 03 ca 05 |mp....LDX #0....| 00000b90 20 0d 03 d4 0f 2e 64 69 67 69 74 5f 6c 6f 6f 70 | .....digit_loop| 00000ba0 0d 03 de 2d 43 4d 50 20 74 65 6d 70 20 20 20 20 |...-CMP temp | 00000bb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 00000bc0 20 49 73 20 41 20 3c 20 74 65 6d 70 3f 0d 03 e8 | Is A < temp?...| 00000bd0 3e 42 43 43 20 6f 76 65 72 5f 64 69 67 69 74 20 |>BCC over_digit | 00000be0 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 66 | \ If| 00000bf0 20 73 6f 20 64 6f 6e 27 74 20 73 75 62 74 72 61 | so don't subtra| 00000c00 63 74 20 61 6e 79 20 6d 6f 72 65 0d 03 f2 07 49 |ct any more....I| 00000c10 4e 58 0d 03 fc 07 53 45 43 0d 04 06 35 53 42 43 |NX....SEC...5SBC| 00000c20 20 74 65 6d 70 20 20 20 20 20 20 20 20 20 20 20 | temp | 00000c30 20 20 20 20 20 20 20 20 5c 20 53 75 62 74 72 61 | \ Subtra| 00000c40 63 74 20 74 65 6d 70 20 66 72 6f 6d 20 41 0d 04 |ct temp from A..| 00000c50 10 12 4a 4d 50 20 64 69 67 69 74 5f 6c 6f 6f 70 |..JMP digit_loop| 00000c60 0d 04 1a 05 20 0d 04 24 4c 2e 6f 76 65 72 5f 64 |.... ..$L.over_d| 00000c70 69 67 69 74 20 20 20 20 20 20 20 20 20 20 20 20 |igit | 00000c80 20 20 20 20 5c 20 58 20 6e 6f 77 20 68 6f 6c 64 | \ X now hold| 00000c90 73 20 6e 75 6d 62 65 72 20 6f 66 20 74 69 6d 65 |s number of time| 00000ca0 73 20 59 20 66 69 74 74 65 64 20 69 6e 74 6f 20 |s Y fitted into | 00000cb0 41 0d 04 2e 07 50 48 41 0d 04 38 41 54 58 41 20 |A....PHA..8ATXA | 00000cc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000cd0 20 20 20 20 20 20 20 5c 20 54 72 61 6e 73 66 65 | \ Transfe| 00000ce0 72 20 58 20 69 6e 74 6f 20 41 2c 20 73 65 74 74 |r X into A, sett| 00000cf0 69 6e 67 20 66 6c 61 67 73 0d 04 42 3b 42 45 51 |ing flags..B;BEQ| 00000d00 20 6e 6f 5f 66 6c 61 67 5f 73 65 74 20 20 20 20 | no_flag_set | 00000d10 20 20 20 20 20 20 20 20 5c 20 49 66 20 58 3e 30 | \ If X>0| 00000d20 20 74 68 65 6e 20 64 6f 6e 27 74 20 73 65 74 20 | then don't set | 00000d30 66 6c 61 67 0d 04 4c 4a 49 4e 43 20 7a 65 72 6f |flag..LJINC zero| 00000d40 5f 66 6c 61 67 20 20 20 20 20 20 20 20 20 20 20 |_flag | 00000d50 20 20 20 5c 20 4f 74 68 65 72 77 69 73 65 20 69 | \ Otherwise i| 00000d60 6e 63 72 65 61 73 65 20 66 6c 61 67 20 62 79 20 |ncrease flag by | 00000d70 31 2c 20 69 2e 65 2e 20 73 65 74 20 69 74 0d 04 |1, i.e. set it..| 00000d80 56 10 2e 6e 6f 5f 66 6c 61 67 5f 73 65 74 0d 04 |V..no_flag_set..| 00000d90 60 44 4c 44 59 20 7a 65 72 6f 5f 66 6c 61 67 20 |`DLDY zero_flag | 00000da0 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 4c | \ L| 00000db0 6f 61 64 20 66 6c 61 67 20 69 6e 74 6f 20 59 2c |oad flag into Y,| 00000dc0 20 69 66 20 69 74 20 69 73 20 7a 65 72 6f 20 2e | if it is zero .| 00000dd0 2e 2e 0d 04 6a 45 42 45 51 20 65 6e 64 5f 64 69 |....jEBEQ end_di| 00000de0 67 69 74 20 20 20 20 20 20 20 20 20 20 20 20 20 |git | 00000df0 20 5c 20 2e 2e 2e 20 74 68 65 6e 20 64 6f 6e 27 | \ ... then don'| 00000e00 74 20 62 6f 74 68 65 72 20 70 72 69 6e 74 69 6e |t bother printin| 00000e10 67 20 74 68 65 20 30 0d 04 74 07 43 4c 43 0d 04 |g the 0..t.CLC..| 00000e20 7e 36 41 44 43 20 23 97 20 22 30 22 20 20 20 20 |~6ADC #. "0" | 00000e30 20 20 20 20 20 20 20 20 20 20 20 5c 20 4f 74 68 | \ Oth| 00000e40 65 72 77 69 73 65 20 61 64 64 20 97 22 30 22 20 |erwise add ."0" | 00000e50 28 34 38 29 0d 04 88 30 4a 53 52 20 6f 73 77 72 |(48)...0JSR oswr| 00000e60 63 68 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |ch | 00000e70 20 20 20 5c 20 41 6e 64 20 70 72 69 6e 74 20 64 | \ And print d| 00000e80 69 67 69 74 0d 04 92 05 20 0d 04 9c 0e 2e 65 6e |igit.... .....en| 00000e90 64 5f 64 69 67 69 74 0d 04 a6 49 50 4c 41 20 20 |d_digit...IPLA | 00000ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000eb0 20 20 20 20 20 20 5c 20 50 75 6c 6c 20 72 65 6d | \ Pull rem| 00000ec0 61 69 6e 69 6e 67 20 70 61 72 74 20 6f 66 20 6e |aining part of n| 00000ed0 75 6d 62 65 72 20 66 72 6f 6d 20 73 74 61 63 6b |umber from stack| 00000ee0 0d 04 b0 07 52 54 53 0d 04 ba 05 20 0d 04 c4 3a |....RTS.... ...:| 00000ef0 2e 73 70 61 63 65 20 20 20 20 20 20 20 20 20 20 |.space | 00000f00 20 20 20 20 20 20 20 20 20 20 20 5c 20 53 75 62 | \ Sub| 00000f10 72 6f 75 74 69 6e 65 20 70 72 69 6e 74 73 20 61 |routine prints a| 00000f20 20 73 70 61 63 65 0d 04 ce 0b 4c 44 41 20 23 33 | space....LDA #3| 00000f30 32 0d 04 d8 0e 4a 53 52 20 6f 73 77 72 63 68 0d |2....JSR oswrch.| 00000f40 04 e2 07 52 54 53 0d 04 ec 05 5d 0d 04 f6 05 ed |...RTS....].....| 00000f50 0d 05 00 0b d6 20 63 6f 64 65 25 0d ff |..... code%..| 00000f5d