From e779668334c816ffe81c27a7ca02104421b96cfe Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Tue, 23 Feb 2021 11:56:09 +0100 Subject: [PATCH] Added print_hex SR & refactor --- src/bootloader.asm | 22 +++++++++++++--------- src/elib/bios_disk.asm | 5 +---- src/elib/io.asm | 10 ++++++++++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/bootloader.asm b/src/bootloader.asm index b20de8a..eadcf6d 100644 --- a/src/bootloader.asm +++ b/src/bootloader.asm @@ -6,14 +6,16 @@ mov bx, info_string ; Print version info call println - mov bx, hex_test_string ; Hex print test (not needed but fun) - call print + ; Read from disk + mov bp, 0x8000 + mov sp, bp ; move the stack away so that it does not get overwritten - pusha - mov dx, 0x002e ; test the conversion - call hex_to_ascii - call println - popa + mov bx, 0x9000 + mov dh, 2 ; read 2 sectors + call disk_read ; read + + mov dx, [0x9000] + call print_hex jmp $ ; inf loop @@ -22,12 +24,14 @@ %include "equ/ASCII.asm" ; SRs -%include "elib/io.asm" %include "elib/convert.asm" +%include "elib/io.asm" + +%include "elib/bios_disk.asm" welcome_string: db "e Operating-System (eOS)", ASCII_END info_string: db "Version 2021 0.0", ASCII_END -hex_test_string: db "Hex printing test: ", ASCII_END +read_test_string: db "Disk read: ", ASCII_END times 510-($-$$) db 0 db 0x55, 0xaa ; magic BIOS numbers diff --git a/src/elib/bios_disk.asm b/src/elib/bios_disk.asm index 601f22d..9a563a8 100644 --- a/src/elib/bios_disk.asm +++ b/src/elib/bios_disk.asm @@ -28,11 +28,8 @@ read_error: mov bx, read_error_string call println - pusha mov dh, ah - call hex_to_ascii - call println - popa + call print_hex disk_loop: jmp $ diff --git a/src/elib/io.asm b/src/elib/io.asm index 34c62e2..4624849 100644 --- a/src/elib/io.asm +++ b/src/elib/io.asm @@ -40,3 +40,13 @@ println: popa ret + + +; Subroutine to print a hex value +print_hex: + pusha + call hex_to_ascii + call print + popa + + ret