Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

2) Make your assembler more intelligent so that it can catch errors, tell the user what the error is, and possibly suggest corrections.

a. Duplicate Labels

If there are two identical labels, my assembler will catch the error.

 

b. Unknown Operation

If the operation is not in the instruction table, then the seemlier will report the error. For example, the assembler does not know the operation "output." 

 

c. Unrecognized Registers

If the order of registers are flipped, my assembler will catch the error and suggest correction.

I used try -except.

Image Removed

wrong order of registers

catches error and suggests correction

Image Removed

 

Image Removed

Image Removed

and except to handle this kind of errors.

 

i.

For example,

Image Added

the immediate value was put after the destination register whereas the right order should be movie 1 RA. 

Image Added

 

ii.

In the following example, the source register RG is not in the register fields.

Image Added

Image Added


iii.

The destination register RF is not in the register fields, so the assembler will report an error.

 

3) Create some test programs that evaluate all of the CPUs capabilities.

...

The program testInstr.txt uses all the remaining rest instructions.


I commented what should be executed in the text files. The results of simulation are as expected.

...