Starting from:

$30

HW01: Linux, C, and ASM Solution

Part 2: C and Assembly




C and Assembly programs are structured the same way: as a collection of

functions, possibly spread across multiple source files.




But C and Assembly are even more closely related: they both have the same

concept of a "function". A function written in either language can be called

transparently from the other.




In this assignment, we'll confirm that you have a development environment that

allows you to write, build, and run programs written in C and Assembly.




It is recommended that you use the Xbuntu VM from HW01a with the vim editor.




Using homework tarballs




The starter code for this assignment is distributed as a .tar.gz archive (a

"gzipped tarball").




- You can unpack this tarball with: ```tar xzvf [file].tar.gz```

- The starter code is unpacked into a directory. You want to keep this

directory and nested directory structure so as to not confuse the

autograding scripts.

- Once you've completed your work in the assignment directory, you can

pack it up into a new tarball for submission

with: ```tar czvf [new-file].tar.gz [the-directory]```




Task 1:




- Create a C source file, "square.c", containing a function called

"square" that squares a long integer.

- Run "make square" and "./square 5" to verify that the provided

assembly code in "square-main.s" can call your function.




Task 2:

 

- Create an assembly source file, "cube.s", containing a function called

"cube" that cubes a long integer (e.g. cube(3) = 27).

- Run "make cube" and "./cube 5" to verify that the provided

C code in "cube-main.c" can call your function.

- Run "perl test.t" to make sure that the autograder will be happy with

your code. Fix any issues.




To Submit:




- A tarball containing the starter code and your modifications.

- Make sure you don't change the test script.

More products