I have fighting alot with my damn bootsector thing... i have successfully loaded the rootdir and located the file (well at least I don't get any error doing this) but it fail reading it later..
I do as it say I should read the fat12 in the FAQ (if I got my assembly code right was a while since I coded assembly)
this is a pice of my code
;---( Read file )---
;
; Input
; AX - The first cluster entry value
; BX - FileBuffer (where to store the file)
ReadFile:
cmp ax, 0x0fff ; end of file?
jge EOF ; well if it is jump to EOF
call LBAtoCHS ; convert AX to CHS values
mov al, 1 ; sectors to read
call ReadChunk ; read the sector that this value is ( LBAtoCHS already set CHS values needed in correct registers and BX is the FILE_BUFF and al is sectors to read)
add bx, 0x200 ; increase bx with 512 bytes becouse we just read in that into it
push ax ; push AX onto stack
pop dx ; retrive AX from stack but into DX
add dx, dx ; multiply with 2 ( or actually dx + dx -> dx=5 5+5 )
add dx, ax ; multiply with 3 ( or actuallu dx + dx + ax -> AX=5 5+5+5 )
rcr dx, 1 ; this would divide with 2 (or multiply with 1.5)
; and it will also put a bit in carry flag if
pushf ; save carry flag for a while
mov ax, FAT_BUFF
add ax, dx ; now this would be the next value from the fat
popf
jc integer
shr ax, 4 ; it wasn't a whole integer
jmp ReadFile
integer:
and ax, 0x0fff
jmp ReadFile
Eof:
ret
bochs says I try to read a sector that is far beoyond the limit of the floppy size
reading file from floppy/fat12
Re:reading file from floppy/fat12
Code: Select all
add dx, ax ; multiply with 3 ( or actuallu dx + dx + ax -> AX=5 5+5+5 )
rcr dx, 1 ; this would divide with 2 (or multiply with 1.5)
; and it will also put a bit in carry flag if
pushf ; save carry flag for a while
mov ax, FAT_BUFF
add ax, dx ; now this would be the next value from the fat
popf
jc integer
shr ax, 4 ; it wasn't a whole integer
jmp ReadFile
Good luck,
Mike
Re:reading file from floppy/fat12
so if I understand correct the lines between the pushf and popf would beMike wrote: ...
With "add ax, dx", you are moving into AX the address of the proper value within the FAT, not the value at that address. Before the "popf", insert a "mov ax, word [ax]" - that will get the value at address AX.
Good luck,
Mike
mov ax, FAT_BUFF ; get the base address
add ax, dx ; make the addres point at the new value
mov ax, word[ax] ; retrives the new value into ax
would that be the same as this:
add dx, FAT_BUFF
mov ax, word [dx]
;-- or --
mov ax, word [FAT_BUFF + dx]
Re:reading file from floppy/fat12
Go here and get bootprog, it as full nasm code, so you can compear it to yours.
http://alexfru.chat.ru/epm.html
\\\\||////
(@@)
ASHLEY4.
http://alexfru.chat.ru/epm.html
\\\\||////
(@@)
ASHLEY4.
Re:reading file from floppy/fat12
Yes. Both would work.so if I understand correct the lines between the pushf and popf would be
mov ax, FAT_BUFF ; get the base address
add ax, dx ; make the addres point at the new value
mov ax, word[ax] ; retrives the new value into ax
would that be the same as this:
add dx, FAT_BUFF
mov ax, word [dx]
;-- or --
mov ax, word [FAT_BUFF + dx]
Good luck,
Mike