x86 assembly and C integration

Coursework · x86 assembly, C, stack frames, recursion

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.

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

LabTopicSource
1Byte summation and loopsAssembly
2Register arithmeticAssembly
3Comparisons and conditional branchesAssembly
4Indexed addressing and string parsingAssembly
5Stack frames and FibonacciAssembly · C driver
6Function interfaces and factorialAssembly · C driver