UMBC CMSC 313, Computer Organization & Assembly Language, Fall 2002, Section 0101
The Stack & C Functions II
Thursday 10/10, 2002
[Up]
[Previous Lecture]
[Next Lecture]
Assigned Reading in Murdocca & Heuring: 7.7
Assigned Reading in Neveln: 8.1-8.8
Assigned: Proj4
Due: Proj3
Topics Covered:
- We continued discussion of C function call conventions.
- We looked examples of calling C functions from assembly language
programs (e.g., calling printf()). We used gcc to
link/load the program to avoid having to figure out the options
to give to ld to get this to work.
- We looked at C programs calling assembly language functions.
Programs shown:
- A more complicated C function converted to assembly language
using gcc -S (shown only briefly):
cfunc.c,
cfunc2.s (AT&T style assembly),
cfunc2.asm (Intel style assembly).
- A C function with a return value with size more than 4 bytes
(shown only briefly):
cfunc3.c,
cfunc3.asm
(The comments in this file were added afterwards).
- An assembly language program that calls printf to write
to stdout (with C style main function):
printf1.asm,
printf1.txt.
- An assembly language program that calls printf to write
to stdout (with assembly style _start entry point):
printf2.asm,
printf2.txt.
- An example of a C program that calls a function implemented in
assembly:
arraytest.c,
arrayinc.asm,
arraytest.txt.
Last Modified:
22 Jul 2024 11:27:51 EDT
by
Richard Chang
to Fall 2002 CMSC 313 Section Homepage