flat assembler
Message board for the users of flat assembler.

flat assembler > OS Construction > LBA Write Sector Problem

Author
Thread Post new topic Reply to topic
Navic



Joined: 05 Mar 2007
Posts: 16
Location: USA
This code generates a general protection fault at the rep outsw command. My read sector code is identical except obviously the use of EDI instead of ESI and command 20h instead of 30h. The read sector function works just fine, does anyone have a clue as to why this would GPF?
Thanks in advance!


Code:
hd_write_sector:
        cli
        push esi
        mov dx,1F2h
        mov al,1
        out dx,al
        lea esi,[lba]
        lodsw
        ;AL=0-7 (1F3h)  AH=8-15 (1F4h)
        inc dx
        out dx,al
        inc dx
        xchg al,ah
        out dx,al
        lodsw
        ;AL=16-23 (1F5h)  AH=24-27 (1F6h)
        inc dx
        out dx,al
        xchg al,ah
        ;LBA on, Drive 0
        mov ah,0E0h
        add al,ah
        inc dx
        out dx,al
        ;Write with Retry
        inc dx
        mov al,30h
        out dx,al
waitwrite:
        in al,dx
        test al,8
        jz waitwrite
        pop esi
        mov dx,1F0h
        mov ecx,100h
        rep outsw
        sti
        ret
    
[/code]
Post 15 Mar 2007, 16:52
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Should you not have some thing like
Code:
  mov     dx,1f6h         ;Drive and head port     mov     al,0a0h         ;Drive 0, head 0     out     dx,al     

or
Code:
        mov edx,[hdbase1]        inc   edx        mov   al,0        out   dx,al    

At start of function, also try adding a  cld before rep outsw
Post 15 Mar 2007, 18:03
View user's profile Send private message Reply with quote
Navic



Joined: 05 Mar 2007
Posts: 16
Location: USA
Right before the 30h command, I set the 1F6h register with this
Code:
;LBA on, Drive 0
mov ah,0E0h
add al,ah
inc dx
out dx,al
    

0E0h instead of 0A0h because LBA bit 6 must be set to 1 to turn on LBA, 0A0h is for CHS. cld before rep outsw makes no change.
Post 18 Mar 2007, 21:53
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.