CSCI 2400: Assembly Class 1
Welcome to assembly programming!
Let's get started with a simple "Hello, world!" program.
In today's class you will:
- Log in to hopper.slu.edu
- Assemble and run our template program
- Modify this program's behavior
- First we need a Linux environment, so we will remotely connect to the department
server at hopper.slu.edu.
Alternatively, you can login locally and then
also connect to hopper so that you can always access your work remotely.
In general you will only ever need Linux terminal
access for these exercises, though you're welcome to use NoMachine if you'd
like the GUI desktop. If you're using one of the classroom machines, login by typing at a terminal:
- Make a new directory for your work with the command
mkdir new_dir_name, then
change to that directory with the command
- Now, download the template program to Hopper with the command wget:
- First, take a moment and look at the program in a text editor of your choice. There are only
a few lines of code between the comments "Our code starts here" and "Our code ends here". Can you
describe what the first set of lines does? Can you describe what the second set of lines does? If you can't,
try to remember the "program stack" that we talked about in class. If you're still not clear, call
the instructor over to explain.
- There are currently two variables in this program- what are they called and what
are their values?
- What will this program print to the console?
- Assemble the program and run it with the commands:
gcc -m32 template.s -o template
- Change the output of the program by modifying the variable
"string" and the variable "a". Make sure that you still print the value of the
variable "a". Re-assemble and re-run your program to make sure it works correctly.
- Now change the output of your program by inserting an
before the first
pushl instruction. The first operand should be an
immediate instruction, and the second operand should be the variable name "a" without
dollar signs or percent signs.
- Modify your program so that it contains a second variable named "b", and
so that your program prints both the value of a and b. (Use a single call to printf)
- Did the variables print in the order you expected? Why or why not?
- Keep your program for submission with the next homework. Have a nice day!