Assembly Code Programming

Notes on using the M6809 assembler in the lab

  1. Prepare the source file using the Editor program in the usual way. The filename should be given the extension .asm (e.g. test.asm). The format must be as given below - if there is no label on a line there must be at least one space character preceding the instruction mnemonic.
    
                                      org     $3000
    
                                      ldx     #$C646
    
                              loop    leax    -1,x
    
                                      bne     loop
    
                                      swi
    
                                      end
    
    
    Note that assembler directives do not have a dot preceding them and to obtain the # symbol it may be necessary to use the "pound" key (shift-3).
  2. Exit from the editor and type asmset to set up a path to the directory in which the assembler is stored. The source program is assembled by giving the command asm6809 followed by the filename. In order to generate a file containing a listing of the source and object programs it is necessary to give the command in the form below:-
    
                              asm6809 test.asm -l > test.lst
    
    
    This redirects the output listing to a file called test.lst which can then be listed or printed.
  3. Errors in the source program can be corrected using the editor and then the program can be re-assembled using the procedure in (2). Do not use the machine code from a listing which contains errors as these may invalidate code even if it appears to be correct.
  4. The assembler has a tendency to use direct page addressing. To ensure that extended addressing is used prefix the address with >.
    
                              e.g.   lda   >$fe00
    
    
A.J.Tollyfield 26/10/93

Notes on downloading assembled programs in the lab

  1. When you have successfully assembled a program the assembler automatically creates an S19 file. This is a file which contains the machine code version of your program in a special format known as S records which includes all the instruction bytes together with address information and error checking bytes. The name of this file will be the same as the file you assembled but with a .s19 extension. I.e. if you assemble test.asm a file test.s19 will be produced. This is the file which will be downloaded to the lab-kits.
  2. Two programs are required to download the S19 file, one running on the PC and one on the lab-kit. To run the program on the PC type asmset to set up a path to the directory where the program is located, then download to run the downloading program. The settings for the serial link are displayed and you are requested to type the name of the file to be downloaded. Type the name without the S19 extension. If the file exists the download program asks you to press any key to start transmission. Do not do this yet.
  3. Make sure the serial link from the PC is plugged into the correct connector on the lab-kit. This is the left-hand connector viewing the kit from the front.
  4. On the lab-kit, make sure the normal prompt is displayed Cmd/Add> and start running the program by typing E5C0 G. The screen will go blank.
  5. Press any key on the PC to start the process. A dot will be displayed for each byte sent. If the file is transferred successfully the PC will display an appropriate message and the lab-kit will display Trans O.K. before returning to command mode. If an error occurs the lab-kit will display Trans Error. In this case the procedure should be repeated.
A.J.Tollyfield 25/10/94
See a sample program written in assembler format.
Lecture notes