1
0
Fork 0
mirror of https://github.com/tailix/loadwarka.git synced 2024-11-18 13:54:56 -05:00

Save and restore disk number

This commit is contained in:
Alex Kotov 2022-01-28 00:24:15 +05:00
parent 1cef081aed
commit a49f858112
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 13 additions and 5 deletions

View file

@ -5,6 +5,11 @@
#define STACK_BASE 0x2000 #define STACK_BASE 0x2000
.code16 .code16
.global disk_number
.global restore_disk_number
.section .data
disk_number: .byte 0
.section .header .section .header
ljmp $0, $init ljmp $0, $init
@ -21,4 +26,11 @@ init:
mov %ax, %fs mov %ax, %fs
mov %ax, %gs mov %ax, %gs
mov $STACK_BASE, %sp mov $STACK_BASE, %sp
mov %dl, disk_number
ljmp $0, $_start ljmp $0, $_start
.section .text
restore_disk_number:
mov $disk_number, %bx
mov (%bx), %dl
ret

View file

@ -18,13 +18,8 @@ parenth: .string " ("
of: .string " of " of: .string " of "
to_address: .string ") to address " to_address: .string ") to address "
.section .data
disk: .byte 0
.section .text .section .text
_start: _start:
mov %dl, disk
mov $hello, %si mov $hello, %si
call print_str call print_str
@ -107,6 +102,7 @@ read_loop:
jmp read_loop jmp read_loop
finish: finish:
call restore_disk_number
ljmp $0, $STAGE2_BASE ljmp $0, $STAGE2_BASE
ljmp $0, $hang ljmp $0, $hang