ECE 2325                                UMD                                      S.Norr                     Fall 2002

 

 

EXAMPLE OF CONVERTING THRSim11 Code for use in MWAH 355 Lab:

 

Code from program 1 of Lab1:

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                ; Program 1 puts two Hex values in Page Zero of memory,

                ; adds them using accumulator A and stores the result back

                ; in memory.  The instructions which manipulate accumulator A

                ; all use Extended Addressing Mode               S.Norr

                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

                                org 0                       ;tells the assembler to start at address $0000 (RAM)

 

DAT1                     db  D7                    ;tells assembler to define memory byte $0000 as hex D7 in

;Page Zero of memory

DAT2                     db  16                     ;define memory byte for operand 2 (byte $0001)

SUM                       rmb  1                     ;reserve one memory byte for Sum (byte $0002)

 

 

                                org FF00                ; tells the assembler to move to address $FF00 (ROM)

 

START                  LDAA $0000         ; load the data from $0000 into accumulator A

                                ADDA $0001        ; add the data from $0001 to contents of Acc. A

                                STAA  $0002        ; store the contents of Acc. A into memory at $0002

LOOP                     BRA    LOOP         ; nice way to stop without running wild.

                                                                ; this instruction branches back on itself in

                                                                ; an endless loop.

 

  1. First, get rid of all the comment lines, they’ll just clutter up the small screens in Lab if you have

to edit the program on the EVB monitor.

  1. Next, make sure all directives, instructions and hex digits are lower case. 
  2. All labels need a colon after them.
  3. Change the memory address locations in the ORG directives to comply with EVB board memory map.  In other words, org  0    should become  org c000, etc.
  4. Change memory address locations in the instructions which use extended addressing.  For example, LDAA $0000 should become ldaa c000.
  5. Note that the ‘$’ symbol was also removed from the instruction.  The asm11 assembler in MWAH 355 hates dollar signs (must be a non-profit bias)
  6. Finally, remove the BRA (branch always) instruction and replace it with swi  (software interrupt).  This sets a flag in the condition code register that informs the Monitor Program to retake control of the monitor and display all register values.
  7. Asm11 also doesn’t like FCB (form constant Byte), so use db (define byte).  Apparently, DS (define storage), RMB (reserve memory byte) and FDB (form double byte) are not supported either, so don’t use them.

 

The cleaned code should look like this:

 

                        org c000

Dat1:               db   d7

Dat2:               db   16

 

                        org c100

Start:               ldaa c000

                        adda c001

                        staa  c002

                        swi

 

Also, remember that transferring this file from a PC to the unix system will expose a ^M character

on the end of each line.   This must be edited out of the unix file PRIOR to using the asm11 command.

 

 

The best way I have found to edit out the ^M:

 

Download QVT/Term from the ITSS webpage.  Use it as a telnet client with your PC to logon to the university unix system.  After logon, you will automatically launch the UMENU client, from which you can select unix as an option.  Selecting unix automatically puts you into your home directory on the unix account.  Use the command vi filename to edit out the ^M characters.