User Tools

Site Tools


inline_basic_assembler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
inline_basic_assembler [2025/06/19 14:40] – [In Use] reggieinline_basic_assembler [2025/06/20 10:17] (current) – [Dragon Basic Inline Assembler] reggie
Line 1: Line 1:
 ====== Dragon Basic Inline Assembler ====== ====== Dragon Basic Inline Assembler ======
  
-This utility (GTAsm) is intended for small 6809 machine language utilities that enhance programs written mostly in Dragon Basic, for example a routine to scroll the graphics screen. The assembly source code is written in Basic comment statements.+This utility (GTAsm) is intended for developing small 6809 machine language routines that enhance programs written mostly in Dragon Basic, for example a routine to scroll the graphics screen. The assembly source code is written in Basic comment statements. This documentation assumes a good working knowledge of the 6809 and the Dragon 32.
  
-[[https://6809.uk/cas/GTAsm.cas|Download GTAsm Inline Basic Assembler]] (as a .cas file for the Dragon 32)+[[https://6809.uk/cas/GTAsm.cas|Download GTAsm Inline Basic Assembler]] (as a .cas file for the Dragon 32 - get the [[https://www.6809.org.uk/xroar/|XRoar Emulator]])
  
 ==== Reserving Memory ==== ==== Reserving Memory ====
  
-With any small micro with limited RAM there's a big problem: the source code, executable program, and the assembler program itself all have to occupy memory at the same time. As well as the limitation on total space, the executable and the assembler might want to accupy the same address space at the same time.+With any small micro with limited RAM there's a big problem: the source code, executable program, and the assembler program itself all have to occupy memory at the same time. As well as the limitation on total space, the executable and the assembler might want to occupy the same address space at the same time.
  
 GTAsm deals with this problem by loading itself into the graphics pages by default; the assembled code can then freely use the high memory area. Obviously this means the assembler will be corrupted and have to be reloaded every time graphics are drawn. To avoid this, reserve extra pages with PCLEAR and load the assembler in these, or load it into the reserved high memory area. The assembler's workspace (for calculating labels etc.) is limited by the end of the graphics pages, or the top of RAM (&H8000) as appropriate. GTAsm deals with this problem by loading itself into the graphics pages by default; the assembled code can then freely use the high memory area. Obviously this means the assembler will be corrupted and have to be reloaded every time graphics are drawn. To avoid this, reserve extra pages with PCLEAR and load the assembler in these, or load it into the reserved high memory area. The assembler's workspace (for calculating labels etc.) is limited by the end of the graphics pages, or the top of RAM (&H8000) as appropriate.
Line 20: Line 20:
   540 'END   540 'END
      
-The PCLEAR statement clears an extra 3 graphics pages, or 4.5K of RAM. This should be enough for short routines, and leaves the first 4 pages untouched so hi-res modes (PCLEAR3,1 etc.) work as normal. The CLEAR statement sets the last byte of Basic RAM, so our machine code program can start at &H7000.+The PCLEAR statement clears an extra 3 graphics pages, or 4.5K of RAM. This should be enough for short routines, and leaves the first 4 pages untouched so hi-res modes (PMODE3,1 etc.) work as normal. The CLEAR statement sets the last byte of Basic RAM, so our machine code program can start at &H7000.
  
 Run the Basic program. Now load GTAsm and execute it with: Run the Basic program. Now load GTAsm and execute it with:
Line 38: Line 38:
 Or, since we used the DEFUSR1 directive: Or, since we used the DEFUSR1 directive:
  
-  A=USR1(0)+  A=USR01(0)
      
 EXEC remembers its last address, so as long as we don't use it (or DEFUSR0) for something else we can type plain EXEC to re-run the assembler.   EXEC remembers its last address, so as long as we don't use it (or DEFUSR0) for something else we can type plain EXEC to re-run the assembler.  
Line 51: Line 51:
  
   TFR (use TRF instead - this is a simple error)   TFR (use TRF instead - this is a simple error)
 +  
 +=== Addressing ===
 +
 +Use standard brackets rather than square to specify indirect addressing. Use the "<" and ">" symbols to force 8 and 16 bit offsets respectively.
 +
 +  JSR (,X++)        call subroutine at address stored at X, then point to the next address in the list
 +  LDA (CURSPOS)     load A from the address stored at CURSPOS
 +  LDB >$0034        load B from $0034 using extended mode rather than direct
 +  CLR <LINELEN,   clear the byte at Y+LINELEN, forcing 8 bit offset mode (doesn't work!)
      
 === Directives === === Directives ===
Line 80: Line 89:
 A comment can be added after any valid statement without preceding it with any special character. A comment can be added after any valid statement without preceding it with any special character.
  
-When assembly fails there are a number of useful error messages. Beware that some errors can be missed; sometimes you can write garbage amd have it silently interpreted as a comment.+When assembly fails there are a number of useful error messages. Beware that some errors can be missed; sometimes you can write garbage and have it silently interpreted as a comment.
  
 Keep lines to a reasonable length to avoid a bug in Basic. Entering a line of the maximum length then trying to edit it can cause a system crash. This appears to be due to the single-quote being stored as a two-byte token. Keep lines to a reasonable length to avoid a bug in Basic. Entering a line of the maximum length then trying to edit it can cause a system crash. This appears to be due to the single-quote being stored as a two-byte token.
Line 86: Line 95:
 Compatability: GTAsm is for the Dragon 32 only. If it works on any other system then that's a happy accident. Compatability: GTAsm is for the Dragon 32 only. If it works on any other system then that's a happy accident.
  
-==== In Use ====+==== Example of Use ====
  
 Included on the [[https://6809.uk/cas/GTAsm.cas|cassette download]] is a work in progress. It was intended to be a simple Defender-style space shooter, but for now just allows for scrolling of a spacefield with the up and down arrows. This is the Basic and inline assembly language listing: Included on the [[https://6809.uk/cas/GTAsm.cas|cassette download]] is a work in progress. It was intended to be a simple Defender-style space shooter, but for now just allows for scrolling of a spacefield with the up and down arrows. This is the Basic and inline assembly language listing:
Line 127: Line 136:
   4020 'LBSRPUT:@MLOOP SYNC:LBSRPUT:LBSRSMOV:LBSRPUT:BSRHDO:BRAMLOOP   4020 'LBSRPUT:@MLOOP SYNC:LBSRPUT:LBSRSMOV:LBSRPUT:BSRHDO:BRAMLOOP
      
-To have a look at this, start with a cold boot, insert the tape, and load and run the program with:+To have a look at this, start the Dragon with a cold boot, insert the tape, and load and run the program with:
  
   CLOAD"SPACEDEF"   CLOAD"SPACEDEF"
   RUN   RUN
      
-The program will quit with an ?FC error because the USR routine hasn't been defined yet. Rewind the tape and load the assembler into graphics page 5 (we'll be using the others) and execute it with:+The program will quit with an ?FC error because the USR routine hasn't been defined yet; we ran it simply for the memory reserving statements. Rewind the tape and load the assembler into graphics page 5 (we'll be drawing on the others) and execute it with:
  
   CLOADM"ASMB1E00"     CLOADM"ASMB1E00"  
   EXEC   EXEC
      
-After a delay of a few seconds the OK prompt should reappear. Now again type RUN. You should see some simple smooth-moving space game graphics. All you can do is use the up and down arrows; your spaceship stays still while the background (just that pair of mines at the sides) moves.  +Note that there are two versions of the assembler on the tape, identical except for the load address (which is included in the file name). Also note that there is no machine code listing displayed during assembly as there is no "ON" directive in the code.  
 + 
 +After a delay of a few seconds the OK prompt should reappear. Now again type RUN. You should see some simple smooth-moving space game graphics. All you can do is use the up and down arrows; your spaceship stays still while the background (just that pair of mines at the sides) moves. Soft reset to quit. Now experiment with debugging the program to remove the trails that the mines leave behind. 
              
  
-==== About ====+==== Credits ====
  
 GTAsm was hand written in machine code by Gwilym Thomas and is copyright © 1985. It probably hasn't been debugged since then so don't expect it to be free of errors. But do feel free to have fun with it developing 6809 assembly language programs for your Dragon 32. GTAsm was hand written in machine code by Gwilym Thomas and is copyright © 1985. It probably hasn't been debugged since then so don't expect it to be free of errors. But do feel free to have fun with it developing 6809 assembly language programs for your Dragon 32.
  
  
inline_basic_assembler.1750344035.txt.gz · Last modified: 2025/06/19 14:40 by reggie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki