Problem mixing C/ASM code
Posted: Tue Mar 09, 2004 12:00 am
Hello:
I am having problem trying to mix C and ASM code when I want to use global variables.
For example,
C code:
#include "myclib.h"
int NUM;
main() {
NUM=10;
printd(NUM); }
The printd() function is an NASM code (part of my OS).
I belive I have an error when I compile the program with this script:
nasm -f aout cheader.asm -o a.o
gcc -c -ffreestanding shell.c -o b.o
nasm -f aout clib.asm -o c.o
nasm -f aout cstack.asm -o d.o
ld -e start -Ttext 0x0000 --oformat binary -o shell.bin a.o b.o c.o d.o
cheader.asm just have a jump to _main,
shell.c is the program I want to compile,
clib.asm have all the syscalls to my kernel OS,
and cstack.asm just have space for the stack.
Any idea?
Thank you very much,
pepito
I am having problem trying to mix C and ASM code when I want to use global variables.
For example,
C code:
#include "myclib.h"
int NUM;
main() {
NUM=10;
printd(NUM); }
The printd() function is an NASM code (part of my OS).
I belive I have an error when I compile the program with this script:
nasm -f aout cheader.asm -o a.o
gcc -c -ffreestanding shell.c -o b.o
nasm -f aout clib.asm -o c.o
nasm -f aout cstack.asm -o d.o
ld -e start -Ttext 0x0000 --oformat binary -o shell.bin a.o b.o c.o d.o
cheader.asm just have a jump to _main,
shell.c is the program I want to compile,
clib.asm have all the syscalls to my kernel OS,
and cstack.asm just have space for the stack.
Any idea?
Thank you very much,
pepito