The assembler is now generating the 16-bit code that I want and a test program ran successfully, but this program will not:
Code:
C source (called kernel.c):
__asm (".code16");
extern void print_a (char *);
int main ()
{
print_a ("Hello, world!");
test:
goto test;
}
followed by:
Code:
ASM source (called library.asm; assembled with NASM):
[BITS 16]
GLOBAL _print_a
SECTION .text
_print_a:
PUSH BP
MOV BP,SP
MOV SI,[BP+8]
MOV AH,0x0E
MOV BX,0x0007
.print_loop:
LODSB
OR AL,AL
JZ .done
INT 0x10
JMP .print_loop
.done:
POP BP
RET
My bootloader loads this code into memory at 0050:0000 and then executes a far return to said location. I am compiling under DJGPP using the following compiler/linker options:
Code:
gcc -ffreestanding -c kernel.c -o kernel.o
ld -Ttext 0x50 -e _main --oformat binary kernel.o library.o -o kernel.bin
Can anyone tell me why this code will not produce the line as i've written it? Whenever I change the code to print a character instead of a line, it works fine!!!