CPSC 355 Lecture Notes - Lecture 28: Gnu Debugger, Assembly Language, Function Prototype
Document Summary
Cpsc 355 - lecture 28 nov 21st. Example using two separate assembly code files. global stp adrp x19, a_m add x19, x19, :lo12:a_m ldr w0, [x19] bl myfunc ldp ret. > reference to object in the other module. global stp sub w0, w0, 1 ldr ret. Assemble and link: as first. s o first. o as second. s o second. o gcc first. o second. o o myexec. Note: this can be done using a makefile. Viewed in gdb: (gdb) x/8i (gdb) x/wd a_m (gdb) x5i myfunc. C code can call functions written in assembly: can be useful when optimizing sections of code. // function prototype int i = 5, j = 10, result; result = sum(i, j); // a function defined in assembly in sum. s printf(cid:894)(cid:862)result = %d\n(cid:863), result(cid:895); return 0; #include int sum(int, int); int main( ) { 4 sum add w0, w0, w1 // w0 and w1 are input parameters, leftmost w0 is the return value ldp ret.