CPSC 355 Lecture Notes - Lecture 28: Gnu Debugger, Assembly Language, Function Prototype

181 views5 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents