8-Bit Software Online Conversion

BadFix Source - Listing

5MODE7 10 REM 'BADFIX' Source code 20 memory`address=&70 :REM and &71 30 line`address=&72 :REM and &73 40 line`length=&74 50 : 60 FOR pass=0 TO 3 STEP 3 70 P%=&900 :REM Assembly address 80 [OPT pass 90 .start 100 LDA &18 ½Read the value of PAGE f rom &18 110 STA memory`address+1 ½Store it in memory`address 120 LDA#0 130 STA memory`address 140 TAY 150 LDA #&0D ½Load accumulator with C arriage return (&0D) 160 STA(memory`address),Y ½Write it a s first byte of program 170: 180 .outer 190 JSR update ½Increment pointer 200 LDY #0 210 LDA (memory`address),Y ½Get next program byte 220 CMP #&FF ½Is it &FF (indicating e nd of program) 230 BNE over ½If not branch to 'over' 240 LDA #7 ½Must be end of program 250 JSR &FFEE ½Sound beep 260 RTS ½and finish 270 : 280 .over 290 LDA memory`address ½Update line`a ddress to point- 300 STA line`address ½to start of n ew line 310 LDA memory`address+1 320 STA line`address+1 330 JSR update ½Update pointer twice- 340 JSR update ½to skip line number 350 LDA #3 ½Store the value 3 in line `length register 360 STA line`length ½(we are 3 bytes into the line) 370 : 380 .inner 390 INC line`length ½Increment line`l ength value to point to next byte 400 BEQ force`end ½Check to see if it exceeds maximum permitted- 410 ½length of line (255 bytes) if so, branch to 'force`end' 420 JSR update ½Update pointer 430 LDA (memory`address),Y ½Get next byte 440 CMP #&0D ½Is it a Carriage return ? (&0D) 450 BEQ carriage`return ½If so, branc h to 'carriage`return' 460 CMP #&20 ½Is it a control charact er (value less than &20) 470 BCS inner ½If not, branch back to 'inner' 480 LDA #ASC("@") ½Must be a control character 490 STA (memory`address),Y ½overwrite it with '@' 500 JMP inner ½Jump back to 'inner' 510 : 520 .carriage`return ½Must be Carriag e return 530 LDA line`length ½Get line`length value 540 LDY #2 550 STA (line`address),Y ½Write corre ct value into line length byte 560 JMP outer ½Jump back to 'outer' 570 : 580 .update ½Update memory`address 590 INC memory`address ½Increment Lo byte 600 BNE past ½If it has not reached z ero, branch to 'past' 610 INC memory`address+1 ½Lo byte has reached zero, increment Hi byte 620 : 630 .past 640 RTS ½Return from sub-routine 650 : 660 .force`end ½Force an end to the p rogram 670 LDA #&0D ½Load a Carriage return (&0D) 680 STA (memory`address),Y ½Store it as last byte of line 690 JSR update ½Update pointer 700 LDA #&FF ½Load accumulator with & FF (end of program byte) 710 LDY #0 720 STA (memory`address),Y ½Write it as last byte of program 730 LDY #2 740 STA (line`address),Y ½Also write it as line length of last line 750 LDA #7 760 JSR &FFEE ½Sound Beep 770 RTS ½and finish 780 ] 790 NEXT 800 REM *SAVE BADFIX 0900 096F