home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.uni-stuttgart.de/pub/systems/acorn/
/
Acorn.tar
/
Acorn
/
acornet
/
dev
/
basic
/
makeapp.spk
/
!MakeApp2
/
CLIapp
/
b2a0_src
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1995-03-21
|
4KB
|
136 lines
This application is FreeWare. (c) 1995 Dick Alstein
$;" at line ";
codesize%=&2000
armcode% codesize%
leafname$="bas2app0"
2help$="Syntax: "+leafname$+" infile [outfile]"
-fname$="<MakeApp2$Dir>.CLIapp."+leafname$
assemble
"OS_File",10,fname$,&FF8,,code_start,code_end
assemble
LR=14
PC=15
dblquote$=
argbuffersize%=512
pass%=8
P%=armcode%
L%=armcode%+codesize%
[ OPT pass%
.code_start
B conversion_start
.argbuffer
dim(argbuffersize%)
.inputtype
EQUD &FFB
.outputtype
EQUD &FF8
.commandsyntax
- EQUS "Program,Help/S,Infile,Outfile"
EQUS
ALIGN
.helpstring
EQUS help$
EQUS
ALIGN
.err_wrongtype
EQUD 0
)/ EQUS "Input file must be a Basic file"
EQUS
ALIGN
.conversion_start
.5 ; --- This is the part that does the conversion
0. ; 1. read the name of infile and outfile
SWI "OS_GetEnv"
3@ MOV R1,R0 ; pointer to command line in R1
ADR R0,commandsyntax
ADR R2,argbuffer
6 MOV R3,#argbuffersize%
SWI "OS_ReadArgs"
8; LDR R0,[R2,#4] ; check for "-Help" switch
TEQ R0,#0
BNE printhelp
;D LDR R6,[R2,#8] ; keep pointer to infile name in R6
TEQ R6,#0
BEQ printhelp
>E LDR R7,[R2,#12] ; keep pointer to outfile name in R7
TEQ R7,#0
Q R7,R6 ; if no outfile name given then same as infile
BB ; 2. check filetype of infile and calculate size of outfile
MOV R0,#17
MOV R1,R6
F! SWI "OS_File"
MOV R2,R2,LSL #12
LDR R1,inputtype
CMP R1,R2,LSR #20
ADR R0,err_wrongtype
K SWINE "OS_GenerateError"
L: MOV R8,R4 ; outputsize = infilesize
N% ; 3. fill in 'blanks' of prefix
STR R8,program_size
LDR R3,program_end
ADD R3,R3,R8
STR R3,program_end
LDR R3,program_dest
ADD R3,R3,R8
STR R3,program_dest
ADD R0,R8,#&9000
X ADR R1,cmdline_endaddr
MOV R2,#9
SWI "OS_ConvertHex8"
\' ; 4. load input file after prefix
MOV R0,#16
MOV R1,R6
ADR R2,program_start
MOV R3,#0
SWI "OS_File"
d& ; 5. write result to output file
MOV R0,#10
MOV R1,R7
LDR R2,outputtype
i! ADR R4,outputcode_start
j5 ADD R5,R4,#(program_start-outputcode_start)
ADD R5,R5,R8
SWI "OS_File"
; 6. ready
SWI "OS_Exit"
.printhelp
ADR R0,helpstring
SWI "OS_Write0"
SWI "OS_NewLine"
SWI "OS_Exit"
.outputcode_start
zK ; --- This is the prefix that is prepended to the given Basic program
|& ; 1. copy Basic program to &9000
LDR R1,program_size
LDR R2,program_end
LDR R3,program_dest
.copyabyte
LDRB R0,[R2],#-1
STRB R0,[R3],#-1
SUBS R1,R1,#1
BNE copyabyte
; 2. enter Basic
ADR R0,cmdline
SWI "OS_CLI"
J ; --- The following 4 data fields are filled in when bas2app0 is run
.program_size
F EQUD 0 ; set to (outputsize)
.program_end
I EQUD &8000+(program_start-outputcode_start)-1 ; add (outputsize)
.program_dest
C EQUD &9000-1 ; add (outputsize)
.cmdline
& EQUS "Basic -quit @00009000,"
.cmdline_endaddr
L EQUS "00000000" ; insert (&9000+outputsize)
EQUS
.program_start
0 ; --- The original Basic program goes here
.code_end
pass%
dim(size%)
i%=1
size%
[ OPT pass%
EQUB 0