![](/images/backgrounds/286207/hp-hp-ux-developer-tools-reference-guide-669687138x1.png)
Programming Examples
5. Output of the cc
5. Output of the cc -S Command
This example shows how a simple C program generates assembly language code. The program calls the printf() routine. To run the assembled code, you need to link the file /usr/ccs/lib/crt0.o and the C library file. Remember that the ld command requires that you link the crt0.o file first in
C Program Listing
main ()
{
printf ("Hello World\n");
}
Assembly Program Listing From the C Compiler
.LEVEL 1.0 |
|
|
|
.SPACE | $TEXT$,SORT=8 |
|
|
.SUBSPA | $CODE$,QUAD=0,ALIGN=4,ACCESS=44,CODE_ONLY,SORT=24 | ||
main |
|
|
|
.PROC |
|
|
|
.CALLINFO CALLER,FRAME=0,SAVE_RP |
| ||
.ENTRY |
|
|
|
STW | ;offset 0x0 |
| |
LDO | 48(%r30),%r30 | ;offset 0x4 |
|
ADDIL | ;offset 0x8 | ||
.CALL | ARGW0=GR | ;in=26; |
|
BL | printf,%r2 | ;offset 0xc |
|
LDO | |||
L$exit1 |
|
|
|
LDW | ;offset 0x14 |
| |
BV | %r0(%r2) | ;offset 0x18 |
|
.EXIT |
|
|
|
LDO | ;offset 0x1c |
| |
.PROCEND ; |
|
| |
.SPACE | $TEXT$ |
|
|
.SUBSPA | $LIT$,QUAD=0,ALIGN=8,ACCESS=44,SORT=16 | ||
.SUBSPA | $CODE$ |
|
|
.SPACE | $PRIVATE$,SORT=16 |
| |
.SUBSPA | $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=16 | ||
$THIS_DATA$ |
|
|
|
.ALIGN | 4 |
|
|
.STRINGZ “Hello World\n”
.SUBSPA $SHORTDATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=24
138 | Chapter 7 |