problem with int 13h function

  • Follow


I am having problems with a function of int 13h
The following is an extract from ralf browns PC interrupt listing
on the function I am having problems with:

--------B-1302----------------------------------------------
INT 13 - DISK - READ SECTOR(S) INTO MEMORY
AH = 02h
AL = number of sectors to read (must be nonzero)
CH = low eight bits of cylinder number
CL = sector number 1-63 (bits 0-5)
high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer
Return: CF set on error
-----------------------------------------------------------------
This is my code in asm:

mov    ax,0201h    ;read, 1 sector
mov    cx,0001h    ;cyl 0 sector 1
mov    dx,0080h    ;head 0, drive 0x80
mov    bx,offset databuf
int       13h

databuf db 300 dup(0h)


The code above works fine for floppies (with dl set to 0), however when I
use this to read sectors
from my "C" drive (drive 0x80 is for the first HD - bit 7 set), the data
that
is placed in my buffer is nonsense. If i read sector 1, head 0, track 0 of a
floppy,
I will have its boot sector data in my buffer. However if i try head 0,
track 0, sector 1
of drive 0x80, its not there. When I step through my code with the debugger,
the HD
light flashes as soon as I step over the int 13h instruction. that kind of
suggests to me
it did read something off the HD.. what it read? I dont know.

Anyone have a similar problem with this? is there a different function I
should be using
to read sectors off HD?

if i issue "l 100 2 0 1" in debug, then type d 100 to view a dump, the boot
sector data
can be seen. Am I missing something here? For this int 13h function, the
first sector starts
at 1, and not 0... (I am guessing that debugs sectors start at 0)

I cant see what I have done wrong.. Or does this function not work on hard
disks?
I tried using the biosdisk() function in C, and tried the same thing in pure
asm and got
the same problem.

Alex.




0
Reply alex 9/29/2003 12:13:29 PM

alex <no@spam.pls.kthx.com> schreef in berichtnieuws
bl97gd$dph$1@lust.ihug.co.nz...

Hello Alex,

> I am having problems with a function of int 13h

[Snip]

> This is my code in asm:
>
> mov    ax,0201h    ;read, 1 sector
> mov    cx,0001h    ;cyl 0 sector 1
> mov    dx,0080h    ;head 0, drive 0x80
> mov    bx,offset databuf
> int       13h
>
> databuf db 300 dup(0h)

Ehhmm ...  A sector normally is 512 bytes.  You just reserve 300. That could
cause problems ...

And are you aware you did not load ES ?

> The code above works fine for floppies (with dl set to 0),
> however when I use this to read sectors from my "C" drive
> (drive 0x80 is for the first HD - bit 7 set), the data
> that is placed in my buffer is nonsense.

Make that : Nothing you recognise :-)

> If i read sector 1, head 0, track 0 of a floppy, I will have
> its boot sector data in my buffer. However if i try head 0,
> track 0, sector 1 of drive 0x80, its not there. When I step
> through my code with the debugger, the HD light flashes
> as soon as I step over the int 13h instruction. that kind of
> suggests to me it did read something off the HD.. what it
> read? I dont know.

It read the *Master*-boot-record (MBR for short).  In it is, next to a small
bootstrap-routine, stored where & how large the primary & extended
partitions are.

> Anyone have a similar problem with this? is there a different
> function I should be using to read sectors off HD?

The call is o.k., but you're currently just not aware that a floppy and a
hard-disk are somewhat differently set-up :-)

> if i issue "l 100 2 0 1" in debug, then type d 100 to view a
> dump, the boot sector data can be seen. Am I missing
> something here?

Yes, you're missing something here.  The difference is that Debug works on
*logical* drives, and INT 13h works on *physical* drives (a physical drive
can hold one or more logical drives).

> For this int 13h function, the first sector starts at 1, and
> not 0... (I am guessing that debugs sectors start at 0)

Correct.

> I cant see what I have done wrong..

That is because you have not done anything wrong !  The only thing you are
guilty of is mis-interpreting the arguments to, and the results from the
call :-)

>Or does this function not work on hard disks?

It does, it does !

> I tried using the biosdisk() function in C, and tried the
> same thing in pure asm and got the same problem.

Probably because they use the same call :-)

Regards,
  Rudy Wieser




0
Reply R 9/29/2003 9:01:10 PM


Hi :)

> > I am having problems with a function of int 13h
>
> [Snip]
>
> > This is my code in asm:
> >
> > mov    ax,0201h    ;read, 1 sector
> > mov    cx,0001h    ;cyl 0 sector 1
> > mov    dx,0080h    ;head 0, drive 0x80
> > mov    bx,offset databuf
> > int       13h
> >
> > databuf db 300 dup(0h)
>
> Ehhmm ...  A sector normally is 512 bytes.  You just reserve 300. That
could
> cause problems ...
>
> And are you aware you did not load ES ?

that was a typo ;) it should be 300h bytes, my actual code has it as 300h :P
sorry.
having only 300 bytes would make things hurt. lol. I agree..
I should have cut and paste rather than typing from scratch :P
DS,ES have already been setup prior to this call :)

> > The code above works fine for floppies (with dl set to 0),
> > however when I use this to read sectors from my "C" drive
> > (drive 0x80 is for the first HD - bit 7 set), the data
> > that is placed in my buffer is nonsense.
>
> Make that : Nothing you recognise :-)
>

The HD has only one partition on it, being DOS 6 only (FAT16),
shouldnt I expect a similar boot record with a BPB table
at cylinder 0, head 0, sector 1? It is there, because I witnessed
it in debug. Inside it the vendor ID string "DOS5" is in it. The data
supposedly read from the first sector on the HD with the int13h call
does not contain this data.

> It read the *Master*-boot-record (MBR for short).  In it is, next to a
small
> bootstrap-routine, stored where & how large the primary & extended
> partitions are.
>

So there are two boot records? even though theres only one partition
which has all the HD's space allocated to it (2G)? I'm aware of how
the mbr is used in conjunction with booting into multiple partitions. I just
find
this strange.

Alex :]



0
Reply alex 9/29/2003 10:26:43 PM

> It read the *Master*-boot-record (MBR for short).  In it is, next to a
small
> bootstrap-routine, stored where & how large the primary & extended
> partitions are.

> > if i issue "l 100 2 0 1" in debug, then type d 100 to view a
> > dump, the boot sector data can be seen. Am I missing
> > something here?
>
> Yes, you're missing something here.  The difference is that Debug works on
> *logical* drives, and INT 13h works on *physical* drives (a physical drive
> can hold one or more logical drives).
>

found the data I was looking for. it was in the first sector, but on head 1!
and not head 0!
debug must somehow know to treat that as the first sector. if it treats the
first sector at head 1
as the disk's first sector, and I gave debug a logical sector number of 0..
then how would I examine
the mbr in debug?

lol. this is rather odd.

Alex.





0
Reply alex 9/29/2003 10:48:11 PM

