A couple bootloader questions
Posted: Sun Oct 07, 2012 5:59 am
I'm trying to make a simple bootloader that accesses a few bios interrupts, but I'm having a few problems. Here is my code:
For some reason moving the address of the "welcome" label to %si results in an incorrect address of 0xf821 instead of 0x7c21. I tried changing it in the binary with the dd command, and then it worked correctly. However this doesn't really make sense because the call instruction wasn't affected by the .org directive at all with an address of 0x1a (the correct unrelocated address) according to objdump , yet it still managed to find the "print_str" function. And where does the corresponding instruction "e8 0f 00" specify the address 0x1a?
Also, if I uncomment the commented stuff at the start of the file nothing is displayed at all, not even the "A" character at the start. Have I done something wrong there?
Cheers
Code: Select all
.globl _start
.code16
.org 0x7c00
.text
_start:
/*
* cli
*
*ljmp $0, $real_start
*real_start:
*
* xorw %ax, %ax
* movw %ax, %ds
* movw %ax, %ss
* movw $0x2000, %sp
* sti
*/
mov $0x0e41, %ax
int $0x10
mov $welcome, %si
call print_str
mov $0x0e5a, %ax
int $0x10
1:
jmp 1b
/* PRINT STRING */
1:
mov $0x0007, %bx
mov $0x0e, %ah
int $0x10
inc %si
print_str:
mov (%si), %al
cmp $0, %al
jne 1b
ret
welcome: .asciz "Welome, please enter a number\n"
. = _start + 510
.word 0xaa55
Also, if I uncomment the commented stuff at the start of the file nothing is displayed at all, not even the "A" character at the start. Have I done something wrong there?
Cheers