COSC 201: Computer Organization

Lab 1: ARMv8 Assembly Introduction

Purpose
Learn about basic ARMv8 assembly instructions and how the general purpose registers are used by assembly language. Programming will be donw on your Raspberry Pi computer.
Method
Set up the Raspberry Pi. Read a simple assembly program and analyze how register values are changed by it. Modify the same assembly code to do a different arithmetic operation.
Preparation
Read sections 2.1-2.3 from the text
Files to use
prog1.s , chkprog1.c
What to Hand In
Modified prog1???.s, lab1???.txt, prog2???.s, chkprog2???.c
Click here to get gdb.
Click here to get summary of instructions to use in linux.

  1. Set up your Raspberry Pi, following the instructions in lab. Click here for a copy of the instructions. Note the first two steps have already been done for you. Use the following registration code: 40D6B637DDF86C
  2. On your Raspberry Pi, open an xterm window and go to the Desktop and make a lab1 directory. (See the summary of linux instructions.) Open the firefox browser and go to the course syllabus and click on the lab. Right click on each of the files needed and save them to the Desktop/lab1 directory.
  3. Open the emacs editor and open prog1.s and read it. Annotate prog1.s by indicating the values in each register under the headings given. If the value is unknown, indicate with a "?" use save as to save your modified file as prog1???.s, where ??? is replaced by your last name and first initial. For example progr1NevisonC.s.
  4. Open chkprog1.c in emacs and read it. This is a c program that calls prog1.s when the two are compiled together. How do you suppose the result of prog1.s is communicated to chkprog1.c? How do you suppose control moves from prog1.s back to chkprog1.c after it is done? What must happen when prog1.s is called for this to work? Write your answers into a text file, lab1???.txt
  5. Compile and assemble these files by typing:     gcc-6 checkprog1.c prog1.s
  6. Run the executable file by typing: ./a.out
  7. Write you own simple assembly program, named prog2???.s, that computes the expression (8 + 9) - (3 + 11).Write a heading similar to the one given in prog1.s, but changing the name, date, etc. appropriately (hint: open prog1.s in emacs and modify it appropriately, then save as prog2.s). Load each constant into a different register (X9, X10, X11, X12) using the mov instruction in the same way it is used in prog1.s. Put the result into the appropriate register, so that it could be found by a calling program, analogous to chkprog1.c. Write such a calling program, naming it chkprog2???.c. (hint: open checkprog1.c in emacs and modify it, then save to checkprog2.c)
  8. Test your new program by compiling, assemblying and running it, as in step 5.
  9. Turn in your work by emailing the required files to me.
  10. Shut down your raspberry pi by going to your xterm and typing: sudo shutdown        Then you need to enter the root password.     The pi will shutdown in 1 minute. Then unplug it.