Its was hard to determine where this post belonged, so I put it here...
I have been playing with two versions of a 'hello, world' program, in order to see the differences produced by declaring main as returning an int, and declaring main as not returning anything. When I declare main to return an int, and return 0, everything goes as expected, and when I check the exit status code it is indeed 0. But when I do a void main version of the program, I get an exit status of 13. So I have done a fair bit of searching, and the best I can come up with is that the 13 I get on my machine is something left over in the register eax. (When I ran the program in gdb, and checked eax, sure enough it was 13 stored there) Anyway, I am not strong with assembly, and so I am not sure of how eax ends up holding the value 13, and I was wondering if someone could shed some light on the matter for me. Here is the code I am using:
C version
And the assembly output from gccCode:test $ cat hello1.c #include <stdio.h> void main(void) { printf("hello, world\n"); }
I am not interested in using void main, but simply am trying to discover some of the inner workings of things.Code:test $ cat hello1.s .file "hello1.c" .section .rodata .LC0: .string "hello, world\n" .text .align 2 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp movl $0, %eax subl %eax, %esp subl $12, %esp pushl $.LC0 call printf addl $16, %esp leave ret



LinkBack URL
About LinkBacks



