For Chapter 3

add.s: shows the minimal structure of a very simple assembly (spim) program.

sum_to3.s: A program to verify that 1+2+3=(1+3)*3/2.

cubesum.s: Sum of cubes using loop.

Lab 2.2 solution bcopy.s

For Chapter 4

multiply.s: software implementation of multiplication.

follow3.s: the program of first quiz.

divide.s: software implementation of integer division.

poly.s: an example with floating point numbers.

Lab 3 solution booth.s; Lab 4 solutions gcd.s and expt.s.

swap.s: the swap procedure and the sort.s (the sort function) discussed in class. And the main program in C: callsort.c.

For Appendix A

Recursive factorial function factorial.s.

Lab 5 solutions string2int.s and legendre.s.

Other examples

example0.s: shows the minimal structure of a program.

example1.s: a hello program, demonstrates the convention for calling a function (printf).

example2.s: similar to example1, but print integer and floating point numbers.

example2b.s: calling scanf and printf.

example3.s: how does the main function call another very simple function sum.

example3b.s: contain only the function sum, which can be called by another assembly program or C program.

ex3b.c: shows how the C program calls the sum assembly program, example3b.s.

arraysum.s: An example assembly program to compute the sum of an array A[0] + A[1] + .... The program is called from C by callasum.c. Part of the assembly code is discussed in class.