For this assignment you will write a TOY machine language program.
You will not have to write any C code.
Here are some debugging hints that may help you out.
Remember that all values, "line numbers", and arithmetic are
in hex. This is by far the most common error.
The pc is initially set to 10, so the first instruction
of your TOY program must be at memory address 10.
Comment your TOY code. Also, this may sound silly, but don't
accidentally update your comments and forget to update the
actual code! The Java simulator does not currently support
comments, but be sure to include them in your final submission.
You have only 8 registers to work with, so you may need
to reuse some registers for different purposes.
Be grateful that you have 8; many early computers had only 2,
so you would need to store variables in memory, and transfer
them back and forth to the registers as needed.
Recall that there is no register R8, and
that all registers are global variables, so be careful.
Check the initial "core dump" to be sure that your program
was read in correctly. This will fix common errors like
having two or more instructions with the same line number, or
forgetting the colon after the memory address.
Watch out for jump statements - if you insert a new line of code
between existing lines, the location that you want to jump to may change.
Also, after updating the line numbers, check that there
are no inadvertent "gaps" in line numbering. You need to be careful
to use consecutive "line numbers", since if you
don't specify the initial contents of some memory address, it
is set to 0000 which means halt.
You may use "dummy" instructions as in the TOY notes.
If you use the C version of the TOY simulator, use opcode
4 to print out the value of a particular register.
This is the analog of printf() debugging in C.
In the Java version, the output goes to the Java console.
To view this in Netscape 4.7, select
Communicator-Tools-Java Console;
in IE 5, select
Tools-Internet Options-Advanced-Java Console Enabled.
If you are using the C version of the simulator, you may
find it helpful to add extra dump() and
dumpreg() commands in the simulator for debugging.
Kevin Wayne