Back
CS 456 Home

Assignment h5: Implementing the Unix Copy command in NASM

Due Date: April 24 @ 8AM EDT

This time around, we're going to take a command that we should already be 
familiar with, the cp command, and implement this in NASM 32-bit assembly. 

You will start with the following files: Makefile, functions.asm and copy.asm

You will not need to modify Makefile or functions.asm, as that is there to help
you complete this assignment. The functions.asm file contains functions that we 
used often in the NASM tutorial. The Makefile is there to help with compiling
the source code, all you have to do now is type "make" and it will run the 
compilation.
 
From the readings and the in-class code you can probably figure out that copy 
will be similar to our implementation of cat in asm, execpt we also invoke the
creat system call (and invoke close twice). I also invoked the fstat (well, 
technically fstat64) system call to get the permissions as unlike the readings,
I did not want the permissions hardcoded. I did the fstat for you to get the 
permissions, all you need to do with regard to that is put the permissions in 
the correct place. 

In short, it's basically the cat command, but output to a different file,

There are programs in the in-class code that will help you out, the readings I 
provided should be of help as well  I ask that you not depend on Generative AI 
(like ChatGPT, etc) to do this assignment. You should be able to do this 
assignment based on the examples given in the book and in the In-class code.

To pick up this assignment, copy the h5 folder into your cs456 directory by running: 
		     cp -R /home/cs456/h5/ ~/cs456/
		OR:  hw_get.py cs456 h5

Then use a text editor (like vi, nano, emacs) to open it and make the necessary 
edits to accomplish these objectives.

Once finished, leave it in that directory. I will run a script to collect the 
files when the due date approaches.