Re: boot sector
- From: bob@xxxxxxxxxxxxxx
- Date: 23 Nov 2006 21:44:13 -0800
Benjamin David Lunt wrote:
<bob@xxxxxxxxxxxxxx> wrote in message
news:1164324758.361049.262160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've been looking at the code for my hard drive's boot sector, and I am
somewhat confused by this portion:
60 pusha
6A00 push byte +0x0
6A00 push byte +0x0
FF760A push word [bp+0xa]
FF7608 push word [bp+0x8]
6A00 push byte +0x0
68007C push word 0x7c00
6A01 push byte +0x1
6A10 push byte +0x10
B442 mov ah,0x42
8BF4 mov si,sp
CD13 int 0x13
61 popa
It appears to call this interrupt for an "EXTENDED READ":
http://www.ctyme.com/intr/rb-0708.htm
That page indicates the format of a disk address packet is as follows:
00h BYTE size of packet (10h or 18h)
01h BYTE reserved (0)
02h WORD number of blocks to transfer (max 007Fh for Phoenix EDD)
04h DWORD -> transfer buffer
08h QWORD starting absolute block number
The code says the size of packet is 0x10 with the line "push byte
+0x10". However, it seems to put a 1 in the reserved section with
"push byte +0x1" - or am I reading it wrong?
push byte 01
doesn't actually push a byte on to the stack. It pushes a sign
extended word onto the stack. All stack access with push and pop
is 16-bit (unless you use opsize, etc.)
Also, it doesn't appear to specify all 16 bytes of the disk address
packet. Is it planning to use the leftovers from the initial pusha
call?
If you count the push's, 8, then multiply by sizeof(word), that
is actually 16 bytes.
Since the push's go down in memory, sp will point to the first
of the data block pushed.
Now, what gets me is, why does the code popa without adding 16
to the sp register first?
Ben
Thanks, Benjamin.
It actually does two popa's in a row, but I only put in the first one.
Also, just to confirm, is the code reading 1 block? (a.k.a. 512 bytes)
.
- Follow-Ups:
- Re: boot sector
- From: Benjamin David Lunt
- Re: boot sector
- References:
- boot sector
- From: bob
- Re: boot sector
- From: Benjamin David Lunt
- boot sector
- Prev by Date: Re: boot sector
- Next by Date: Re: boot sector
- Previous by thread: Re: boot sector
- Next by thread: Re: boot sector
- Index(es):
Relevant Pages
|