Anyway I was interested in having a go at producing the assembler code myself
I tried it on this short program I wrote earlier.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
main(argc,argv)
int argc;
char *argv[];
{
system("testbat");
}
compiled with
Code:
set DJGPP=C:\DJGPP\DJGPP.ENV
set PATH=C:\DJGPP\BIN;%PATH%
gcc -S testb.c
Which produces this:-
Which may answer some of your question (or not).
Code:
.file "testb.c"
.section .text
LC0:
.ascii "testbat\0"
.globl _main
_main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
subl %eax, %esp
subl $12, %esp
pushl $LC0
call _system
addl $16, %esp
leave
ret
.ident "GCC: (GNU) 4.0.1"
Not sure what all that is about lol,
Code:
pushl $LC0
call _system
Seems to be the passing of parameter to the 'system' call, I think the other stuff
is to do with the program arguements.
Anyone know what 'leave' does?