Home » Archimedes archive » Archimedes World » AW-1997-02.adf » !Assembler_Assembler » FProcess
FProcess
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 » Archimedes archive » Archimedes World » AW-1997-02.adf » !Assembler_Assembler |
Filename: | FProcess |
Read OK: | ✔ |
File size: | 1209 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10ON ERROR REPORT:PRINT" at line ";ERL:END 20PROCassemble 30CALL code 40END 50: 60DEFPROCassemble 70DIM code 2048 80REM Allocate buffers inside code, so we don't get problems with long ADRs 90in_file=code+128 100out_file=code+256 110code=code+384 120: 130REM Example of two-pass assembly; on the first time around, we 140REM don't want errors reported, hence OPT 0 150: 160FOR pass=0 TO 2 STEP 2 170P%=code 180[OPT pass 190: 200 MOV R12,R14 ; Keep BASIC return address in R12 210 : 220 ADR R0,in_prompt 230 ADR R1,in_file 240 BL input_routine ; Get input filename 250 : 260 ADR R0,out_prompt 270 ADR R1,out_file 280 BL input_routine ; Get output filename 290 : 300 MOV R0,#&43 310 ADR R1,in_file 320 SWI "OS_Find" ; Open input file 330 CMP R0,#0 340 BEQ file_error ; Finish now if there's been an error 350 MOV R6,R0 ; Otherwise store the file handle in R6 360 : 370 MOV R0,#&83 380 ADR R1,out_file 390 SWI "OS_Find" ; Create and open output file 400 CMP R0,#0 410 BEQ file_error_close_input ; Finsh and close the input file if 420 ; there's been an error 430 MOV R7,R0 ; Otherwise store the file handle in R7 440 : 450.process_file ; Start of file processing loop 460 MOV R1,R6 470 SWI "OS_BGet" ; Get next byte from input file into R0 480 BCS file_finished ; Check for end-of-file, and if we've 490 ; reached it, jump out of the loop 500 CMP R0,#65 ; } These four comparisons make sure 510 BLT skip_byte ; } that a byte is changed only if it 520 CMP R0,#90 ; } is less than 65 or greater than 90 530 BGT skip_byte ; } (i.e. it is a capital letter) 540 ADD R0,R0,#32 ; Changes letter to lower case 550.skip_byte 560 MOV R1,R7 ; } Put byte (altered or otherwise) 570 SWI "OS_BPut" ; } to output file 580 B process_file ; Loop round again 590 : 600.file_finished 610 MOV R0,#0 620 MOV R1,R6 630 SWI "OS_Find" ; Close input file 640 MOV R1,R7 650 SWI "OS_Find" ; Close output file 660 MOV R0,#18 670 ADR R1,out_file 680 MOV R2,#&1000 ; } 690 SUB R2,R2,#1 ; } &FFF is what we want (see magazine) 700 SWI "OS_File" ; Set filetype of output to text 710 : 720 MOV PC,R12 ; Return to BASIC 730 : 740.file_error_close_input ; Called when input file has been opened 750 ; but the output file hasn't 760 MOV R0,#0 770 MOV R1,R6 780 SWI "OS_Find" ; Close input file 790.file_error 800 SWI "OS_WriteS" ; Display error message 810 EQUS "Couldn't open files":EQUB 0 820 ALIGN 830 SWI "OS_NewLine" 840 MOV PC,R12 ; Return to BASIC 850 : 860.input_routine ; BL here with R0 > prompt 870 ; R1 > 128 byte buffer 880 ; ARM chip does R14 > return address 890 : 900 SWI "OS_Write0" ; Display prompt passed in R0 910 MOV R0,R1 ; Move buffer to R0 for OS_ReadLine 920 MOV R1,#128 ; 128 byte limit 930 MOV R2,#33 ; No spaces / ctrl chars allowed 940 MOV R3,#126 ; No top-bit set characters either 950 SWI "OS_ReadLine" ; Call OS routine to get input 960 MOVCS PC,R12 ; If Escape pressed, exit to BASIC... 970 MOV PC,R14 ; ...otherwise return back to caller 980 : 990.in_prompt EQUS " In filename: ":EQUB 0 1000.out_prompt EQUS "Out filename: ":EQUB 0 1010]:NEXT 1020ENDPROC
� � �:�" at line ";�:� �assemble � code (� 2: <��assemble F� code 2048 PK� Allocate buffers inside code, so we don't get problems with long ADRs Zin_file=code+128 dout_file=code+256 ncode=code+384 x: �@� Example of two-pass assembly; on the first time around, we �-� don't want errors reported, hence OPT 0 �: �� pass=0 � 2 � 2 �P%=code � [OPT pass �: �N MOV R12,R14 ; Keep BASIC return address in R12 � : �$ ADR R0,in_prompt �" ADR R1,in_file �@ BL input_routine ; Get input filename � : % ADR R0,out_prompt # ADR R1,out_file A BL input_routine ; Get output filename " : , MOV R0,#&43 6" ADR R1,in_file @= SWI "OS_Find" ; Open input file J CMP R0,#0 TQ BEQ file_error ; Finish now if there's been an error ^S MOV R6,R0 ; Otherwise store the file handle in R6 h : r MOV R0,#&83 |# ADR R1,out_file �H SWI "OS_Find" ; Create and open output file � CMP R0,#0 �R BEQ file_error_close_input ; Finsh and close the input file if �G ; there's been an error �S MOV R7,R0 ; Otherwise store the file handle in R7 � : �K.process_file ; Start of file processing loop � MOV R1,R6 �S SWI "OS_BGet" ; Get next byte from input file into R0 �Q BCS file_finished ; Check for end-of-file, and if we've �O ; reached it, jump out of the loop �P CMP R0,#65 ; } These four comparisons make sure �Q BLT skip_byte ; } that a byte is changed only if it R CMP R0,#90 ; } is less than 65 or greater than 90 M BGT skip_byte ; } (i.e. it is a capital letter) J ADD R0,R0,#32 ; Changes letter to lower case &.skip_byte 0O MOV R1,R7 ; } Put byte (altered or otherwise) :> SWI "OS_BPut" ; } to output file D> B process_file ; Loop round again N : X.file_finished b MOV R0,#0 l MOV R1,R6 v> SWI "OS_Find" ; Close input file � MOV R1,R7 �? SWI "OS_Find" ; Close output file � MOV R0,#18 �# ADR R1,out_file �/ MOV R2,#&1000 ; } �S SUB R2,R2,#1 ; } &FFF is what we want (see magazine) �L SWI "OS_File" ; Set filetype of output to text � : �= MOV PC,R12 ; Return to BASIC � : �T.file_error_close_input ; Called when input file has been opened �I ; but the output file hasn't � MOV R0,#0 MOV R1,R6 > SWI "OS_Find" ; Close input file .file_error C SWI "OS_WriteS" ; Display error message *4 EQUS "Couldn't open files":EQUB 0 4 ALIGN >$ SWI "OS_NewLine" H= MOV PC,R12 ; Return to BASIC R : \K.input_routine ; BL here with R0 > prompt fT ; R1 > 128 byte buffer pS ; ARM chip does R14 > return address z : �I SWI "OS_Write0" ; Display prompt passed in R0 �O MOV R0,R1 ; Move buffer to R0 for OS_ReadLine �< MOV R1,#128 ; 128 byte limit �L MOV R2,#33 ; No spaces / ctrl chars allowed �N MOV R3,#126 ; No top-bit set characters either �J SWI "OS_ReadLine" ; Call OS routine to get input �Q MOVCS PC,R12 ; If Escape pressed, exit to BASIC... �P MOV PC,R14 ; ...otherwise return back to caller � : �,.in_prompt EQUS " In filename: ":EQUB 0 �,.out_prompt EQUS "Out filename: ":EQUB 0 �]:� �� �
00000000 0d 00 0a 1a ee 20 85 20 f6 3a f1 22 20 61 74 20 |..... . .:." at | 00000010 6c 69 6e 65 20 22 3b 9e 3a e0 0d 00 14 0d f2 61 |line ";.:......a| 00000020 73 73 65 6d 62 6c 65 0d 00 1e 0a d6 20 63 6f 64 |ssemble..... cod| 00000030 65 0d 00 28 05 e0 0d 00 32 05 3a 0d 00 3c 0e dd |e..(....2.:..<..| 00000040 f2 61 73 73 65 6d 62 6c 65 0d 00 46 0f de 20 63 |.assemble..F.. c| 00000050 6f 64 65 20 32 30 34 38 0d 00 50 4b f4 20 41 6c |ode 2048..PK. Al| 00000060 6c 6f 63 61 74 65 20 62 75 66 66 65 72 73 20 69 |locate buffers i| 00000070 6e 73 69 64 65 20 63 6f 64 65 2c 20 73 6f 20 77 |nside code, so w| 00000080 65 20 64 6f 6e 27 74 20 67 65 74 20 70 72 6f 62 |e don't get prob| 00000090 6c 65 6d 73 20 77 69 74 68 20 6c 6f 6e 67 20 41 |lems with long A| 000000a0 44 52 73 0d 00 5a 14 69 6e 5f 66 69 6c 65 3d 63 |DRs..Z.in_file=c| 000000b0 6f 64 65 2b 31 32 38 0d 00 64 15 6f 75 74 5f 66 |ode+128..d.out_f| 000000c0 69 6c 65 3d 63 6f 64 65 2b 32 35 36 0d 00 6e 11 |ile=code+256..n.| 000000d0 63 6f 64 65 3d 63 6f 64 65 2b 33 38 34 0d 00 78 |code=code+384..x| 000000e0 05 3a 0d 00 82 40 f4 20 45 78 61 6d 70 6c 65 20 |.:...@. Example | 000000f0 6f 66 20 74 77 6f 2d 70 61 73 73 20 61 73 73 65 |of two-pass asse| 00000100 6d 62 6c 79 3b 20 6f 6e 20 74 68 65 20 66 69 72 |mbly; on the fir| 00000110 73 74 20 74 69 6d 65 20 61 72 6f 75 6e 64 2c 20 |st time around, | 00000120 77 65 0d 00 8c 2d f4 20 64 6f 6e 27 74 20 77 61 |we...-. don't wa| 00000130 6e 74 20 65 72 72 6f 72 73 20 72 65 70 6f 72 74 |nt errors report| 00000140 65 64 2c 20 68 65 6e 63 65 20 4f 50 54 20 30 0d |ed, hence OPT 0.| 00000150 00 96 05 3a 0d 00 a0 14 e3 20 70 61 73 73 3d 30 |...:..... pass=0| 00000160 20 b8 20 32 20 88 20 32 0d 00 aa 0b 50 25 3d 63 | . 2 . 2....P%=c| 00000170 6f 64 65 0d 00 b4 0d 5b 4f 50 54 20 70 61 73 73 |ode....[OPT pass| 00000180 0d 00 be 05 3a 0d 00 c8 4e 20 20 20 20 20 20 20 |....:...N | 00000190 20 20 20 4d 4f 56 20 20 20 20 20 20 20 52 31 32 | MOV R12| 000001a0 2c 52 31 34 20 20 20 20 20 20 20 20 20 20 20 20 |,R14 | 000001b0 20 3b 20 4b 65 65 70 20 42 41 53 49 43 20 72 65 | ; Keep BASIC re| 000001c0 74 75 72 6e 20 61 64 64 72 65 73 73 20 69 6e 20 |turn address in | 000001d0 52 31 32 0d 00 d2 0f 20 20 20 20 20 20 20 20 20 |R12.... | 000001e0 20 3a 0d 00 dc 24 20 20 20 20 20 20 20 20 20 20 | :...$ | 000001f0 41 44 52 20 20 20 20 20 20 20 52 30 2c 69 6e 5f |ADR R0,in_| 00000200 70 72 6f 6d 70 74 0d 00 e6 22 20 20 20 20 20 20 |prompt..." | 00000210 20 20 20 20 41 44 52 20 20 20 20 20 20 20 52 31 | ADR R1| 00000220 2c 69 6e 5f 66 69 6c 65 0d 00 f0 40 20 20 20 20 |,in_file...@ | 00000230 20 20 20 20 20 20 42 4c 20 20 20 20 20 20 20 20 | BL | 00000240 69 6e 70 75 74 5f 72 6f 75 74 69 6e 65 20 20 20 |input_routine | 00000250 20 20 20 20 3b 20 47 65 74 20 69 6e 70 75 74 20 | ; Get input | 00000260 66 69 6c 65 6e 61 6d 65 0d 00 fa 0f 20 20 20 20 |filename.... | 00000270 20 20 20 20 20 20 3a 0d 01 04 25 20 20 20 20 20 | :...% | 00000280 20 20 20 20 20 41 44 52 20 20 20 20 20 20 20 52 | ADR R| 00000290 30 2c 6f 75 74 5f 70 72 6f 6d 70 74 0d 01 0e 23 |0,out_prompt...#| 000002a0 20 20 20 20 20 20 20 20 20 20 41 44 52 20 20 20 | ADR | 000002b0 20 20 20 20 52 31 2c 6f 75 74 5f 66 69 6c 65 0d | R1,out_file.| 000002c0 01 18 41 20 20 20 20 20 20 20 20 20 20 42 4c 20 |..A BL | 000002d0 20 20 20 20 20 20 20 69 6e 70 75 74 5f 72 6f 75 | input_rou| 000002e0 74 69 6e 65 20 20 20 20 20 20 20 3b 20 47 65 74 |tine ; Get| 000002f0 20 6f 75 74 70 75 74 20 66 69 6c 65 6e 61 6d 65 | output filename| 00000300 0d 01 22 0f 20 20 20 20 20 20 20 20 20 20 3a 0d |..". :.| 00000310 01 2c 1f 20 20 20 20 20 20 20 20 20 20 4d 4f 56 |.,. MOV| 00000320 20 20 20 20 20 20 20 52 30 2c 23 26 34 33 0d 01 | R0,#&43..| 00000330 36 22 20 20 20 20 20 20 20 20 20 20 41 44 52 20 |6" ADR | 00000340 20 20 20 20 20 20 52 31 2c 69 6e 5f 66 69 6c 65 | R1,in_file| 00000350 0d 01 40 3d 20 20 20 20 20 20 20 20 20 20 53 57 |..@= SW| 00000360 49 20 20 20 20 20 20 20 22 4f 53 5f 46 69 6e 64 |I "OS_Find| 00000370 22 20 20 20 20 20 20 20 20 20 20 20 3b 20 4f 70 |" ; Op| 00000380 65 6e 20 69 6e 70 75 74 20 66 69 6c 65 0d 01 4a |en input file..J| 00000390 1d 20 20 20 20 20 20 20 20 20 20 43 4d 50 20 20 |. CMP | 000003a0 20 20 20 20 20 52 30 2c 23 30 0d 01 54 51 20 20 | R0,#0..TQ | 000003b0 20 20 20 20 20 20 20 20 42 45 51 20 20 20 20 20 | BEQ | 000003c0 20 20 66 69 6c 65 5f 65 72 72 6f 72 20 20 20 20 | file_error | 000003d0 20 20 20 20 20 20 3b 20 46 69 6e 69 73 68 20 6e | ; Finish n| 000003e0 6f 77 20 69 66 20 74 68 65 72 65 27 73 20 62 65 |ow if there's be| 000003f0 65 6e 20 61 6e 20 65 72 72 6f 72 0d 01 5e 53 20 |en an error..^S | 00000400 20 20 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 | MOV | 00000410 20 20 20 52 36 2c 52 30 20 20 20 20 20 20 20 20 | R6,R0 | 00000420 20 20 20 20 20 20 20 3b 20 4f 74 68 65 72 77 69 | ; Otherwi| 00000430 73 65 20 73 74 6f 72 65 20 74 68 65 20 66 69 6c |se store the fil| 00000440 65 20 68 61 6e 64 6c 65 20 69 6e 20 52 36 0d 01 |e handle in R6..| 00000450 68 0f 20 20 20 20 20 20 20 20 20 20 3a 0d 01 72 |h. :..r| 00000460 1f 20 20 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |. MOV | 00000470 20 20 20 20 20 52 30 2c 23 26 38 33 0d 01 7c 23 | R0,#&83..|#| 00000480 20 20 20 20 20 20 20 20 20 20 41 44 52 20 20 20 | ADR | 00000490 20 20 20 20 52 31 2c 6f 75 74 5f 66 69 6c 65 0d | R1,out_file.| 000004a0 01 86 48 20 20 20 20 20 20 20 20 20 20 53 57 49 |..H SWI| 000004b0 20 20 20 20 20 20 20 22 4f 53 5f 46 69 6e 64 22 | "OS_Find"| 000004c0 20 20 20 20 20 20 20 20 20 20 3b 20 43 72 65 61 | ; Crea| 000004d0 74 65 20 61 6e 64 20 6f 70 65 6e 20 6f 75 74 70 |te and open outp| 000004e0 75 74 20 66 69 6c 65 0d 01 90 1d 20 20 20 20 20 |ut file.... | 000004f0 20 20 20 20 20 43 4d 50 20 20 20 20 20 20 20 52 | CMP R| 00000500 30 2c 23 30 0d 01 9a 52 20 20 20 20 20 20 20 20 |0,#0...R | 00000510 20 20 42 45 51 20 20 20 20 20 20 20 66 69 6c 65 | BEQ file| 00000520 5f 65 72 72 6f 72 5f 63 6c 6f 73 65 5f 69 6e 70 |_error_close_inp| 00000530 75 74 20 3b 20 46 69 6e 73 68 20 61 6e 64 20 63 |ut ; Finsh and c| 00000540 6c 6f 73 65 20 74 68 65 20 69 6e 70 75 74 20 66 |lose the input f| 00000550 69 6c 65 20 69 66 0d 01 a4 47 20 20 20 20 20 20 |ile if...G | 00000560 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000580 20 20 20 20 20 3b 20 20 74 68 65 72 65 27 73 20 | ; there's | 00000590 62 65 65 6e 20 61 6e 20 65 72 72 6f 72 0d 01 ae |been an error...| 000005a0 53 20 20 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |S MOV | 000005b0 20 20 20 20 20 52 37 2c 52 30 20 20 20 20 20 20 | R7,R0 | 000005c0 20 20 20 20 20 20 20 20 20 3b 20 4f 74 68 65 72 | ; Other| 000005d0 77 69 73 65 20 73 74 6f 72 65 20 74 68 65 20 66 |wise store the f| 000005e0 69 6c 65 20 68 61 6e 64 6c 65 20 69 6e 20 52 37 |ile handle in R7| 000005f0 0d 01 b8 0f 20 20 20 20 20 20 20 20 20 20 3a 0d |.... :.| 00000600 01 c2 4b 2e 70 72 6f 63 65 73 73 5f 66 69 6c 65 |..K.process_file| 00000610 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000620 20 20 20 20 20 20 20 20 20 20 20 3b 20 53 74 61 | ; Sta| 00000630 72 74 20 6f 66 20 66 69 6c 65 20 70 72 6f 63 65 |rt of file proce| 00000640 73 73 69 6e 67 20 6c 6f 6f 70 0d 01 cc 1d 20 20 |ssing loop.... | 00000650 20 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 | MOV | 00000660 20 20 52 31 2c 52 36 0d 01 d6 53 20 20 20 20 20 | R1,R6...S | 00000670 20 20 20 20 20 53 57 49 20 20 20 20 20 20 20 22 | SWI "| 00000680 4f 53 5f 42 47 65 74 22 20 20 20 20 20 20 20 20 |OS_BGet" | 00000690 20 20 20 3b 20 47 65 74 20 6e 65 78 74 20 62 79 | ; Get next by| 000006a0 74 65 20 66 72 6f 6d 20 69 6e 70 75 74 20 66 69 |te from input fi| 000006b0 6c 65 20 69 6e 74 6f 20 52 30 0d 01 e0 51 20 20 |le into R0...Q | 000006c0 20 20 20 20 20 20 20 20 42 43 53 20 20 20 20 20 | BCS | 000006d0 20 20 66 69 6c 65 5f 66 69 6e 69 73 68 65 64 20 | file_finished | 000006e0 20 20 20 20 20 20 3b 20 43 68 65 63 6b 20 66 6f | ; Check fo| 000006f0 72 20 65 6e 64 2d 6f 66 2d 66 69 6c 65 2c 20 61 |r end-of-file, a| 00000700 6e 64 20 69 66 20 77 65 27 76 65 0d 01 ea 4f 20 |nd if we've...O | 00000710 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000730 20 20 20 20 20 20 20 3b 20 20 72 65 61 63 68 65 | ; reache| 00000740 64 20 69 74 2c 20 6a 75 6d 70 20 6f 75 74 20 6f |d it, jump out o| 00000750 66 20 74 68 65 20 6c 6f 6f 70 0d 01 f4 50 20 20 |f the loop...P | 00000760 20 20 20 20 20 20 20 20 43 4d 50 20 20 20 20 20 | CMP | 00000770 20 20 52 30 2c 23 36 35 20 20 20 20 20 20 20 20 | R0,#65 | 00000780 20 20 20 20 20 20 3b 20 7d 20 54 68 65 73 65 20 | ; } These | 00000790 66 6f 75 72 20 63 6f 6d 70 61 72 69 73 6f 6e 73 |four comparisons| 000007a0 20 6d 61 6b 65 20 73 75 72 65 0d 01 fe 51 20 20 | make sure...Q | 000007b0 20 20 20 20 20 20 20 20 42 4c 54 20 20 20 20 20 | BLT | 000007c0 20 20 73 6b 69 70 5f 62 79 74 65 20 20 20 20 20 | skip_byte | 000007d0 20 20 20 20 20 20 3b 20 7d 20 74 68 61 74 20 61 | ; } that a| 000007e0 20 62 79 74 65 20 69 73 20 63 68 61 6e 67 65 64 | byte is changed| 000007f0 20 6f 6e 6c 79 20 69 66 20 69 74 0d 02 08 52 20 | only if it...R | 00000800 20 20 20 20 20 20 20 20 20 43 4d 50 20 20 20 20 | CMP | 00000810 20 20 20 52 30 2c 23 39 30 20 20 20 20 20 20 20 | R0,#90 | 00000820 20 20 20 20 20 20 20 3b 20 7d 20 69 73 20 6c 65 | ; } is le| 00000830 73 73 20 74 68 61 6e 20 36 35 20 6f 72 20 67 72 |ss than 65 or gr| 00000840 65 61 74 65 72 20 74 68 61 6e 20 39 30 0d 02 12 |eater than 90...| 00000850 4d 20 20 20 20 20 20 20 20 20 20 42 47 54 20 20 |M BGT | 00000860 20 20 20 20 20 73 6b 69 70 5f 62 79 74 65 20 20 | skip_byte | 00000870 20 20 20 20 20 20 20 20 20 3b 20 7d 20 28 69 2e | ; } (i.| 00000880 65 2e 20 69 74 20 69 73 20 61 20 63 61 70 69 74 |e. it is a capit| 00000890 61 6c 20 6c 65 74 74 65 72 29 0d 02 1c 4a 20 20 |al letter)...J | 000008a0 20 20 20 20 20 20 20 20 41 44 44 20 20 20 20 20 | ADD | 000008b0 20 20 52 30 2c 52 30 2c 23 33 32 20 20 20 20 20 | R0,R0,#32 | 000008c0 20 20 20 20 20 20 3b 20 43 68 61 6e 67 65 73 20 | ; Changes | 000008d0 6c 65 74 74 65 72 20 74 6f 20 6c 6f 77 65 72 20 |letter to lower | 000008e0 63 61 73 65 0d 02 26 0e 2e 73 6b 69 70 5f 62 79 |case..&..skip_by| 000008f0 74 65 0d 02 30 4f 20 20 20 20 20 20 20 20 20 20 |te..0O | 00000900 4d 4f 56 20 20 20 20 20 20 20 52 31 2c 52 37 20 |MOV R1,R7 | 00000910 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00000920 7d 20 50 75 74 20 62 79 74 65 20 28 61 6c 74 65 |} Put byte (alte| 00000930 72 65 64 20 6f 72 20 6f 74 68 65 72 77 69 73 65 |red or otherwise| 00000940 29 0d 02 3a 3e 20 20 20 20 20 20 20 20 20 20 53 |)..:> S| 00000950 57 49 20 20 20 20 20 20 20 22 4f 53 5f 42 50 75 |WI "OS_BPu| 00000960 74 22 20 20 20 20 20 20 20 20 20 20 20 3b 20 7d |t" ; }| 00000970 20 74 6f 20 6f 75 74 70 75 74 20 66 69 6c 65 0d | to output file.| 00000980 02 44 3e 20 20 20 20 20 20 20 20 20 20 42 20 20 |.D> B | 00000990 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 5f 66 | process_f| 000009a0 69 6c 65 20 20 20 20 20 20 20 20 3b 20 4c 6f 6f |ile ; Loo| 000009b0 70 20 72 6f 75 6e 64 20 61 67 61 69 6e 0d 02 4e |p round again..N| 000009c0 0f 20 20 20 20 20 20 20 20 20 20 3a 0d 02 58 12 |. :..X.| 000009d0 2e 66 69 6c 65 5f 66 69 6e 69 73 68 65 64 0d 02 |.file_finished..| 000009e0 62 1d 20 20 20 20 20 20 20 20 20 20 4d 4f 56 20 |b. MOV | 000009f0 20 20 20 20 20 20 52 30 2c 23 30 0d 02 6c 1d 20 | R0,#0..l. | 00000a00 20 20 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 | MOV | 00000a10 20 20 20 52 31 2c 52 36 0d 02 76 3e 20 20 20 20 | R1,R6..v> | 00000a20 20 20 20 20 20 20 53 57 49 20 20 20 20 20 20 20 | SWI | 00000a30 22 4f 53 5f 46 69 6e 64 22 20 20 20 20 20 20 20 |"OS_Find" | 00000a40 20 20 20 20 3b 20 43 6c 6f 73 65 20 69 6e 70 75 | ; Close inpu| 00000a50 74 20 66 69 6c 65 0d 02 80 1d 20 20 20 20 20 20 |t file.... | 00000a60 20 20 20 20 4d 4f 56 20 20 20 20 20 20 20 52 31 | MOV R1| 00000a70 2c 52 37 0d 02 8a 3f 20 20 20 20 20 20 20 20 20 |,R7...? | 00000a80 20 53 57 49 20 20 20 20 20 20 20 22 4f 53 5f 46 | SWI "OS_F| 00000a90 69 6e 64 22 20 20 20 20 20 20 20 20 20 20 20 3b |ind" ;| 00000aa0 20 43 6c 6f 73 65 20 6f 75 74 70 75 74 20 66 69 | Close output fi| 00000ab0 6c 65 0d 02 94 1e 20 20 20 20 20 20 20 20 20 20 |le.... | 00000ac0 4d 4f 56 20 20 20 20 20 20 20 52 30 2c 23 31 38 |MOV R0,#18| 00000ad0 0d 02 9e 23 20 20 20 20 20 20 20 20 20 20 41 44 |...# AD| 00000ae0 52 20 20 20 20 20 20 20 52 31 2c 6f 75 74 5f 66 |R R1,out_f| 00000af0 69 6c 65 0d 02 a8 2f 20 20 20 20 20 20 20 20 20 |ile.../ | 00000b00 20 4d 4f 56 20 20 20 20 20 20 20 52 32 2c 23 26 | MOV R2,#&| 00000b10 31 30 30 30 20 20 20 20 20 20 20 20 20 20 20 3b |1000 ;| 00000b20 20 7d 0d 02 b2 53 20 20 20 20 20 20 20 20 20 20 | }...S | 00000b30 53 55 42 20 20 20 20 20 20 20 52 32 2c 52 32 2c |SUB R2,R2,| 00000b40 23 31 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 |#1 ; | 00000b50 7d 20 26 46 46 46 20 69 73 20 77 68 61 74 20 77 |} &FFF is what w| 00000b60 65 20 77 61 6e 74 20 28 73 65 65 20 6d 61 67 61 |e want (see maga| 00000b70 7a 69 6e 65 29 0d 02 bc 4c 20 20 20 20 20 20 20 |zine)...L | 00000b80 20 20 20 53 57 49 20 20 20 20 20 20 20 22 4f 53 | SWI "OS| 00000b90 5f 46 69 6c 65 22 20 20 20 20 20 20 20 20 20 20 |_File" | 00000ba0 20 3b 20 53 65 74 20 66 69 6c 65 74 79 70 65 20 | ; Set filetype | 00000bb0 6f 66 20 6f 75 74 70 75 74 20 74 6f 20 74 65 78 |of output to tex| 00000bc0 74 0d 02 c6 0f 20 20 20 20 20 20 20 20 20 20 3a |t.... :| 00000bd0 0d 02 d0 3d 20 20 20 20 20 20 20 20 20 20 4d 4f |...= MO| 00000be0 56 20 20 20 20 20 20 20 50 43 2c 52 31 32 20 20 |V PC,R12 | 00000bf0 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 52 65 | ; Re| 00000c00 74 75 72 6e 20 74 6f 20 42 41 53 49 43 0d 02 da |turn to BASIC...| 00000c10 0f 20 20 20 20 20 20 20 20 20 20 3a 0d 02 e4 54 |. :...T| 00000c20 2e 66 69 6c 65 5f 65 72 72 6f 72 5f 63 6c 6f 73 |.file_error_clos| 00000c30 65 5f 69 6e 70 75 74 20 20 20 20 20 20 20 20 20 |e_input | 00000c40 20 20 20 20 20 20 20 20 3b 20 43 61 6c 6c 65 64 | ; Called| 00000c50 20 77 68 65 6e 20 69 6e 70 75 74 20 66 69 6c 65 | when input file| 00000c60 20 68 61 73 20 62 65 65 6e 20 6f 70 65 6e 65 64 | has been opened| 00000c70 0d 02 ee 49 20 20 20 20 20 20 20 20 20 20 20 20 |...I | 00000c80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000c90 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 20 62 | ; b| 00000ca0 75 74 20 74 68 65 20 6f 75 74 70 75 74 20 66 69 |ut the output fi| 00000cb0 6c 65 20 68 61 73 6e 27 74 0d 02 f8 1d 20 20 20 |le hasn't.... | 00000cc0 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 20 | MOV | 00000cd0 20 52 30 2c 23 30 0d 03 02 1d 20 20 20 20 20 20 | R0,#0.... | 00000ce0 20 20 20 20 4d 4f 56 20 20 20 20 20 20 20 52 31 | MOV R1| 00000cf0 2c 52 36 0d 03 0c 3e 20 20 20 20 20 20 20 20 20 |,R6...> | 00000d00 20 53 57 49 20 20 20 20 20 20 20 22 4f 53 5f 46 | SWI "OS_F| 00000d10 69 6e 64 22 20 20 20 20 20 20 20 20 20 20 20 3b |ind" ;| 00000d20 20 43 6c 6f 73 65 20 69 6e 70 75 74 20 66 69 6c | Close input fil| 00000d30 65 0d 03 16 0f 2e 66 69 6c 65 5f 65 72 72 6f 72 |e.....file_error| 00000d40 0d 03 20 43 20 20 20 20 20 20 20 20 20 20 53 57 |.. C SW| 00000d50 49 20 20 20 20 20 20 20 22 4f 53 5f 57 72 69 74 |I "OS_Writ| 00000d60 65 53 22 20 20 20 20 20 20 20 20 20 3b 20 44 69 |eS" ; Di| 00000d70 73 70 6c 61 79 20 65 72 72 6f 72 20 6d 65 73 73 |splay error mess| 00000d80 61 67 65 0d 03 2a 34 20 20 20 20 20 20 20 20 20 |age..*4 | 00000d90 20 45 51 55 53 20 20 20 20 20 20 22 43 6f 75 6c | EQUS "Coul| 00000da0 64 6e 27 74 20 6f 70 65 6e 20 66 69 6c 65 73 22 |dn't open files"| 00000db0 3a 45 51 55 42 20 30 0d 03 34 13 20 20 20 20 20 |:EQUB 0..4. | 00000dc0 20 20 20 20 20 41 4c 49 47 4e 0d 03 3e 24 20 20 | ALIGN..>$ | 00000dd0 20 20 20 20 20 20 20 20 53 57 49 20 20 20 20 20 | SWI | 00000de0 20 20 22 4f 53 5f 4e 65 77 4c 69 6e 65 22 0d 03 | "OS_NewLine"..| 00000df0 48 3d 20 20 20 20 20 20 20 20 20 20 4d 4f 56 20 |H= MOV | 00000e00 20 20 20 20 20 20 50 43 2c 52 31 32 20 20 20 20 | PC,R12 | 00000e10 20 20 20 20 20 20 20 20 20 20 3b 20 52 65 74 75 | ; Retu| 00000e20 72 6e 20 74 6f 20 42 41 53 49 43 0d 03 52 0f 20 |rn to BASIC..R. | 00000e30 20 20 20 20 20 20 20 20 20 3a 0d 03 5c 4b 2e 69 | :..\K.i| 00000e40 6e 70 75 74 5f 72 6f 75 74 69 6e 65 20 20 20 20 |nput_routine | 00000e50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000e60 20 20 20 20 20 20 3b 20 42 4c 20 68 65 72 65 20 | ; BL here | 00000e70 77 69 74 68 20 20 20 20 20 52 30 20 20 3e 20 70 |with R0 > p| 00000e80 72 6f 6d 70 74 0d 03 66 54 20 20 20 20 20 20 20 |rompt..fT | 00000e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000eb0 20 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | ; | 00000ec0 20 20 20 20 52 31 20 20 3e 20 31 32 38 20 62 79 | R1 > 128 by| 00000ed0 74 65 20 62 75 66 66 65 72 0d 03 70 53 20 20 20 |te buffer..pS | 00000ee0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000f00 20 20 20 20 20 3b 20 41 52 4d 20 63 68 69 70 20 | ; ARM chip | 00000f10 64 6f 65 73 20 20 20 20 52 31 34 20 3e 20 72 65 |does R14 > re| 00000f20 74 75 72 6e 20 61 64 64 72 65 73 73 0d 03 7a 0f |turn address..z.| 00000f30 20 20 20 20 20 20 20 20 20 20 3a 0d 03 84 49 20 | :...I | 00000f40 20 20 20 20 20 20 20 20 20 53 57 49 20 20 20 20 | SWI | 00000f50 20 20 20 22 4f 53 5f 57 72 69 74 65 30 22 20 20 | "OS_Write0" | 00000f60 20 20 20 20 20 20 20 3b 20 44 69 73 70 6c 61 79 | ; Display| 00000f70 20 70 72 6f 6d 70 74 20 70 61 73 73 65 64 20 69 | prompt passed i| 00000f80 6e 20 52 30 0d 03 8e 4f 20 20 20 20 20 20 20 20 |n R0...O | 00000f90 20 20 4d 4f 56 20 20 20 20 20 20 20 52 30 2c 52 | MOV R0,R| 00000fa0 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |1 | 00000fb0 3b 20 4d 6f 76 65 20 62 75 66 66 65 72 20 74 6f |; Move buffer to| 00000fc0 20 52 30 20 66 6f 72 20 4f 53 5f 52 65 61 64 4c | R0 for OS_ReadL| 00000fd0 69 6e 65 0d 03 98 3c 20 20 20 20 20 20 20 20 20 |ine...< | 00000fe0 20 4d 4f 56 20 20 20 20 20 20 20 52 31 2c 23 31 | MOV R1,#1| 00000ff0 32 38 20 20 20 20 20 20 20 20 20 20 20 20 20 3b |28 ;| 00001000 20 31 32 38 20 62 79 74 65 20 6c 69 6d 69 74 0d | 128 byte limit.| 00001010 03 a2 4c 20 20 20 20 20 20 20 20 20 20 4d 4f 56 |..L MOV| 00001020 20 20 20 20 20 20 20 52 32 2c 23 33 33 20 20 20 | R2,#33 | 00001030 20 20 20 20 20 20 20 20 20 20 20 3b 20 4e 6f 20 | ; No | 00001040 73 70 61 63 65 73 20 2f 20 63 74 72 6c 20 63 68 |spaces / ctrl ch| 00001050 61 72 73 20 61 6c 6c 6f 77 65 64 0d 03 ac 4e 20 |ars allowed...N | 00001060 20 20 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 | MOV | 00001070 20 20 20 52 33 2c 23 31 32 36 20 20 20 20 20 20 | R3,#126 | 00001080 20 20 20 20 20 20 20 3b 20 4e 6f 20 74 6f 70 2d | ; No top-| 00001090 62 69 74 20 73 65 74 20 63 68 61 72 61 63 74 65 |bit set characte| 000010a0 72 73 20 65 69 74 68 65 72 0d 03 b6 4a 20 20 20 |rs either...J | 000010b0 20 20 20 20 20 20 20 53 57 49 20 20 20 20 20 20 | SWI | 000010c0 20 22 4f 53 5f 52 65 61 64 4c 69 6e 65 22 20 20 | "OS_ReadLine" | 000010d0 20 20 20 20 20 3b 20 43 61 6c 6c 20 4f 53 20 72 | ; Call OS r| 000010e0 6f 75 74 69 6e 65 20 74 6f 20 67 65 74 20 69 6e |outine to get in| 000010f0 70 75 74 0d 03 c0 51 20 20 20 20 20 20 20 20 20 |put...Q | 00001100 20 4d 4f 56 43 53 20 20 20 20 20 50 43 2c 52 31 | MOVCS PC,R1| 00001110 32 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b |2 ;| 00001120 20 49 66 20 45 73 63 61 70 65 20 70 72 65 73 73 | If Escape press| 00001130 65 64 2c 20 65 78 69 74 20 74 6f 20 42 41 53 49 |ed, exit to BASI| 00001140 43 2e 2e 2e 0d 03 ca 50 20 20 20 20 20 20 20 20 |C......P | 00001150 20 20 4d 4f 56 20 20 20 20 20 20 20 50 43 2c 52 | MOV PC,R| 00001160 31 34 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |14 | 00001170 3b 20 2e 2e 2e 6f 74 68 65 72 77 69 73 65 20 72 |; ...otherwise r| 00001180 65 74 75 72 6e 20 62 61 63 6b 20 74 6f 20 63 61 |eturn back to ca| 00001190 6c 6c 65 72 0d 03 d4 0f 20 20 20 20 20 20 20 20 |ller.... | 000011a0 20 20 3a 0d 03 de 2c 2e 69 6e 5f 70 72 6f 6d 70 | :...,.in_promp| 000011b0 74 20 20 45 51 55 53 20 22 20 49 6e 20 66 69 6c |t EQUS " In fil| 000011c0 65 6e 61 6d 65 3a 20 22 3a 45 51 55 42 20 30 0d |ename: ":EQUB 0.| 000011d0 03 e8 2c 2e 6f 75 74 5f 70 72 6f 6d 70 74 20 45 |..,.out_prompt E| 000011e0 51 55 53 20 22 4f 75 74 20 66 69 6c 65 6e 61 6d |QUS "Out filenam| 000011f0 65 3a 20 22 3a 45 51 55 42 20 30 0d 03 f2 07 5d |e: ":EQUB 0....]| 00001200 3a ed 0d 03 fc 05 e1 0d ff |:........| 00001209