
COSC 2410 Fall, 2005
Programming Assignment 4
Due: Nov. 29, 2005 --Analysis of the problem and proposed solution: including
documentation, block diagram and tentative subroutines
(Please refer the following link for some subroutines you can use directly after Nov.29th:
http://www2.cs.uh.edu/~jwang3/subroutine-examples.asm )
Due: Dec. 1, 2005 โ Refinement of documentation, two completed subroutines
Due: Dec 8, 2005 โ Final project
In this programming assignment you are to implement a simplified one-pass assembler
for subsets of the MIPS instructions. Since this is a one-pass assembler there will be no
forward referencing. The subsets that your assembler should recognize are given below.
You should modify your subroutines and procedures you developed in previous
programming assignment. To simplify the writing of the assembler, you may assume that
the source code to be assembled by your assembler conforms to the following rules:
1) A statement occupies only one line
2) The fields are separated by one or more blanks
3) A label can be at most 8 characters
4) The operation field is either an instruction or a directive(no pseudo-instruction)
5) Numbers in the operand field are positive, decimal numbers
6) The number of user-defined symbols does not exceed 100
In addition to generating the object code, your assembler should detect the following
types of errors:
1) Multiply defined symbols
2) Undefined symbols
3) Illegal op code
Bonus: (10 points each)
1) Not enough operands
2) Too many operands
The output of your assembler should be a listing file and a sorted symbol table. You
should use ASCII values to sort the symbol table (i.e. Upper case before Lower case)
The object code of a statement must be printed next to the statement. For this you might
want to use a data structure, LINE, that holds the statement, the value of LC at the
statement, and the object code of the statement. LINE can then be printed out later on. If
the statement contains an error then an error message should be printed out instead of the
object code.
The instructions and addressing modes that must be recognized by your assembler are:
Addressing Modes: Immediate, Register
Bonus: Base addressing, PC-relative addressing (10 points each)
Instruction (op code): add, addi, sub, and, or ori, beq
Bonus: LW, SW (10 points)