CS 3330: Homework 4: Y86 HW 2

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

In this homework you'll implement the rest of the Y86 instruction set.

The due date for this assignment has been postponed due to snow-canceled office hours.

Your Task

You should create a file named hw4.hcl and work in that. It should contain a working lab4.hcl, either your own or our example solution.

By the end of this homework, you will have a fully functioning Y86 simulator.

Other built-in signals

Review the list of built-in signals in the README.md bundled with hcl2d. You'll use them all for this assignment:

Stat

The Stat should be

jXX

Note that the immediate value is in bits [8, 40) not [16, 48).

Nothing to do in decode, execute, memory, or writeback; simply update the PC to the immediate value if (and only if) the conditions are met (you should already have a wire conditionsMet:1 from lab).

If jXX is correctly implemented, the following should run for 19 steps, visiting hex addresses 0, 6, c, 17, 19, 11, c, 17, 19, 11, c, 17, 19 11, c, 17, 19, 11, and 16, then halting at address 16:

    irmovl $3, %eax
    irmovl $-1, %ebx
a:
    jmp b
c:
    jge a
    halt
b:
    addl %ebx, %eax
    jmp c

rmmovl and mrmovl

Memory is accessed by setting addr to the memory address in question and either

You will also need to compute the memory address as rvalB + valC (the book suggests you do this in the ALU, meaning the same mux you used for OPl's adding and subtracting).

If both memory moves are implemented correctly, the following should result in edx containing 0x20000 and address 0xa2 containing byte 0x02.

mrmovl 2, %eax
rmmovl %eax, 160(%eax)
mrmovl 158(%eax), %edx

pushl

Decode: read rA and %esp

Execute: add −4 to %esp

Memory: write rvalA to the address computed by that subtraction

Writeback: write the result of the subtraction back into %esp

The following code

irmovl $3, %eax
irmovl $256, %esp
pushl %eax

should leave a 0x03 in address 0xfc and an 0xfc in esp

popl

Decode: read %esp

Execute: add 4 to %esp

Memory: read from the pre-added %esp address

Writeback: write both (1) the result of the addition back into %esp and (2) the results of the read into rA

The following code

irmovl $4, %esp
popl %eax

should leave a 0x08 in esp and a 0xfb00000 in eax

call

call is like pushl and jmp in general form

Decode: read %esp

Execute: add −4 to %esp

Memory: write the next instruction address (valP) to the address computed by that subtraction

Writeback: write the result of the subtraction back into %esp

PC Update: the new PC (p_pc) should be valC, not valP.

The following code

    irmovl $256, %esp
    call a
    addl %esp, %esp
a:
    halt

should leave 0xfc in esp and a 0x0b in address 0xfc

ret

ret is like popl and jmp in general form

Decode: read %esp

Execute: add +4 to %esp

Memory: read from the pre-added %esp address

Writeback: write the result of the addition back into %esp

PC Update: the new PC (p_pc) should be the value read from memory (rvalM), not valP.

The following code

    irmovl $256, %esp
    irmovl a, %ebx
    rmmovl %ebx, (%esp)
    ret
    halt
a:
    irmovl $258, %eax
    halt

should run 6 cycles, leave eax as 0x102, and esp as 0x104

Testing your Code

In addition to the tests above, your code should behave the same as yis when run on anything in the y86/ folder except asuml.yo and asumi.yo (which use instructions not in the y86 basic set) and pushquestion.yo (which is ambiguous and may or may not work the same as yis; we don't care either way).

Submit

Submit a file named hw4.hcl on the submission page.

Copyright © 2015 by Luther Tychonievich. All rights reserved.
Last updated 2015-02-18 12:30 -0500