-
Compiling Help! Yay!
So, I'm working on stuff (a small os). The current code is simple:
Code:
#include <stdio.h>
char usrin[256];
int main(int argc, char *argv[])
{
* * * *printf("> ");
* * * *puts(usrin);
* * * *printf("/n");
* * * *printf(usrin);
* * * *return 0;
}
, and to compile asm before I used c I use:
Code:
$ nasm myfile.asm -o myfile.bin -f bin
But when I try to use gcc and compile it normally "
Code:
$ gcc myfile.c -o myfile.bin
", it doesn't work at all when called on my bootdisk, and gives this funky output in nix:
Code:
$ sh usrin.bin
MZ?♥♦ÿÿ,@?♫▼º♫': not found
♫▼º♫': not found
usrin.bin: 1: Syntax error: word unexpected (expecting ")")
so then I tried to get gcc to stop before compiling, and instead just make asm code with
Code:
$ gcc myfile.c -o myfile.asm -S
. That makes this code:
Code:
* * * *.file * "usrin.c"
* * * *.def * *___main; * * * *.scl * *2; * * *.type * 32; * * .endef
* * * *.text
LC0:
* * * *.ascii "> \0"
LC1:
* * * *.ascii "/n\0"
.globl _main
* * * *.def * *_main; *.scl * *2; * * *.type * 32; * * .endef
_main:
* * * *pushl * %ebp
* * * *movl * *%esp, %ebp
* * * *subl * *$8, %esp
* * * *andl * *$-16, %esp
* * * *movl * *$0, %eax
* * * *movl * *%eax, -4(%ebp)
* * * *movl * *-4(%ebp), %eax
* * * *call * *__alloca
* * * *call * *___main
* * * *movl * *$LC0, (%esp)
* * * *call * *_printf
* * * *movl * *$_usrin, (%esp)
* * * *call * *_puts
* * * *movl * *$LC1, (%esp)
* * * *call * *_printf
* * * *movl * *$_usrin, (%esp)
* * * *call * *_printf
* * * *movl * *$0, %eax
* * * *leave
* * * *ret
* * * *.comm * _usrin, 256 * * *# 256
* * * *.def * *_puts; *.scl * *2; * * *.type * 32; * * .endef
* * * *.def * *_printf; * * * *.scl * *2; * * *.type * 32; * * .endef
Then I tried compiling it with nasm with
Code:
$ nasm myfile.asm -o myfile.bin -f bin
. It gave me a crapload of errors, which were:
Code:
$ nasm myfile.asm -o myfile.bin -f bin
usrin.asm:1: error: attempt to define a local label before any non-local labels
usrin.asm:1: error: parser: instruction expected
usrin.asm:2: error: attempt to define a local label before any non-local labels
usrin.asm:2: error: parser: instruction expected
usrin.asm:3: error: attempt to define a local label before any non-local labels
usrin.asm:5: error: parser: instruction expected
usrin.asm:7: error: parser: instruction expected
usrin.asm:8: error: parser: instruction expected
usrin.asm:9: error: parser: instruction expected
usrin.asm:11: error: parser: instruction expected
usrin.asm:12: error: parser: instruction expected
usrin.asm:13: error: parser: instruction expected
usrin.asm:14: error: parser: instruction expected
usrin.asm:15: error: symbol `movl' redefined
usrin.asm:15: error: parser: instruction expected
usrin.asm:16: error: symbol `movl' redefined
usrin.asm:16: error: parser: instruction expected
usrin.asm:17: error: symbol `movl' redefined
usrin.asm:17: error: parser: instruction expected
usrin.asm:20: error: symbol `movl' redefined
usrin.asm:20: error: parser: instruction expected
usrin.asm:22: error: symbol `movl' redefined
usrin.asm:22: error: parser: instruction expected
usrin.asm:24: error: symbol `movl' redefined
usrin.asm:24: error: parser: instruction expected
usrin.asm:26: error: symbol `movl' redefined
usrin.asm:26: error: parser: instruction expected
usrin.asm:28: error: symbol `movl' redefined
usrin.asm:28: error: parser: instruction expected
usrin.asm:31: error: parser: instruction expected
usrin.asm:32: error: parser: instruction expected
usrin.asm:33: error: symbol `.def' redefined
usrin.asm:33: error: parser: instruction expected
Now, I'd have to admit I'm not the greatest at x86 assembly (that's why I'm using c :P). And I'm not quite sure how to fix the errors, or otherwise get the damn thing compiled right.
If someone out there knows what is happening, please offer some insight!
-
-
wheres Kaniaz when you need him? ;p
-
I have no idea... I know some C++ and Java but what is THAT? :shock:
Get out of the stone age? :D
-
I haven't got a clue what all those errors are for (don't use the OS or compiler) but when making an OS it's usually not a very good idea to use calls that actually use another OS...
-
K. Let me look.
[Stalker: system calls ok. linux was made "parasiting" on unix then the last final leap, the kernel, brung it all together as a last os. omg yay]
-
(Double post, yay. But life goes on.)
Right. Where did usrin.bin come from? you compiled it as myfile.bin? Also, try renaming usrin array. Don't know why but I have a small thought tugging at the back of my brain. DO IT D:
-
myfile.bin is the same as usrin.bin :P. And to make you happy I renamed the array "usrinp".
-
You see...dodgy file names, crappy variable names...
IT CONFORMS TO ALL THE MICROSOFT STANDARDS NOW! WHY IS IT NOT WORKING?!
Edit: Oh yes. It's not supposed to, in Microsoft standard. Go sell it for $50.