- MinGW GCC + AS broken?
- 10 Jul 2012 10:11:15 am
- Last edited by LincolnB on 10 Jul 2012 10:35:33 am; edited 2 times in total
I'm on Windows 7, and I installed MinGW just the other day. Unless I'm mistaken, the following syntax would be the same:
Code:
Code:
given hello.c:
Code:
Don't get my wrong, I'm not ruling out the idea of my being mistaken that those two CMD commands are equivalent. Anyways, the first one just compiles the C code using GCC, and the second one eats C, poops ASM, and then tries to assemble the ASM. However, the second one doesn't work - it runs but doesn't display "Hi" like the C one does.
EDIT:
OK, I run that second command again, and trying to run the executable, a pop-up comes up and says,
Code:
And here's my hello.s file:
Code:
Code:
C:\>gcc hello.c -o hello.exe
C:\>hello.exe
Code:
C:\>gcc -S hello.c
C:\>as hello.s -o hello.exe
C:\>hello.exe
given hello.c:
Code:
#include <stdio.h>
main() {
printf("Hello");
}
Don't get my wrong, I'm not ruling out the idea of my being mistaken that those two CMD commands are equivalent. Anyways, the first one just compiles the C code using GCC, and the second one eats C, poops ASM, and then tries to assemble the ASM. However, the second one doesn't work - it runs but doesn't display "Hi" like the C one does.
EDIT:
OK, I run that second command again, and trying to run the executable, a pop-up comes up and says,
Code:
C:\Windows\system32\cmd.exe - hello.exe
the NTVDM CPU has encountered an illegal instruction
CS:0e25 IP:001d OP:ff ff ff ff ff Choose 'Close' to terminate the application.
And here's my hello.s file:
Code:
.file "hello.c"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "Hi\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
LFB6:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $16, %esp
call ___main
movl $LC0, (%esp)
call _printf
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
LFE6:
.def _printf; .scl 2; .type 32; .endef