CS 3330: Lab 3: Playing with the Y86 Simulator

This page does not represent the most current semester of this course; it is present merely as an archive.

This is a solo assignment. You may discuss concepts freely, but all your HCL and Y86 code should be your own.

Obtain and Test the Simulator

See the associated lab for how to do this.

Using SSH

SSH (as set up on our machines) does not allow window creation. To run via SSH, you'll need to comment out all GUI and TK related material in the Makefiles in the sim/, sim/seq, and sim/pipe directories.

The following command will add the comments you need if run from sim/:

linux> sed -i -e 's/^\(GUIMODE\|TKLIBS\|TKINC\)=/#\1=/g' Makefile seq/Makefile pipe/Makefile
linux> make clean
linux> make

After making this change to the Makefiles, you will not be able to run the simulator in GUI mode.

You can undo that command and re-enable GUI mode with:

linux> sed -i -e 's/^#\(GUIMODE\|TKLIBS\|TKINC\)=/\1=/g' Makefile seq/Makefile pipe/Makefile
linux> make clean
linux> make

Write some Y86 Code

cd into the y86-code folder.

Make a new file called hw3.ys (this is the second HW but I want to keep the numbers in syn with the lab numbers). In that file you will write some Y86 code. I suggest you use the following starter code

    irmovl  Stack,%esp
    irmovl  $8, %eax
    irmovl  $1, %ecx
Head:
    pushl   %esp
    subl    %ecx, %eax
    jne     Head
    halt
.pos 0x30
Stack:

(note: your file needs to end with a newline for the Y86 assembler to assemble it)

Modify that base code to have the following properties:

You may download hw3yschecker.sh into your y86-code directory and run it as bash hw3yschecker.sh to see if your code complies with these rules.

Note: hw3.ys is intended to run on the unmodified ssim based on seq-std.hcl, not the version you modify by writing seq-hw3.hcl in the next part of the homework.

Change the Simulator

cd into the seq folder and cp seq-std.hcl seq-hw3.hcl. Then edit the seq-hw3.hcl to do the following:

You can make your simulator with

linux> make clean
linux> make ssim VERSION=hw3

You can test it with the following code:

irmovl  $32, %eax           # eax = 0x020
irmovl  $256, %ebx          # ebx = 0x100
rmmovl  %eax, 4(%ebx)       # 0x0104 = 0x00000020
addl    %ebx,%eax           # ebx = 0x120
mrmovl  -28(%ebx), %ecx     # ecx = 0x020
rrmovl  %ebx, %edx          # edx = 0x120
irmovl  $512, %esp          # esp = 0x200
pushl   %ebx                # 0x0204 = 0x00000120
popl    %ebp                # ebp = 0x00000120
nop                         # invalid; program halts
irmovl  $17, %eax           # never executed

which should do what is noted in the comments. You should end up with a address 0x0204 modified (stack grows up, not down), %ebx should be 0x120 not 0x100, and the other registers should have the values noted.

You may download hw3hclchecker.sh into your seq directory and run it as bash hw3hclchecker.sh to see if your modifications meet all the specifications.

Turn In

Submit both hw3.ys and seq-hw3.hcl on the submission page.

Copyright © 2015 by Luther Tychonievich. All rights reserved.
Last updated 2014-09-23 19:19 -0400