Skip to content

Instantly share code, notes, and snippets.

@fbrosser
Created October 10, 2012 15:59
Show Gist options
  • Save fbrosser/3866540 to your computer and use it in GitHub Desktop.
Save fbrosser/3866540 to your computer and use it in GitHub Desktop.
Advanced Computer Architecture Assignment Notes

Full Error Reporting for Assembler

1 Difficulty level, Cat E (Programming Support)

A number of improvements have been made to the perl assembler (tinyasm.pl) for the TinyCPU. These changes have all been made in perl code in the file tinyasm.pl. Two test assembly programs have been designed, one successful assembly and one to demonstrate the error reporting and warnings.

The improved error handling is a step up from the old compiler, which did not offer much support at all to the programmer. The introduction of an ORG directive is more or less a necessity, and the RETI instruction is needed to support interrupts. The improvements have been made by adding pattern matching to the assembler to match more advanced patterns than in the basic version, as well as a simple system for counting and printing errors and warnings. To support the error and warning summary, there is also a line counting system. Below follows a complete list of the improvements:

Number formats

The assembler now supports decimal and hexadecimal (hex indicated by "h") number formats for adresses and immediate values.

ORG directive

Assembler directive "ORG" changes the current adress being written to.

Remove empty lines

Empty lines are no longer interpreted as faulty instructions, but instead just ignored.

RETI (7xxx)

Support has been added for an instruction for returning from an interrupt.

Overlapping memory space

If the programmes tries to write to the same memory location twice, a warning is given by the assembler.

Hash for immediate values

Immediate values are now written with hash (#) in order to differentiate from memory adresses more easily.

Missing operands

The assembler now checks for missing operands, and gives error reports accordingly.

Faulty operands

If the programmer tries to use a faulty operand (e.g. pushi A), such as an adress given as argument to an immediate instruction, the assembler gives an error.

END directive

The assembler now accepts the END directive, and puts a HALT instruction where the program ends. Further instructions and data are ignored.

Error and warnings report

After assembling the given file, a complete error report and warnings list is given to help the programmer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment