flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Stucked using PIO :-(

Author
Thread Post new topic Reply to topic
flash



Joined: 11 Mar 2006
Posts: 55
Location: Cuba
flash 30 Mar 2012, 10:21
Have a nice day!
I am stucked using old PIO code (posted some time ago by Dex). The problem is that it does't work.
I am reviewing docs from osdev and from this forum and all seems to be ok. But theres is nothing at 7e00h(7c00h+512).
I am using qemu and this code to funge as hdd0: qemu -hda code.img
There is something more to do in order to configure PIO access?

Best wishes...

Code:
format binary as 'img'
use16
org 7c00h
                cli
                mov     ax,0b800h
                mov     es,ax
                mov     ax,cs
                mov     ds,ax

                mov     dx,1f7h
            @@: in      al,dx
                and     al,0c0h                 ; Check disk to have no errors
                or      al,40h                  ; and ready
                jz      @b
                
                mov     al,0a0h                 ; Select master 0 head 0
                mov     dx,1f6h
                out     dx,al

                mov     al,1                    ; Read just one sector
                mov     dx,1f2h
                out     dx,al

                mov     al,2                    ; Starting at second
                mov     dx,1f3h
                out     dx,al

                mov     al,0                    ; Locate the head...
                mov     dx,1f4h
                out     dx,al

                mov     al,0                    ; ...at cylinder zero
                mov     dx,1f5h
                out     dx,al

                mov     al,20h                  ; Send read command
                mov     dx,1f7h
                out     dx,al

            @@: in      al,dx
                test    al,8                    ; Wait drive to gather data
                jz      @b

                cld
                mov     di,7c00h+512            ; Use adjacent boot load zone as buffer
                mov     cx,512/2
                mov     dx,1f0h
                rep     insw

                xor     di,di
                mov     ah,74h          
                mov     si,7c00h+512
            @@: mov     al,[si]
                or      al,al
                jz      @f
                mov     [es:di],ax              ; Show data on screen
                add     di,2
                inc     si
                jmp     @b

            @@: jmp     $


times 510-($-$$) db 0
                 dw 0aa55h
db 'This is the data to be loaded from RAM code. There is something hidden: ',0x53,0x45,0x43,0x52,0x45,0x54
times 2*1000000-($-$$) db 0
    

_________________
i don't hate goto
Post 30 Mar 2012, 10:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20340
Location: In your JS exploiting you and your system
revolution 30 Mar 2012, 10:25
flash wrote:
Code:
              mov     ax,cs
               mov     ds,ax    
Be careful with your assumptions about the contents of segment registers. To ensure that your DS register is truely zero then set it to zero.
Code:
xor ax,ax
mov ds,ax    
Edit: remember to set up your stack (SS & SP) also.
Post 30 Mar 2012, 10:25
View user's profile Send private message Visit poster's website Reply with quote
flash



Joined: 11 Mar 2006
Posts: 55
Location: Cuba
flash 30 Mar 2012, 10:36
qemu console shows good values after "info registers" command. Still, does not work... even putting manual values at those registers.
As far as i know there is no need to specify any special disk format in .img file which makes more strange this behavior.
Post 30 Mar 2012, 10:36
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20340
Location: In your JS exploiting you and your system
revolution 30 Mar 2012, 11:00
Are you aware that INSW uses es:di?
Post 30 Mar 2012, 11:00
View user's profile Send private message Visit poster's website Reply with quote
flash



Joined: 11 Mar 2006
Posts: 55
Location: Cuba
flash 30 Mar 2012, 11:26
Hi revolution,
thank's again!!. You show me that my problems refers basically to wrong assumptions. In this case i read outs documentation from Intel and i made in my head an identical syntax for ins
Thank's a lot!
Post 30 Mar 2012, 11:26
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.