flat assembler
Message board for the users of flat assembler.

Index > Main > ES:BX Explanation Needed!

Author
Thread Post new topic Reply to topic
leo128



Joined: 04 Aug 2006
Posts: 2
leo128 04 Aug 2006, 15:50
I'm trying to use int 13h, function 02h --> Read disk sectors.

this is the description I've found on internet:

Function 02h: Read Disk Sectors
This function reads disk sectors using CHS format. This can be either a floppy diskette or a hard disk.

On input, the CHS values are contained in the following registers:

AH = function number, 02h in this case
AL = number of sectors to read (must be nonzero)
CH = low 8 bits of cylinder number
CL = high 2 bits of cylinder number and 6-bit sector number as follows:
high-order bits 6-7 (hard disk only) contain high 2 bits of cylinder number
low-order bits 0-5 contain sector number (1-63)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX = data buffer


the problem is... what does EX:BX mean? I'm new to ASM, I use "flat assembler"

I mean, in general, somebody would give me a hint on using the ES register? what does the column between ES and BX stand for? which is the correct sintax for flat assembler?

Or... a good tutorial about this?

Thank you!
Post 04 Aug 2006, 15:50
View user's profile Send private message Reply with quote
HyperVista



Joined: 18 Apr 2005
Posts: 691
Location: Virginia, USA
HyperVista 04 Aug 2006, 19:45
Hello leo128

ES stands for Extra Segment and is one of a handful of segment registers and can be used to specify a location in memory. The colon between ES and BX (ES:BX) denotes the standard segment:off-set address notation. In otherwords, ES:BX specifies a memory location that is the value contained in BX "distance" from the start of the segment ES.
Post 04 Aug 2006, 19:45
View user's profile Send private message Visit poster's website Reply with quote
leo128



Joined: 04 Aug 2006
Posts: 2
leo128 05 Aug 2006, 19:22
All Right! Thank you!

So, let see if I got it...

CS --> Code segment (points to a segment in which the program code resides)
DS --> Data segment (points to a segment in which the program is expected to store its data)
ES --> Extra segment register used for addressing memory without modifying other registers, for example DS.

so, if I make ES match CS, I can read data from disk and tell int 13 to store data in the code segment, and I have to pay attention not to overwrite the program code itself...

so, actually, because I'm not yet an expert ASMer, I tried

mov ax, cs
mov es, ax

and it worked fine... so at the moment I use labels to make room for my data. anyway, I think I could have done this with any other memory segment (like DS...) to make it accessible via ES.

is all this right? did I get it? I hope so...

anyway... my interrupt 13 call seems to work fine now, except that it fails returning an error code in AH (code = 80h, which seems to mean "Disk Timeout"). When I issue the int 13 call, the MS-DOS 16 bit subsystem of windows XP tells me that int 13 is unsupported, and the application might not work as expected. I just click "Ignore" and it goes stright to the failure (CF = 1, AH = 80h)

so my doubt is... can I use int 13h, function 02h in my environment, or I'll have to do something, like install windows 98 or MS-DOS 6.22 ???

maybe I passed it wrong cyl/head/sect parameters...

or even... do I have to use another interrupt ???

thank you again!!!
Post 05 Aug 2006, 19:22
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 22 Dec 2006, 02:58
Accidentally found this (OK, not newest) thread with open questions.

Quote:

so my doubt is... can I use int 13h, function 02h in my environment


NO.

Quote:

or I'll have to do something, like install


DOS. FreeDOS or Enhanced DR-DOS Wink

Quote:

maybe I passed it wrong cyl/head/sect parameters...


Install DOS first. Also, CHS works up to 8 GB maximal.

Quote:

or even... do I have to use another interrupt ???


NO. Use this one but be careful not to overwrite something on the HD. Wink

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 22 Dec 2006, 02:58
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.