Code: Select all
ParseDirectoryEntry:
mov ecx, [es:bx+0x0A]
mov eax, [es:bx+0x02]
push ax
xor eax, eax
pop ax
xor ah, ah
cmp eax, 0
je ParseDirectoryEntry
cmp cl, 0
je .zero
ret
.zero:
mov cl, 1
ret
Code: Select all
ParseDirectoryEntry:
mov ecx, [es:bx+0x0A]
mov eax, [es:bx+0x02]
push ax
xor eax, eax
pop ax
xor ah, ah
cmp eax, 0
je ParseDirectoryEntry
cmp cl, 0
je .zero
ret
.zero:
mov cl, 1
ret
Code: Select all
;Parse A Directory Entry
;
;This routine checks some stuff in a thingy-whatsit that may or may not be related to some
;sort of (page directory, phone directory?) entry; and may return some sort of values and other
;stuff (but might not return too).
;Input
; es:bx The address of a thingy-whatsit
;
;Output
; eax Something that's guaranteed to be non-zero
; ecx "stuff" in the highest 24-bits, with maybe some sort of flag in the lowest byte?
;_______________________________________________________________________________________________
ParseDirectoryEntry:
mov ecx,[es:bx+0x0A] ;ecx = something
movzx eax,byte [es:bx+0x02] ;eax = something else
xor cl,cl ;ecx = assumed value to return, with "stuff" in highest 24-bits
test al,al ;Is something else zero?
je ParseDirectoryEntry ; yes, keep looping until an IRQ changes the thingy-whatsit
cmp [es:bx+0x0A],1 ;Is something less than one (or, is something zero)?
adc cl,0 ;Set CL=1 if something was zero, else leave CL=0 (and don't upset the "stuff"!)
ret
Code: Select all
;************************************************;
; Reads a series of sectors
; Cx=>Number of blocks to read
; EAX=>Starting sector - Anything above B6 causes an err???
; ES:BX=>Buffer to read to
; DL=>Drive #
; Carry set on err
;************************************************;
ReadSectors:
.MAIN:
mov [DriveNum], dl
mov di, 5
push ax
mov ah, 45h
mov al, 0x00 ; Lock drive to prevent tray opening
int 0x13
cmp ah, 0
pop ax
jne .End
.SECTORLOOP:
push eax
push ds
push es
push bx
push cx
push di
push dword 0 ;Block number
push dword eax
push word es ; Read to es:bx
push word bx
push word cx
push word 10h ; Size: 10h
mov ah, 0x42
push ss
pop ds
mov si, sp
mov dl, [DriveNum]
int 0x13
push ax
mov al, ah
mov ah, 0x0E
int 0x10
pop ax
add esp, 0x10
.CONTINUE:
pop di
pop cx
pop bx
pop es
pop ds
cmp ah, 0
pop eax
je .SUCCESS
.LOOP:
dec di
jnz .SECTORLOOP
.SUCCESS:
clc
push ax
mov ax, 0x4501 ; Unlock drive
mov dl, [DriveNum]
int 0x13
cmp ah, 0
pop ax
jne .SUCCESS
.End:
ret
From personal experience: short term gain = long term fail here. I know that some well placed comments saved me a lot of time later on. I've also seen a lot of cases where I didn't bother to document and I had again to figure out how some things worked.death2all wrote:Please excuse my lack of comments, I don't have much time to devote, and I try to get as much done as possible in what time I have.