[an error occurred while processing this directive]
Checklist: TOY Encryption
Frequently Asked Questions
|
What are the goals of this assignment?
To learn to program in a machine language; to gain a better
understanding of how variables are stored and manipulated in the
computer; and to appreciate the programming and debugging advantages
of a structured programming language like Java over machine language!
I can't launch the Java Web Start version of the
Visual X-TOY simulator on my laptop. Any ideas?
The program requires something called Web Start. When you
installed Java initially, this was included. However, Windows
security patches have been know to break it. If this happens to you,
go to java.com and click the
Get It Now button.
I can't launch the Java Web Start version of the
Visual X-TOY simulator in the Moore 100 labs. Any ideas?
The link in this assignment will not work on the Linux machines in the
Moore 100 labs. Instead, select the Terminal from the start menu, and
type "xtoy". The link in the assignment does work on the
Windows machines, but there is also an icon for X-Toy in the Start
Menu under the CIS 110 section of the Course Specific Software menu.
How do I format the TOY output?
You can't. Just print one integer per line (0000 or 0001).
My program prints out the right answer, but then I get
java.lang.NumberFormatException: null. What could be
wrong? You are probably trying to read from standard input, even
though it is empty. Be sure that your TOY program terminates when it
encounters FFFF.
How do I write/comment a .toy file?
To initialize a location in memory to have a value, write (on its own line) the
index of the memory location (two hex digits), followed by a colon,
followed by a space, followed by the value (four hex digits).
Anything else on the line is ignored by the TOY simulator and
treated as a comment. Any line that does not follow this format is
also interpreted as a comment, but you should begin comment lines with
"//" as a matter of good style.
TOY.java doesn't read in some of my instructions. Any ideas?
Be sure that you follow the required format XX: XXXX. Check
for duplicated line numbers and using the letter O instead of the number 0.
How much do I need to comment my TOY code?
At a minimum, you should:
- Comment each TOY program with your name, login, and recitation.
Your header should also describe the purpose of the program,
including what it reads from standard input and what it writes to
standard output.
- Include a register map at the top of your .toy file, as well
as in your readme.
- Comment each TOY instruction with its "assembly language"
equivalent. Visual X-TOY can do this for you automatically.
- Comment each block of code that serves a high-level purpose,
e.g., read seed length, seed, and tap bit.
- If you're not sure, comment more. Since you can't give
descriptive names to registers and memory addresses like you can
to variables, assembly is extremely hard to read and debug without
thorough comments.
To simulate the execution of your program on a TOY machine,
use either the bare-bones TOY.java or
the full-blown Visual X-TOY simulator.
To get started, download the sample TOY program
multiply.toy.
Visual X-TOY simulator.
The Visual X-TOY simulator from lecture provides lots of useful
development features. There are three modes (edit, debug, and
machine). Download it from the link on the assignment page.
- To load a TOY program, select File -> Open,
then browse to find the program, e.g., multiply.toy.
- To execute your program, select Mode -> Debug Mode.
Then click the Run button at the bottom.
You can enter data on standard input by typing the value in the Stdin
tab and clicking the Add button.
You will have to click theRun button to resume execution.
You can see the results on standard output in the Stdout tab.
- To edit your own program, select Mode -> Edit Mode.
You can type your program directly in the edit window.
You might wish to use multiply.toy as a reference for formatting
and commenting.
- To redirect standard input from a file, select
Mode -> Load File to Stdin. You should be able to write and
debug your program completely within Visual X-TOY using simple input
files like zeros.in before switching to images
and the command line.
- To auto-comment your program to include the assembly language
code, select Tools -> Auto-comment Code.
- If the assembly language code is not automatically kept
up-to-date with the machine code, select Tools|Options,
click Auto-Complete, then check Commenting
Auto-completion. If you are using Visual X-TOY 7.2, available
on the assignment page, this will update the assembly comments
whenever you modify an instruction, and prevent you from changing
the assembly comments directly (rather than updating the machine
instruction). If you are using Visual X-TOY 7.1 from the
booksite, you will need to select Commenting and Un-commenting
Auto-completion This auto-completion mode will only add
assembly statements when you enter new instructions; it will not
update them or prevent you from editing them.
Command-line TOY simulator.
Download the TOY simulator using the link on the assignment page.
- Compile it with
% javac TOY.java
- Test it by typing the values in boldface.
% java TOY multiply.toy
...
Terminal
---------------------------------------
0002
0005
000A
...
First, you will see a core dump (the contents of the pc,
the registers, and main memory) before the computation begins.
Then, you will see the results of the computation, where standard
input comes from the terminal and standard output goes to the
terminal.
This TOY program expects you to enter two integers from
standard input (in hex); after you do this, you will see
their product (in hex) on standard output.
Finally you will see a core dump after the computations ends.
- The version of TOY on the assignment page prints the core dump
in a different way than the version on the booksite so that it
will not interfere with the actual program output. Do not use
the booksite version of TOY.java! You will not be able to pipe
the output to TOYReadImage.
- To edit your own program, use a text editor.
You can use multiply.toy as a reference for formatting and commenting.
Here are some debugging hints that may help you out.
- Remember that all values, memory addresses, and arithmetic are
in hex. This is by far the most common error. For example, 1A comes
after 19.
- Don't forget that Register 0 always contains the value
0. You can specify R0 as a destination register in any
instruction, but the result will not be stored in R0. Instead
it will be silently discarded.
- 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.
- Don't confuse the gray line numbers in X-Toy that are purely
for cross-referencing warnings and error messages to lines in your
file with the hexadecimal memory addresses that start off each TOY
instruction. The instruction "10: 1234" means load the hex
value 1234 into memory address hex 10 (decimal 16) no matter which
line of your file it appears on.
-
Comment your TOY code. Also, this may sound silly, but don't
accidentally update your comments and forget to update the
actual code! Using Visual X-TOY 7.2 from the assignment page, rather
than version 7.1 from the booksite will help you avoid this pitfall.
- All registers are global variables, so be careful.