@@ -59,11 +59,13 @@ entry:
5959
6060
6161;;==============================================================================
62- ;; errors
62+ ;; failure | abort boot with error notification
63+ ;;==============================================================================
64+ ;; Argument:
65+ ;; -- si: string.
6366;;==============================================================================
6467
65- notify_ext_not_supported:
66- mov si , msg_no
68+ failure:
6769 call print
6870
6971.halt:
@@ -105,12 +107,12 @@ diskcpy:
105107;;==============================================================================
106108
107109cpySec:
110+ push ax ;; Reg is overriden by bios in 0x42 service return.
108111 push dx
109112 push si
110113 push di
111114
112115.cpy:
113- push ebx ;; Backup sectorNumber.
114116 mov di , sp ;; Base of disk address packet.
115117
116118 ;; Build disk address packet.
@@ -123,34 +125,33 @@ cpySec:
123125
124126 mov si , sp
125127 mov dl , [ drvNum ]
126- mov ah , 42h ;; Extended read.
128+ mov ah , 0x42 ;; Extended read.
127129 int 0x13
128130
129- mov sp , di ;; Clean stack.
130- pop ebx
131-
132- jnc read_ok ; jump if no error
131+ mov sp , di ;; Clean stack.
133132
134- push ax
135- xor ah , ah ; else, reset and retry
136- int 0x13
137- pop ax
138- jmp .cpy
133+ ;;jnc .success ;; Check for errors.
139134
140- read_ok:
141- add ebx , 1 ; increment next sector with carry
142- add cx , 512 ; Add bytes per sector
143- jnc no_incr_es ; if overflow...
135+ .failure:
136+ mov si , msg_err ;; TO-DO: retry before failure. Can also report error co
137+ ;; de in ah.
138+ jmp failure
139+
140+ .success:
141+ add ebx , 1 ;; increment next sector with carry
142+ add cx , 512 ;; Add bytes per sector
143+ jnc no_incr_es ;; if overflow...
144144
145145incr_es:
146146 mov dx , es
147- add dh , 0x10 ; ...add 1000h to ES
147+ add dh , 0x10 ; ; ...add 1000h to ES
148148 mov es , dx
149149
150150no_incr_es:
151151 pop di
152152 pop si
153153 pop dx
154+ pop ax
154155
155156 ret
156157
@@ -170,13 +171,19 @@ extensionTest:
170171 mov bx , 55aah ;; Required signature.
171172 mov dl , [ drvNum ]
172173 int 0x13
173- jc notify_ext_not_supported
174+ jc .unsupported
174175 cmp bx , 0xaa55
175- jne notify_ext_not_supported
176+ jne .unsupported
176177
177178 mov si , msg_ok
178179 call print
180+ jmp .fin
181+
182+ .unsupported:
183+ mov si , msg_no
184+ jmp failure
179185
186+ .fin:
180187 ret
181188
182189
@@ -210,8 +217,9 @@ print:
210217msg_extSupport: db "Verifying bios ext support.." , 0
211218msg_no: db " no" , 13 , 10 , 0
212219msg_load: db "Reading disk.." , 0
213- msg_ok: db " ok" , 13 , 10 , 0
214- msg_halt: db "Sys halted" , 0
220+ msg_err: db " [error]" , 13 , 10 , 0
221+ msg_ok: db " [ok]" , 13 , 10 , 0
222+ msg_halt: db "System halted" , 0
215223
216224drvNum: db 0x00
217225
0 commit comments