Writing Y86
Goals
- Write Y86 Mini Programs
- Assemble using YAS
- Simulate
Needs
//TODO
You are given 3 "stubs" of a Y86 program. Each follows a pretty standard formula:
- The expectation of the program is explained to you.
- Some set-up (registers initialized, etc.) is done for you.
- A chunk of code where you should implement the program is commented out.
- Auto-graded check for correctness wraps up the program.
You need to fill in the part of the program bookended by the # WRITE ASSEMBLY CODE HERE #
comments with Y86 assembly that fulfills the expectation of the program. Once finished with your Y86 instructions, you can test your solution by assembling your .ys file into a .yo file by passing it to the YAS (Y86 Assembler). This is easily done by saving your .ys file in the /y86-code/
directory (see the Y86 Simulator Lab for reference) and typing make FILENAME.yo
where FILENAME
is the name of the .ys file, sans the ".ys" extension. If any errors are produced when trying to assemble (most likely there will be some on your first or second try having to do with syntax, instructions etc.) they will be printed to the console. Once finished, this will assemble your FILENAME.ys
assembly file into object code that is ready to be run on the simulator.
To simulate the execution of one of your newly created .yo file (using SEQ
), try the following steps:
:$ cd seq
:$ ./ssim -g ../y86-code/FILENAME.yo
The %eax register will contain 1
if your solution is correct. Anything else in %eax means the program did not accomplish what was intended.
DO NOT change any code outside of the # WRITE ASSEMBLY CODE HERE #
comments.
HINTS
- The only arithmetic and logical operations (OPl) Y86 has are
addl, subl, andl, xorl
. - OPl's only take registers.
- See ISA Lecture Slides - Randal E. Bryant, CMU (pdf) for help.
Turn-in
Through the online interface.