Main »

Using the Assembler

edit SideBar

Using the Assembler

The -prog option of the script will do the assembling steps for you, so most of the time, you do not need to do the following steps manually. These instructions are listed here just for reference, to let you make clear what is going on when you assemble and load a program.

In order to test your processor, you may need to assemble programs to be loaded into memory. To do this, there is a simple assembler provided. It will take source code that looks like the text in figure below and produces two files:

  • An object file, and
  • A listing for your reference.

An example assembly program foo.asm:

// An example assembly program

slbi	r1, 0
slbi	r1, 0x55
slli	r2, r1, 8
bnez	r2, .LAB3
subi    r2, r2, 1

An example object file:


An example binary listing:

0000 9100 slbi	r1, 0
0001 9155 slbi	r1, 0x55
0002 a948 slli	r2, r1, 8
0003 6a01 bnez	r2, .LAB3
0004 4a41 subi    r2, r2, 1
0005      .LAB3:
0005 0000 halt

Running the Assembler

The assembler is located here:


That directory should have already been added to your PATH variable.

Say you have a source file named myfile.asm:

  • To assemble it, do: myfile.asm
  • This produces many files, two of the files are: The listing file called loadfile.lst, and the object file (loadfile_all.img).
  • The assembler always produces a warning that if there are any errors, the output is not valid. This is just a reminder -- this message itself is not an error.
  • The assembler will also produce 4 files named loadfile_0,1,2,3.img. These are binary images you can load into the four-banked memory when you get to it. You load one of these files into each bank.

To simulate running the problem image on a golden simulator, see WISC-SP13 simulator-debugger.

Assembly Syntax

Assembly programs are written using the semantics outlined in the WISC-SP13 ISA document. C style comments can be used (//). Static data and labels can be used as follows:


beqz r0, .label1

<-- code here -->

Static data:

lbi r0, L.DataArea //load the lower half of datum
slbi r0, U.DataArea //load the upper half of datum

data 0x1234
data 0x5678

Page last modified on October 03, 2020, visited times

Edit - History - Print - Recent Changes (All) - Search