I'm new to GCC development, so I'm having a problem with a simple C program using an i686 cross compiler to output a flat binary file. Here's the C program,
void printChar(void);
void main() {
printChar();
L1:
goto L1;
}
void printChar(void)
{
__asm__ (
"movb $62, %al\n\t" // '>'
"mov $0x0e, %ah \n\t" // video function 0Eh (print char)
"mov $0x0007, %ebx \n\t" // color
"int $0x10\n\t"
);
}
here's the script file commands,
i686-elf-gcc -c test.c -o test.o -ffreestanding -Wall -Wextra
i686-elf-ld test.o -o test.bin --oformat binary --entry main
here's the debug listing,
0100 55 PUSH BP
0101 89E5 MOV BP,SP
0103 83E4F0 AND SP,-10
0106 E80200 CALL 010B
0109 0000 ADD [BX+SI],AL
010B EBFE JMP 010B
010D 55 PUSH BP
010E 89E5 MOV BP,SP
0110 B03E MOV AL,3E
0112 B40E MOV AH,0E
0114 BB0700 MOV BX,0007
0117 0000 ADD [BX+SI],AL
0119 CD10 INT 10
011B 5D POP BP
011C C3 RET
011D 0000 ADD [BX+SI],AL
011F 0014 ADD [SI],DL
The call statement at 106 is calling an address 2 bytes short (10B) of the address it should be calling (10D). There's probably some simple alignment directive I should be using somewhere, but I can't find it. Any help is appreciated. Thanks..