fixed stupid bug - mov msg, %si actually translated to move r/m16 to %si instead of immediate move like mov $msg, %si. also implemented bootloader migration to 0050:0000 address just to be stable

This commit is contained in:
mykola2312 2024-08-03 04:30:31 +03:00
parent 9643f450ac
commit d8ab00c7cd

View file

@ -1,13 +1,31 @@
.section .text
.code16
mov $BOOTLOADER_SIZE, %ax
# we're moving to 0050, 0x7C00 -> 0x0500
# so, DS is 0x07C0 and ES is 0x0050
mov $0x07C0, %ax
mov %ax, %ds
mov $0x0050, %ax
mov %ax, %es
mov msg, %si
# set both source and destination pointers to zero, since we using segments
xor %ax, %ax
mov %ax, %si
mov %ax, %di
# set counter with determined size by linker
mov $BOOTLOADER_SIZE, %cx
cld
.copy:
lodsb
stosb
loop .copy
# far jump to new memory region
jmp $0x0050,$.bootloader
.bootloader:
mov $msg, %si
.putc_loop:
lodsb
or %al, %al