NASM & DJGPP
Posted: Wed Dec 11, 2002 12:00 am
I like write my own OS.
----------------------
I am using the loader:
boot12.asm FAT12 bootstrap for real mode image or loader
Version 1.0, Jul 5, 1999
by John S. Fine [email protected]
I test it with a little ASM code and runs very good.
------------------------------------------------------------------------
As first step I like to print a character on the screen using the method exposed in the guide "Mixing Assembly and C". I wrote this two programs:
----------
NASM part:
[BITS 32]
[GLOBAL _abc]
[SECTION .text]
_abc:
push ebp
mov ebp, esp
mov al,[ebp + 8] ; Get the parameter
mov ah, 0x0e
mov bl, 7
int 0x10
mov esp, ebp
pop ebp
ret
-----------
DJGPP part:
extern void abc(char c);
int main (void) {
abc('A');
abc('B');
abc('C');
repeat:
goto repeat; }
---------------------------------------------------------
Then I create two objects and link it with the statements:
nasm -f coff -o nasmpart.o nasmpart.asm
gcc -ffreestanding -c -o cpart.o cpart.c
ld -Ttext 0x100000 --oformat binary -o kernel.bin
All works as the guide say!
--------
Problem:
When I load my kernel it not print the characters "ABC" but it print 3 spaces. I belive the problem is in the parameters because if a pass a canstant (like 'A') it works right.
I tried too creating an EXE file with the statements:
nasm -f coff -o nasmpart.o nasmpart.asm
gcc -ffreestanding -c -o cpart.o cpart.c
gcc -o kernel.exe bios.o system.o
And it works right!
Somebody can help me?
Thank you.
----------------------
I am using the loader:
boot12.asm FAT12 bootstrap for real mode image or loader
Version 1.0, Jul 5, 1999
by John S. Fine [email protected]
I test it with a little ASM code and runs very good.
------------------------------------------------------------------------
As first step I like to print a character on the screen using the method exposed in the guide "Mixing Assembly and C". I wrote this two programs:
----------
NASM part:
[BITS 32]
[GLOBAL _abc]
[SECTION .text]
_abc:
push ebp
mov ebp, esp
mov al,[ebp + 8] ; Get the parameter
mov ah, 0x0e
mov bl, 7
int 0x10
mov esp, ebp
pop ebp
ret
-----------
DJGPP part:
extern void abc(char c);
int main (void) {
abc('A');
abc('B');
abc('C');
repeat:
goto repeat; }
---------------------------------------------------------
Then I create two objects and link it with the statements:
nasm -f coff -o nasmpart.o nasmpart.asm
gcc -ffreestanding -c -o cpart.o cpart.c
ld -Ttext 0x100000 --oformat binary -o kernel.bin
All works as the guide say!
--------
Problem:
When I load my kernel it not print the characters "ABC" but it print 3 spaces. I belive the problem is in the parameters because if a pass a canstant (like 'A') it works right.
I tried too creating an EXE file with the statements:
nasm -f coff -o nasmpart.o nasmpart.asm
gcc -ffreestanding -c -o cpart.o cpart.c
gcc -o kernel.exe bios.o system.o
And it works right!
Somebody can help me?
Thank you.