rasm user manual

Title rasm (Retargetable assembler)
Author Nikolaos Kavvadias 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
Contact nikos@nkavvadias.com
Website http://www.nkavvadias.com
Release Date 24 February 2014
Version 1.0.0
Rev. history  
v1.0.0

2014-02-24

Changed documentation format to RestructuredText. Added COPYING license in separate file.

v0.2.0

2003-04-08

Public adaptation of version 0.1.0.

v0.1.0

2003-04-05

Initial release.

1. Introduction

These are the source files and preliminary documentation of rasm (Retargetable assembler) by Nikolaos Kavvadias.

2. Main features

The assembler follows a two-pass strategy. At the first pass, the symbol table is updated with the symbolic branch addresses. At the second pass, full assembly of the source code is taking place, and the symbol table whenever it is necessary to determine an address for a named label.

Its differentiating feature is the coding approach so the user can easily add/ replace instructions or modify the existing instruction formats.

A "toy" instruction set is supported in this version of rasm. The "toy" instruction set is described in the following table:

2.1. Instruction formats

  • R-format
31   26 25   21 20   16 15   11 10   0
OpCode Rd Rs1 Rs2 unused
  • I-format
31   26 25   21 20   16 15   0
OpCode Rd Rs immed
  • B-format
31   26 25   0
OpCode branch target address

2.2. Supported instruction set

Instruction format OpCode Description Action
ADD Rd,Rs1,Rs2 0x04 Add Rd := Rs1 + Rs2
CMP Rs1,Rs2 0x0B Compare flags: Rs1 - Rs2
LD Rd,Rb,Ro 0x08 Load register Rd := m[Rb+Ro]
MUL Rd,Rs1,Rs2 0x0A Multiply Rd := Rs1 * Rs2
ORR Rd,Rs1,Rs2 0x11 Logical OR Rd := Rs1 || Rs2
ST Rs,Rb,Ro 0x10 Store register m[Rb+Ro] := Rs
SUB Rd,Rs1,Rs2 0x03 Subtract Rd := Rs1 - Rs2
ADDI Rd,Rs,#immed 0x05 Add immediate Rd := Rs + immed
MOV Rd,Rs 0x12 Move register Rd := Rs
MOVI Rd,#immed 0x09 Move immediate Rd := immed
B $target 0x16 Branch uncondit. PC := target
BLT $target 0x17 Branch if less than
if (flags):
PC := target

3. File description

The RASM distribution includes the following files.

/rasm Top-level directory
COPYING License agreement (GPL, version 2 license).
README This file.
README.html HTML version of README.
README.pdf PDF version of README.
rasm.c Contains the main() routine.
rasm.h

Definitions and constant declaration for the retargetable assembler

  • bitmask: array of bit-masking constants
  • opcode: the fixed-size opcode symbol table
  • instruction format tables (rform, iform, bform)
rasm.y Grammar description file for the "toy" assembly language.
rasm.lex Lexical description file for the "toy" assembly language.
rst2docs.sh Shell script for generating the documentation using docutils.
test1.asm Sample assembly source file.
test1.hex Sample generated file from the assembler.

4. Deliverables

5. Requirements