Page 1 of 1
Why INT 13 cannot put data at end of segment in RMode?
Posted: Thu Nov 06, 2014 7:01 am
by donggas90
Code: Select all
mov dl, byte[DiskNumber]
mov si, AddressPacket
mov byte[si + SDiskAddressPacket.mSizeOfPacket], 16
mov byte[si + SDiskAddressPacket.mReserved], 0
mov word[si + SDiskAddressPacket.mReadSectorCount], 1
mov word[si + SDiskAddressPacket.mTargetOffset], 0x10000 - 2048
mov word[si + SDiskAddressPacket.mTargetSegment], 0x3F
mov dword[si + SDiskAddressPacket.mSectorIndex], 1
mov dword[si + SDiskAddressPacket.mSectorIndexHigh], 0
call IO_ExtendedReadSectors16 ; call INT 13 Function 42
jc FailReadDiskFailed16
In curiously, I had been tried above code in VMware, to fill end of a segment with a sector.
but just stopped after launch.
NOT fault occured, NOT returned failed signal with carry flag.
Just stucked.
Then had been tested other cases and recognized that cannot put in last approximately* 60bytes of a segment.
(*sometimes worked 59bytes from end of segment.)
Why this happened? Is it normal case?
Thanks!
Re: Why INT 13 cannot put data at end of segment in RMode?
Posted: Thu Nov 06, 2014 7:08 am
by Combuster
My crystal ball thinks there's a stack there.
Re: Why INT 13 cannot put data at end of segment in RMode?
Posted: Thu Nov 06, 2014 7:14 am
by donggas90
Combuster wrote:My crystal ball thinks there's a stack there.
Code: Select all
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
not ax
mov sp, ax
Good point.
I had been edited that part of sample code.
because already tried other segments such as 0x3F, 0xFF, 0xFFF what are far from start of memory with target segment but same result occured.
Re: Why INT 13 cannot put data at end of segment in RMode?
Posted: Thu Nov 06, 2014 7:25 am
by donggas90
Maybe this is a complex problem.
At last, I'm thinking INT 13 wasn't real reason by Combuster's answer.
Now will figure out exact reason myself.
Thanks for regard!
Re: Why INT 13 cannot put data at end of segment in RMode?
Posted: Thu Nov 06, 2014 8:28 am
by JAAman
donggas90 wrote:
Code: Select all
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
not ax
mov sp, ax
thats not really a good way to do the stack...
2 problems:
1) you have an invalid stack for one instruction: mov sp should always immediately follow mov ss.... always, no exceptions (the CPU always suspends interrupts for the one instruction following any move into SS since it expects the next instruction must be a mov to SP to make the stack correct)
2) your stack is misaligned, which , while legal, is not good -- you should be loading SP with 0 instead (remember, SP points at the previous entry, so it will be decremented
before storing value, so setting SP = 0, will result in the first value being stored at 0xFFFE/0xFFFF -- at the top of the segment, which is probably what you wanted anyway
simply removing the "not ax" line would fix both of these problems
Re: Why INT 13 cannot put data at end of segment in RMode?
Posted: Thu Nov 06, 2014 6:47 pm
by donggas90
Wow, Thanks JAAman.
Good informations!
I will fix them!