flat assembler
Message board for the users of flat assembler.

Index > OS Construction > int 13

Author
Thread Post new topic Reply to topic
abuashraf



Joined: 11 Nov 2006
Posts: 88
abuashraf
Hi...
I'm having problem reading the first sector of the root directory of fat12
floppy,when I convert the LBA to CHS my code doesn't print any thing,
but when I write track=0,head=1,sector=2 by my hands it works perfectly,
Also my LBACHS fuction works fine becuase I printed the values it gave me and they were as I expect, any way here's my code I hope some one
can help me.

Code:
use16                            ; 16bit addressing
org 0x100                        ; Com file stuff

start:
push cs                          ; Push CS on stack
pop ds                           ; Move CS into DS
push ds                          ; Push DS
pop es                           ; Move DS into ES
mov [count],3
mov bx,0x0200

TryAgain:
mov ah,02h
;mov  ax,19
;call lbachs
mov al,1 ;number of sectors to read
mov ch,0 ;[track] ;track
mov cl,2 ;[sector] ;sector
mov dh,1 ;[head];head
mov dl,1h;B
int 13h
jnc PrintBuffer                   
dec [count]
cmp [count],0
jne TryAgain

FddError:
mov si,fdd_err                   ; Point SI to string
call print                       ; call our print function
ret                              ; Note: if run from dos change this for RET

PrintBuffer:
mov si,out_buffer                ; Point SI to string
call printF                      ; call our print function
ret                              ; Note: if run from dos change this for RET

;====================================================;
;  print.                                            ;
;====================================================;
print:
mov ah,0Eh                       ; Request display
again1:
lodsb                            ; load a byte into AL from DS:SI
or al,al                         ; Or AL
jz done1                         ; Jump 0, to label done1
int 10h                          ; Call interrupt service
jmp again1                       ; Jump to label again1
done1:
ret                              ; Return  

;====================================================;
;  printF.                                           ;
;====================================================;
printF:
mov cx,512
mov ah,0Eh                       ; Request display
again2:
lodsb                            ; load a byte into AL from DS:SI
int 10h                          ; Call interrupt service
loop again2                      ; Jump to label again1
ret                              ; Return

;----------------;
;takes ax=lba ;
;----------------;
;=========;        
 lbachs:          ;
;=========;
  xor     dx,dx
       div     WORD [bpbSectorsPerTrack]
   inc     dl
  mov     BYTE [sector], dl
   xor     dx, dx 
     div     WORD [bpbHeadsPerCylinder]
  mov     BYTE [head], dl
     mov     BYTE [track], al
    ret 

count db 0  
fdd_err db 'Error ,0            

track              db      0000
head            db      0000
sector          db      0000
bpbSectorsPerTrack:         DW 18
bpbHeadsPerCylinder:       DW 2    


Thanx.
Post 09 Mar 2008, 14:00
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
Post 09 Mar 2008, 14:03
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17247
Location: In your JS exploiting you and your system
revolution
Try moving the ah,02 down. Like this:
Code:
...
TryAgain:
;mov  ax,19
;call lbachs
mov ah,02h     ;<--- move it to here after you call lbachs
mov al,1 ;number of sectors to read
...    
Post 09 Mar 2008, 14:05
View user's profile Send private message Visit poster's website Reply with quote
abuashraf



Joined: 11 Nov 2006
Posts: 88
abuashraf
Thank you revolution,
it's working now. Smile
Post 10 Mar 2008, 16:59
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-2020, Tomasz Grysztar.

Powered by rwasa.