Page 1 of 1

reading/writing sectors for filesystem

Posted: Mon Jan 11, 2010 5:56 pm
by ChrisSkura
I have been working on my os and I want to implement a file system. I try to save to a sector and then later read from that sector and ouput the information to the screen. I think I am writing correctly but I can't tell if i am because I can't figure out how to read from it.

this is how i write:

Code: Select all

buffer TIMES 512 db 0
mov byte [buffer+0], 65

mov ah, 03h
mov al, 1
mov cl, 18
mov ch, 79
mov dh, 1
mov dl, 0
mov bx, [buffer]
int 13h
and i read like this

Code: Select all

read TIMES 512 db 0

mov ah, 02h
mov al, 1
mov cl, 18
mov ch, 79
mov dh, 1
mov dl, 0
mov bx, [read]
int 13h
I then output the value of [read+0] to the screen and it is not an 'A'. it isn't anything.

i don't know what I am doing wrong. none of the tutorials a have found show how to do what I want to do.

Re: reading/writing sectors for filesystem

Posted: Mon Jan 11, 2010 6:46 pm
by neon
Hello,

An easy way to test if writing is working (and reading, actually) is by comparing what you are reading/writing with whats on disk (use a disk editor or hex editor).

Re: reading/writing sectors for filesystem

Posted: Mon Jan 11, 2010 6:58 pm
by bewing
ChrisSkura wrote: this is how i write:

Code: Select all

buffer TIMES 512 db 0
...
mov bx, [buffer]
int 13h
ES:BX is supposed to be a pointer to the buffer. You are actually moving the first word of data from the buffer into BX. What you want it to say is MOV BX, buffer
(with no brackets). Please understand that the [] bracket operators in asm are the same as the * operator in C.

Re: reading/writing sectors for filesystem

Posted: Tue Jan 12, 2010 2:37 am
by qw
After calling INT 13H you should test the Carry Flag. If it is set, an error occurred, and you should reset the disk system and try again. Try at least four times.

Also, make sure that your buffer doesn't cross a DMA page boundary. It should be in a physical address range of X0000 - XFFFFH.

Re: reading/writing sectors for filesystem

Posted: Tue Jan 19, 2010 2:16 am
by paulqddinh
me too
i can't read/write using int 13h,
so my mbr is not able to load kernel :(
my mbr is on flashdisk
my kernel in on flashdisk also
any suggestion? [-o<