Merge pull request #10 from E-Almqvist/dev

Dev
pull/13/head
E. Almqvist 4 years ago committed by GitHub
commit 85f527c275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      src/bootloader.asm
  2. 5
      src/bootloader_bios_disk.asm
  3. 38
      src/elib/bios_disk.asm
  4. 2
      src/elib/convert.asm
  5. 10
      src/elib/io.asm

@ -1,19 +1,21 @@
[org 0x7c00] ; bootsector [org 0x7c00] ; bootsector
mov bx, welcomeString ; Print the welcome string mov bx, welcome_string ; Print the welcome string
call println call println
mov bx, infoString ; Print version info mov bx, info_string ; Print version info
call println call println
mov bx, hexTestPrefixString ; Hex print test (not needed but fun) ; Read from disk
call print mov bp, 0x8000
mov sp, bp ; move the stack away so that it does not get overwritten
pusha mov bx, 0x9000
mov dx, 0x002e ; test the conversion mov dh, 2 ; read 2 sectors
call hexToASCII call disk_read ; read
call println
popa mov dx, [0x9000]
call print_hex
jmp $ ; inf loop jmp $ ; inf loop
@ -22,12 +24,14 @@
%include "equ/ASCII.asm" %include "equ/ASCII.asm"
; SRs ; SRs
%include "elib/io.asm"
%include "elib/convert.asm" %include "elib/convert.asm"
%include "elib/io.asm"
%include "elib/bios_disk.asm"
welcomeString: db "Welcome to: e Operating-System (eOS)", ASCII_END welcome_string: db "e Operating-System (eOS)", ASCII_END
infoString: db "Version 2021 0.0", ASCII_END info_string: db "Version 2021 0.0", ASCII_END
hexTestPrefixString: db "Hex printing test: ", ASCII_END read_test_string: db "Disk read: ", ASCII_END
times 510-($-$$) db 0 times 510-($-$$) db 0
db 0x55, 0xaa ; magic BIOS numbers db 0x55, 0xaa ; magic BIOS numbers

@ -1,5 +0,0 @@
disk_read:
pusha
mov ah, BIOS_DISK_READ
mov al, dh ; number of sectors to read

@ -0,0 +1,38 @@
disk_read:
pusha
push dx
mov ah, BIOS_DISK_READ
mov al, dh ; sector count
mov cl, 0x02
mov ch, 0x00 ; read from first cylinder
mov dh, 0x00 ; head
; data pointer: es:bx (standard)
int BIOS_DISK_INT ; do the interrupt
jc read_error ; if flag is set then jump to error
pop dx
cmp al, dh
jne sector_error
popa
ret
sector_error:
mov bx, sector_error_string
call println
read_error:
mov bx, read_error_string
call println
mov dh, ah
call print_hex
disk_loop:
jmp $
read_error_string: db "Disk read error", ASCII_END
sector_error_string: db "Invalid number of sectors read", ASCII_END

@ -5,7 +5,7 @@ HEX_OUT: db "0x0000", ASCII_END
; since it fills the register with the desired ; since it fills the register with the desired
; pointer toward the string. ; pointer toward the string.
hexToASCII: hex_to_ascii:
mov cx, 0 ; incrementor mov cx, 0 ; incrementor
hexloop: hexloop:

@ -40,3 +40,13 @@ println:
popa popa
ret ret
; Subroutine to print a hex value
print_hex:
pusha
call hex_to_ascii
call print
popa
ret

Loading…
Cancel
Save