Are you the moderator for this newsgroup?  Is there any way to find out
what happened to my followup for this thread?  This guy would have had
his answer long before his followups made it to the newsgroup had my
posting made if through (which it doesn't appear to have)?

------- start of forwarded message -------
Path: news.mv.net!newsreader.wustl.edu!gumby.it.wmich.edu!aanews.merit.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-04!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
From: "alex" <no@spam.pls.kthx.com>
Newsgroups: comp.lang.asm.x86
Subject: Re: problem with int 13h function
Approved: CLAX86 Moderators <ccrayne@crayne.org>
Date: Tue, 30 Sep 2003 08:48:11 +1000
Organization: Ihug Limited
Message-ID: <blacme$6ss$1@lust.ihug.co.nz>
X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html
X-CLAX86-Faq: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.asm.x86.html
X-CLAX86-Info-1: Send submissions to comp-lang-asm-x86@moderators.isc.org
X-CLAX86-Info-2: Send technical complaints to    ccrayne@crayne.org
X-CLAX86-Info-3: Send complaints about policy to ccrayne@crayne.org
X-Comment: moderators do not necessarily agree or disagree with this article.
References: <bl97gd$dph$1@lust.ihug.co.nz> <3f789f3d$0$31507$e4fe514c@dreader3.news.xs4all.nl>
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
X-Spamscanner: mailbox3.ucsd.edu  (v1.2 May 26 2003 01:55:38, -0.5/5.0 2.55)
X-Spam-Level: Level 
X-MailScanner: PASSED (v1.2.8 30844 h8TMjfbA056867 mailbox3.ucsd.edu), Found to be clean
X-MailScanner-Information: Please contact the ISP for more information
X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=-3.688,
	required 4, BAYES_00 -4.90, PRIORITY_NO_NAME 1.21)
X-UIDL: CJ=!!7Ud!!=HO!!^G(!!
X-Complaints-To: abuse@supernews.com
Lines: 30
Xref: news.mv.net comp.lang.asm.x86:118049

> It read the *Master*-boot-record (MBR for short).  In it is, next to a
small
> bootstrap-routine, stored where & how large the primary & extended
> partitions are.

> > if i issue "l 100 2 0 1" in debug, then type d 100 to view a
> > dump, the boot sector data can be seen. Am I missing
> > something here?
>
> Yes, you're missing something here.  The difference is that Debug works on
> *logical* drives, and INT 13h works on *physical* drives (a physical drive
> can hold one or more logical drives).
>

found the data I was looking for. it was in the first sector, but on head 1!
and not head 0!
debug must somehow know to treat that as the first sector. if it treats the
first sector at head 1

------- end of forwarded message -------

========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
    Patrick Klos                           Email: patrick@klos.com
    Klos Technologies, Inc.                Web:   http://www.klos.com/
===== Why do I keep getting "one time mailings" over and over again?!? =====

0
Reply Patrick 9/30/2003 2:30:14 AM

I'm not the moderator. I posted it to two newsgroups to get an answer asap.
in alt.msdos.programmer and this group. I received your response there too.
Thanks :) And you were correct on the boot code, it was in Cylinder 0, head
1, sector 1
it appears the partition table and mbr occupy the region on the disk prior
to this.

now all I need is someone to steer me in the direction of some document on
what
the format of a partition table is, so I can process it  in my code (any
offers anyone?)

Cheers, Alex.

