EUG PD


27K Assembler

 
Published in EUG #27

Having kept promising this utility to you all for some time now, I have finally had chance to check it for you. The results appear on this issue disk called 27KASM, along with two test programs: TEST1 and TEST2. All are stored in the Utilities Directory.

Even on a cassette machine in Mode 7, there are only 27K of free memory for programs, or 28K if you're using a Shadow Mode such as those available on the Master 128.

When writing large assembler programs you could quite easily fill this 27K with source code, which means that when it comes to assembly, BASIC gives the insulting "No room" message, as there is no free space to keep the line references on the heap.

The normal way around this is to assemble your program in parts, but this has the disadvantage of you losing the variables between them.

Another possible route is open to those with Sideways RAM, using BASIC 2's offset assembly and pointing the code into &8000. This is fine except when you come to saving, as using *SAVE will Page in the DFS. Also, it won't work on a Master.

This is where my program comes into its own. It will work on any unexpanded 8bit Acorn (but is not second processor compatible) i.e. a Master 128, Electron, BBC B, etc ... as long as it has at least BASIC 2. You can tell if you have this ROM by turning on the machine, typing *BASIC (RETURN) then REPORT (RETURN). Dates of 1982 or greater are fine.

There are some modifications you'll need to make to your code and they are best illustrated with a frivolous example, using the generic header I use for all my assembler listings:

       10REM Pointless program 
       20REM (C)1996 Joe Bloggs 
       30DIM code% 256 
       40INPUT"Assemble at "loc$   
       50loc%=EVAL(loc$)   
       60REM Define os variables for later 
       70oswc=&FFEE:oswd=&FFF1:osfd=&FFCE  
       80osfd=&FFCE:ospb=&FFD4:osby=&FFF4  
       90FORX=4 TO 7 STEP3  
      100O%=code%:P%=loc%  
      110[OPTX  
      120NOP 
      130RTS 
      140] 
      150NEXT 
      160REM Save mcode to disk as usual 
      170OSCLI"SAVE OUTPUT "+STR$(asm%)+" "+STR$(O%)+" "+STR$(loc%)+"
    "+STR$(loc%)  
This requires modifying in the following ways:
      *RUN the redirector, 27KASM
      SET O%=&A00
      DO VDU255 at top and bottom inside the FOR...NEXT loop
Although not essential, you don't need to DIM any memory for it now, and the *SAVE command at the end is not needed any more, which would make the above become:
       10REM Pointless program 
       20REM (C)1996 Joe Bloggs 
       30 
       40INPUT"Assemble at "loc$   
       50loc%=EVAL(loc$)   
       60REM Define os variables for later 
       70oswc=&FFEE:oswd=&FFF1:osfd=&FFCE  
       80osfd=&FFCE:ospb=&FFD4:osby=&FFF4  
       85*RUN 27KASM 
       90FORX=4 TO 7 STEP3  
      100O%=&A00:P%=loc% 
      105VDU255 
      110[OPTX  
      120NOP 
      130RTS 
      140] 
      145VDU255 
      150NEXT 
      160 
      170 
Also enclosed on this disk are two further test programs, which don't do anything special but illustrate some other features. As vectors are repointed, the 27KASM program shouldn't be *RUN twice without pressing BREAK inbetween. The program will work with tape, DFS and ADFS.

Note that it uses Page &A00 (Cassette and RS423 receive on the BBC) as a buffer for BASIC to assemble to. The program itself occupies Page &C00 (character redefinition buffer on BBC/Econet workspace on the Master) so don't redefine any characters. If these locations pose a problem to you, send £2.50 with a note saying where your preferred buffer/program areas are and I'll send you a customised version back on disk.

This utility has been tested with BASIC 2 and BASIC 4. It won't work with BASIC 1 as this has no offset assembly option.

Let me know how you all get on and I'll look forward to seeing your 27K assembler programs in future EUGs. (Actually they won't be that long as I've found that for roughly every 7.25 bytes of BASIC source you write, only 1 byte of m/code is generated, so 3.75K of m/code is more realistic!)

Robert Sprowson, EUG #27

Robert Sprowson