Unformatted text preview:

CS 429H, Spring 2014Y86 AssemblyAssigned: Feb 7, Due: Feb 20, 11:59PM1 IntroductionIn this lab, you will transform three simple functions from C into Y86 assembly and test them against asimulator. The purpose of this is to give you practice with assembly level programming in general, and withthe Y86 instruction set and tools in particular.2 LogisticsYou will work on this lab individually.Any clarifications and revisions to the assignment will be posted on the course Web page or Piazza.3 Handout InstructionsYou can get a copy of this handout and the assignment code from the course website. Youshould download the asmlab-handout 429H.tar file.1. Start by copying the file asmlab-handout 429H.tar to a directory in which you plan to do yourwork.2. Then give the command:unix> tar xvf asmlab-handout_429H.tarThis will cause the following files to be unpacked into the directory: README, Makefile, sim.tar,archlab.ps, archlab.pdf, and simguide.pdf.3. Next, give the commandunix> tar xvf sim.tar1This will create the directory sim, which contains your personal copy of the Y86 tools. You will bedoing all of your work inside this directory.4. Change to the sim directory and build the Y86 tools:unix> cd simunix> make clean; make4 Program DescriptionYou will be working in directory sim/misc for this lab.Your task is to write and simulate the following three Y86 programs. The required behavior of these pro-grams is defined by the example C functions in examples.c. Be sure to put your name and ID in acomment at the beginning of each program.1. Write your Y86 assembly code in myfile.ys2. Invoke the Y86 assembler to convert your Y86 assembly code to byte codeunix> ./yas myfile.ysThis will generate the Y86 machine-level program in myfile.yo3. Use the Y86 instruction simulator to execute your programunix> ./yis myfile.yoYIS will simulate the execution of the program and print changes to any registers or memory locations.The correct register and memory state is mentioned in the following sections.In all of your Y86 functions, you should follow the IA32 conventions for the structure of the stack frameand for register usage instructions, including saving and restoring any callee-save registers that you use.sum.ys: Iteratively sum linked list elementsWrite a Y86 program sum.ys that iteratively sums the elements of a linked list. Your program shouldconsist of some code that sets up the stack structure, invokes a function, and then halts. In this case, thefunction should be Y86 code for a function (sum list) that is functionally equivalent to the C sum listfunction in examples.c. A sample three-element list for testing your code is as follows. Please ensureyou start your data with the label input data so that I can test your code with other test inputs. Yourcode should be able to take care of linked lists of any length.2# Sample linked list.align 4input data:ele1:.long 0x00a.long ele2ele2:.long 0x0b0.long ele3ele3:.long 0xc00.long 0For the given linked list, your function should return the sum 0xcba in register %eax.rsum.ys: Recursively sum linked list elementsWrite a Y86 program rsum.ys that recursively sums the elements of a linked list. This code should besimilar to the code in sum.ys, except that it should use a function rsum list that recursively sums a listof numbers, as shown in the C function rsum list in examples.c. The input list looks exactly like theone used in list.ys. Please ensure you start your data with the label input data so that I can test yourcode with other test inputs. Your code should be able to take care of linked lists of any length.copy.ys: Copy a source block to a destination blockWrite a program (copy.ys) that copies a block of words from one part of memory to another (non-overlapping area) area of memory, computing the checksum (Xor) of all the words copied.Your program should consist of code that sets up a stack frame, invokes a function copy block, and thenhalts. The function should be functionally equivalent to the C function copy block in examples.c. Asample three-element source and destination block for testing your code is as follows. Please ensure youstart your source block with the label src and the destination block with the label dest so that I can testyour code with other test inputs. Your code should be able to take care of blocks of any length. You canassume the destination block follows immediately after the source block, so that you can initialize len as thedifference between dst and src..align 4# Source blocksrc:.long 0x00a.long 0x0b0.long 0xc00# Destination blockdest:.long 0x1113.long 0x222.long 0x333For the given test input, the function should return the sum 0xcba in register %eax, copy the three words0x00a, 0x0b, and 0xc to the 12 contiguous memory locations beginning at address dest, and not corruptother memory locations.5 EvaluationThe lab is worth 30 points, 10 points for each Y86 solution program. Each solution program will be evalu-ated for correctness, including proper handling of the stack and registers, as well as functional equivalencewith the example C functions in examples.c.The programs sum.ys and rsum.ys will be considered correct if the graders do not spot any errors inthem, and their respective sum list and rsum list functions pass all the test cases.The program copy.ys will be considered correct if the graders do not spot any errors in them, and thecopy block function passes all test cases and does not corrupt any other memory locations except theones following dest.6 Handin InstructionsMake sure you have included your name and ID in a comment at the top of each file you submit. Name yourfiles sum.ys, rsum.ys and copy.ys. Turnin your files through canvas as a tar file with the name ”uteid.tar”.For example, if your UTEID is vn339, then submit a file named


View Full Document

UT CS 429H - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?