"Patrick Klos" <pklos@mv.mv.com> wrote in message
news:20030930023014.3618.qmail@mv.mv.com...
> Are you the moderator for this newsgroup?  Is there any way to find out
> what happened to my followup for this thread?  This guy would have had
> his answer long before his followups made it to the newsgroup had my
> posting made if through (which it doesn't appear to have)?
>
> ------- start of forwarded message -------
> Path:
news.mv.net!newsreader.wustl.edu!gumby.it.wmich.edu!aanews.merit.edu!newsfee
d.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-
xit-04!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!news
..crayne.org!clax86!robomod!not-for-mail
> From: "alex" <no@spam.pls.kthx.com>
> Newsgroups: comp.lang.asm.x86
> Subject: Re: problem with int 13h function
> Approved: CLAX86 Moderators <ccrayne@crayne.org>
> Date: Tue, 30 Sep 2003 08:48:11 +1000
> Organization: Ihug Limited
> Message-ID: <blacme$6ss$1@lust.ihug.co.nz>
> X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html
> X-CLAX86-Faq:
http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.asm.x86.html
> X-CLAX86-Info-1: Send submissions to comp-lang-asm-x86@moderators.isc.org
> X-CLAX86-Info-2: Send technical complaints to    ccrayne@crayne.org
> X-CLAX86-Info-3: Send complaints about policy to ccrayne@crayne.org
> X-Comment: moderators do not necessarily agree or disagree with this
article.
> References: <bl97gd$dph$1@lust.ihug.co.nz>
<3f789f3d$0$31507$e4fe514c@dreader3.news.xs4all.nl>
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
> X-Spamscanner: mailbox3.ucsd.edu  (v1.2 May 26 2003 01:55:38, -0.5/5.0
2.55)
> X-Spam-Level: Level
> X-MailScanner: PASSED (v1.2.8 30844 h8TMjfbA056867 mailbox3.ucsd.edu),
Found to be clean
> X-MailScanner-Information: Please contact the ISP for more information
> X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin
(score=-3.688,
> required 4, BAYES_00 -4.90, PRIORITY_NO_NAME 1.21)
> X-UIDL: CJ=!!7Ud!!=HO!!^G(!!
> X-Complaints-To: abuse@supernews.com
> Lines: 30
> Xref: news.mv.net comp.lang.asm.x86:118049
>
> > It read the *Master*-boot-record (MBR for short).  In it is, next to a
> small
> > bootstrap-routine, stored where & how large the primary & extended
> > partitions are.
>
> > > if i issue "l 100 2 0 1" in debug, then type d 100 to view a
> > > dump, the boot sector data can be seen. Am I missing
> > > something here?
> >
> > Yes, you're missing something here.  The difference is that Debug works
on
> > *logical* drives, and INT 13h works on *physical* drives (a physical
drive
> > can hold one or more logical drives).
> >
>
> found the data I was looking for. it was in the first sector, but on head
1!
> and not head 0!
> debug must somehow know to treat that as the first sector. if it treats
the
> first sector at head 1
>
> ------- end of forwarded message -------
>
> ========= For LAN/WAN Protocol Analysis, check out PacketView Pro!
=========
>     Patrick Klos                           Email: patrick@klos.com
>     Klos Technologies, Inc.                Web:   http://www.klos.com/
> ===== Why do I keep getting "one time mailings" over and over again?!?
=====
>



0
Reply alex 9/30/2003 3:58:07 AM

On 29 Sep 2003 22:30:14 -0400
"Patrick Klos" <pklos@mv.mv.com> wrote:

:Are you the moderator for this newsgroup?  Is there any way to find out
:what happened to my followup for this thread?  This guy would have had
:his answer long before his followups made it to the newsgroup had my
:posting made if through (which it doesn't appear to have)?

After searching the logs, I am reasonably certain that your post was not
received. Possibly your ISP can provide some additional information. As you
may already be aware, messages posted to a moderated newsgroup are
converted to email and sent to the moderator via a convoluted set of
relays. If you wish, you may bypass this process by emailing your posts
directly to clax86-submit@crayne.org.

-- Chuck

0
Reply Charles 9/30/2003 4:21:16 AM

alex <no@spam.pls.kthx.com> schreef in berichtnieuws
blabe6$5pp$1@lust.ihug.co.nz...
> Hi :)

Hello Alex,

[Snip]

> > > The code above works fine for floppies (with dl set to 0),
> > > however when I use this to read sectors from my "C" drive
> > > (drive 0x80 is for the first HD - bit 7 set), the data
> > > that is placed in my buffer is nonsense.
> >
> > Make that : Nothing you recognise :-)
>
> The HD has only one partition on it, being DOS 6 only (FAT16),
> shouldnt I expect a similar boot record with a BPB table
> at cylinder 0, head 0, sector 1?

No.  At that place a MBR is placed, so you will be *able* to create more
partitions (logical drives) on that physical drive.

> It is there, because I witnessed it in debug.

As I allready mentioned, debug works a bit different than INT 13h.

> Inside it the vendor ID string "DOS5" is in it. The data
> supposedly read from the first sector on the HD with the int13h call
> does not contain this data.

Correct.  As the sector you read is a MBR, not a BR.  A physical drive can
hold several logical drives, and every logical drive starts with a BR.   How
would the OS know where all those logical drives would be if nobody tells it
?  And that's where the MBR is for.

> > It read the *Master*-boot-record (MBR for short).  In it is,
> > next to a small bootstrap-routine, stored where & how large
> > the primary & extended partitions are.
>
> So there are two boot records?

Not really.  The one at 0,0,1 is a *master*-boot-record, while the one you
want to retrieve is just a Boot-record.

> even though theres only one
> partition which has all the HD's space allocated to it (2G)?
> I'm aware of how the mbr is used in conjunction with booting
> into multiple partitions. I just find this strange.

It's about having the *possibility* to divide the drive into multiple
partitions.  If it (the MBR) would not be there, creating one partition
(logical drive) would be all you *could* do ... :-)

