Programming Examples
4. Demonstrating the Procedure Calling Convention
4.Demonstrating the Procedure Calling Convention
A C program calls an assembly language program to test if .ENTER and
.LEAVE are working correctly. The assembly language program checks to see if the C program has passed the value zero in arg0. The assembly language program then returns the value
You need to compile this assembly listing using cc. The registers ret0 and arg0 are declared within /usr/lib/pcc_prefix.s, which is automatically included when you give the C compiler an assembly file.
To remove the dependency on pcc_prefix.s, replace all occurrences of ret0 with %r28 and arg0 with %r26.
C Program Listing
#include <stdio.h> int errorcount = 0; main ()
{
int toterr = 0;
printf("TESTING FEATURE 000");
fflush(stdout); |
|
|
if( feat000(000) | != | |
printf(" | %d | errors\\n",errorcount); |
toterr += errorcount; errorcount = 0;
}
136 | Chapter 7 |