<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 14 Oct 1999 15:10:40 +0100
From   : "Steve Fewell" <stevef@...>
Subject: Re: Assembler compiler

Christopher wrote:
> Does anyone know of a disc-based compiler for assembly language on the
BBC?
> As I have always thought it would be useful if you could edit code in,
say,
> View, and compile it afterwards. This would solve the problem of assembly
> programs taking up at least 5 times as much memory as the resultant
machine
> code.
> 

This reminds me of a program that I wrote years ago. Searching through my
disks, I found the program that has been added to the end of this message.
Sorry, I don't have BBC -> PC connection, so the program is in plain ASCII
text (and not tokenised). Also, apologies for the lack of spacing and
brackets in the code! (I like my shortcuts!).

The program will read a BASIC program (that includes assembly) from disk
and assemble it to memory (at P% location), without the whole BASIC program
having to be loaded into memory. However, this program is only very simple,
and won't do everything! It relies on the BASIC Interpreter to do all of
the work!

The program will evaluate any variables/constants/labels that have been set
up in the BASIC program, however as only one line is evaluated at a time,
usage of Program-defined functions, goto's, gosub's, procedure calls, loops
(these will be ignored) and call statements (these will be ignored) will
not work.

As all variables are evaluated, then memory after LOMEM (the BASIC Heap)
will be used for these values, and problems will be caused if the assembly
program's assemble space uses this area of memory.

Does anyone know how other disk-based Assemblers cope with BASIC statements
and variable definitions?

The program used V% as the pass number (two passes are made, one with OPT0
and the second with OPT3), and Z% indicates whether BASIC or Assembly
statements are currently being processed.

Any comments, improvements, etc.. on this program are welcome.

Steve.
Steve Fewell at Scala Uk
 [stevef@...] 


10  ONERRORIFERR=223 GOTO270 ELSEREPORT:END
20  Z%=0:V%=0
30  MODE7
40  PRINT"ASSEMBLER FOR FILES"
50  INPUT''"Enter file name =>"F$
60  IN%=OPENIN(F$)
70  IFIN%=0 PRINT"FILE NOT FOUND!!":GOTO50
80  A=BGET#IN%
90  A=BGET#IN%:A=BGET#IN%:A=BGET#IN%
100 A$="":REPEAT
110 A=BGET#IN%
120 IFA<>13 A$=A$+CHR$A
130 UNTILA=13:IFINSTR(A$,"[")>0 Z%=1
140 :
150 C%=0:REPEATC%=C%+1
160 I%=ASC(MID$(A$,C%,1))
170 UNTILI%>127ORC%>LENA$
180 REM TEST FOR NEXT/UNTIL/CALL AS FIRST COMMAND ON LINE.
190 IFI%=237 ORI%=253 ORI%=214 GOTO310
200 IFZ%=0 ORINSTR(A$,"[")>0 OSCLI"KEY0"+A$+"|MG.240|M":GOTO220
210 IFZ%=1OSCLI"KEY0[OPT"+STR$V%+":"+A$+"|MG.240|M"
220 VDU21:*FX138,0,128
230 END
240 VDU6:ONERRORIFERR=223 GOTO270 ELSEREPORT:END
250 IFINSTR(A$,"]")>0 Z%=0
260 IFEOF#IN% GOTO270 ELSEGOTO90
270 CLOSE#0
280 V%=V%+3
290 IFV%>3 GOTO300 ELSEGOTO60
300 PRINT"File Assembled.":END
310 IFINSTR(A$,"]")>0 Z%=0:GOTO90 ELSE GOTO90

<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>