diff --git a/src/x86/header.S b/src/x86/header.S index a19d685..1171554 100644 --- a/src/x86/header.S +++ b/src/x86/header.S @@ -5,6 +5,11 @@ #define STACK_BASE 0x2000 .code16 +.global disk_number +.global restore_disk_number + +.section .data +disk_number: .byte 0 .section .header ljmp $0, $init @@ -21,4 +26,11 @@ init: mov %ax, %fs mov %ax, %gs mov $STACK_BASE, %sp + mov %dl, disk_number ljmp $0, $_start + +.section .text +restore_disk_number: + mov $disk_number, %bx + mov (%bx), %dl + ret diff --git a/src/x86/stage1.S b/src/x86/stage1.S index fdc7142..7bd3bdd 100644 --- a/src/x86/stage1.S +++ b/src/x86/stage1.S @@ -18,13 +18,8 @@ parenth: .string " (" of: .string " of " to_address: .string ") to address " -.section .data -disk: .byte 0 - .section .text _start: - mov %dl, disk - mov $hello, %si call print_str @@ -107,6 +102,7 @@ read_loop: jmp read_loop finish: + call restore_disk_number ljmp $0, $STAGE2_BASE ljmp $0, $hang