[from another message]
> found the data I was looking for. it was in the first sector,
> but on head 1! and not head 0!

Jup.  That's exactly right.  A Partition and/or a logical drive *must* start
at sector 1 (having the effect that the BR of that logical drive is also
placed at sector 1).

> debug must somehow know to treat that as the first sector.
> if it treats the first sector at head 1 as the disk's first sector,

Nope, that's not it.   It treats the first sector of *any* partition as
"sector" Zero.   By the way : didn't you notice that Debug does not use
Track,Head,Sector *at all* (and INT 13h does) ?

> and I gave debug a logical sector number of 0..
> then how would I examine the mbr in debug?

By writing some code that uses INT 13h to get the sector you want :-)
Debug itself (the "L" command)won't be able to get it.

> lol. this is rather odd.

Well, yes.  But that's only as long as the difference between physical and
logical drives is not yet clear to you :-)   Give it a few day's, and it
will come to you

Regards,
  Rudy Wieser




0
Reply R 9/30/2003 9:46:10 AM

In article <blaurh$o1i$1@lust.ihug.co.nz>, alex <no@spam.pls.kthx.com> wrote:
>I'm not the moderator. 

I didn't mean for that question to go to the newsgroup - only to (hopefully)
the moderator.  I must have mistyped something.  Anyway...

>I posted it to two newsgroups to get an answer asap.
>in alt.msdos.programmer and this group. I received your response there too.
>Thanks :) And you were correct on the boot code, it was in Cylinder 0, head
>1, sector 1
>it appears the partition table and mbr occupy the region on the disk prior
>to this.
>
>now all I need is someone to steer me in the direction of some document on
>what
>the format of a partition table is, so I can process it  in my code (any
>offers anyone?)

Check out http://home.att.net/~rayknights/pc_boot/w95b_mbr.htm#PartTbl for
a better reference than I can recall from memory.  Don't worry about the
Win95 reference - that's all pretty standard stuff.

========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
    Patrick Klos                           Email: patrick@klos.com
    Klos Technologies, Inc.                Web:   http://www.klos.com/
===== Why do I keep getting "one time mailings" over and over again?!? =====

0
Reply patrick 9/30/2003 6:15:59 PM

Thanks guys, the feedback has been very helpful & appreciated, and has
steered
me in the right direction. I thank all of you for your time.

Alex :)



0
Reply alex 9/30/2003 10:18:56 PM

alex <no@spam.pls.kthx.com> schreef in berichtnieuws
blcvbg$cin$1@lust.ihug.co.nz...

Hello alex,

> Thanks guys, the feedback has been very helpful & appreciated,
> and has steered me in the right direction. I thank all of you for
> your time.

You're welcome :-)

Regards,
  Rudy Wieser




0
Reply R 10/1/2003 9:01:28 AM

10 Replies
231 Views

(page loaded in 0.128 seconds)

Similiar Articles:













7/30/2012 3:08:41 PM


Reply: