how to choose the destination address for reading sectors from drive?

Hello,
I am using INT 13h AH=02h (http://en.wikipedia.org/wiki/BIOS_call#INT_13h_AH.3D02h:_Read_Sectors_From_Drive) to read sectors from a drive to the memory, and I was wondering how one should pick the target address? Are there any rules? Do I just pick a number from 0x0000h to 0xFFFFh and use it? Is there any rule of thumb?
[332 byte] By [someuser77] at [2007-11-20 11:12:49]
# 1 Re: how to choose the destination address for reading sectors from drive?
Hello Someuser77,

It depends on the structure of drive you address. Assuming you're working with DOS (because Windows disables BIOS disk I/O operations), you use BX, CX, DX registers to define drive parameters.

Search keywords Cylinder, Head, Sector at Internet. For example, floppy drive allows only two head values (0 and 1), while hard disk drives contain a higher number of heads.

Iaki Viggers
iviggers at 2007-11-10 3:55:13 >
# 2 Re: how to choose the destination address for reading sectors from drive?
Thank you for your reply iviggers, I am afraid I didn't explain myself correctly, my question was regarding how one should choose the ES:BX address, when I load the sectors to memory, what address should I specify? How do I know if I selected a good address?
someuser77 at 2007-11-10 3:56:06 >
# 3 Re: how to choose the destination address for reading sectors from drive?
Well, that's certainly a different question.

ES:BX should refer some area inside your program data-area, although DOS allows ES:BX pointing somewhere out of program.

There's not much to optimize from the choice, excepting for making buffer start at a proper alignment (like starting at an address multiple of 4, which would be called dword alignment).

The following (incomplete) code works in TASM:

.model small
.stack 10h
.data
buffer db 200h dup (00h) ; remember BIOS reads/writes in chunks of 512 bytes
.code
start:
...
mov ax,@data
mov es,ax
mov bx,offset buffer ;; data read will be stored in this location
...
mov ah,02h
...
int 13h
...

and you likely would need to include a directive to force alignment. I don't remember which one is t hat directive or linker option.
iviggers at 2007-11-10 3:57:05 >