6 mov [DriveNumber
], dl ; BIOS passes drive number in DL
17 ; Copy MBR sector to 0x0600 and jump there
44 mov si, msg_NoPartition
49 ;------------------------------------------------------------------------------
50 ; Read a sector from a disk, using LBA
51 ; input: EAX - 32-bit DOS sector number
52 ; ES:BX - destination buffer
53 ; output: ES:BX points one byte after the last byte read
61 push eax ; Save the sector number
62 mov di, sp ; remember parameter block end
64 push byte 0 ; other half of the 32 bits at [C]
65 push byte 0 ; [C] sector number high 32bit
66 push eax ; [8] sector number low 32bit
67 push es ; [6] buffer segment
68 push bx ; [4] buffer offset
69 push byte 1 ; [2] 1 sector (word)
70 push byte 16 ; [0] size of parameter block (word)
74 mov ah, 42h ; EXTENDED READ
75 int 0x13 ; http://hdebruijn.soo.dto.tudelft.nl/newpage/interupt/out-0700.htm#0651
77 mov sp, di ; remove parameter block from stack
78 pop eax ; Restore the sector number
80 jnc read_ok
; jump if no error
83 xor ah, ah ; else, reset and retry
90 add bx, 512 ; Add bytes per sector
91 jnc no_incr_es
; if overflow...
95 add dh, 0x10 ; ...add 1000h to ES
103 ;------------------------------------------------------------------------------
106 ;------------------------------------------------------------------------------
107 ; 16-bit Function to print a sting to the screen
108 ; input: SI - Address of start of string
109 print_string_16: ; Output string in SI to screen
111 mov ah, 0x0E ; int 0x10 teletype function
113 lodsb ; Get char from string
115 je .done
; If char is zero, end of string
116 int 0x10 ; Otherwise, print it
121 ;------------------------------------------------------------------------------
123 msg_Load
db "Loading... ", 0
124 msg_NoPartition
db "No active partition found"
129 tables
db "XXXXXXXXXXXXXXXX DO NOT OVERWRITE THIS AREA!!! XXXXXXXXXXXXXXXX" ; 64 bytes in length