From d8ab00c7cde91bb54fdec62bb265bde56be849f4 Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Sat, 3 Aug 2024 04:30:31 +0300 Subject: [PATCH] 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 --- src/mbr_test.s | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/mbr_test.s b/src/mbr_test.s index a505820..4b1c00e 100644 --- a/src/mbr_test.s +++ b/src/mbr_test.s @@ -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