x86 assembly and C integration
I completed six assembly labs covering registers, addressing modes, control flow, and function calls. In the later labs, I implemented recursive Fibonacci and factorial routines in x86 assembly and called them from C programs.
RepositoryFibonacciFactorialC driver
Recursive routines
Fibonacci
The Fibonacci routine uses a shared global variable for input and output. It allocates stack space to preserve the original argument and an intermediate result while making recursive calls for n − 1 and n − 2.
Factorial
The factorial routine reads its argument from the stack, passes n − 1 to a recursive call, and multiplies the returned value by the original argument. It returns its result in EAX. The accompanying C driver calls the assembly routine and prints the result.
Lab source
| Lab | Topic | Source |
|---|---|---|
| 1 | Byte summation and loops | Assembly |
| 2 | Register arithmetic | Assembly |
| 3 | Comparisons and conditional branches | Assembly |
| 4 | Indexed addressing and string parsing | Assembly |
| 5 | Stack frames and Fibonacci | Assembly · C driver |
| 6 | Function interfaces and factorial | Assembly · C driver |