I am writing bootstrap using assembly (in AT & T and gnu / gas syntax). A small program is assembled and linked, and then copied to the first sector of the virtual disk. The BIOS will load it in 0000:7c00, and there is a problem. When you start it call hellowill be transferred from call 0010to call 7c10. But movw $message, %asdoes not move. axstill 0026, not 7c26. As a result, I can not do Hello Worldon the screen. Instead, some random data will be displayed on the screen 0000:0026.
How can I do it right at boot time? Should I change the asm source code with some directives? Or do I need to change the script link?
Thank!
.text
.global _start
.code16
_start:
movw %cs, %ax
movw %ax, %ds
movw %ax, %es
call hello
jmp .
.org 0x10
hello:
movw $message, %ax
movw %ax, %bp
movw $13, %cx
movw $0x1301, %ax
movw $0x000c, %bx
movb $0, %dl
int $0x10
ret
message:
.ascii "Hello, World!"
.org 0x01fe
.byte 0x55
.byte 0xaa
I use the following build and link scripts
as -o boot.o boot.s
ld -Ttext 0x0 -e _start -s -o boot.out boot.o
objcopy -O binary -j .text boot.out boot
vboxmanage convertfromraw boot boot.vdi --format VDI