Re: asm and nasm newbie
- From: "wolfgang kern" <nowhere@xxxxxxxxxxx>
- Date: Tue, 27 Sep 2005 09:52:44 +0000 (UTC)
Zhang Huan wrote:
| when i knew the 66h prefix, i wondered whether it can help me. actually
| i must write an INT13h handler, an implementing a simplied RPC
| protocol.
The 66h prefix is very valuable for using 32-bit registers and data
while in 16-bit modes (RM or PM).
| it would be much better if i can implement it in c, for time
| is so limited. however gcc cannot correctly compile c to 16bit-code in
| the case of memory access. but i think i can do something to change the
| assemble code gcc compiled.
Why not use NASM ?
| > If you use (assuming 16 bits by default yet):
| >
| > 66 e9 xx xx xx xx jmp +x ;then the branch offset is also affected.
| >
| > But as the jumped target cannot be outside the 64KB segment,
| > it is somehow useless in 16-bit mode.
| sorry for my poor english :)
English isn't my mother-tongue either ;)
| do you mean that high 16bit address is ignored??
No, with 66h prefix the whole instruction will work with 32-bit
operand size, but the address-size will remain 16-bit.
And as the jump-instruction use an operand to calculate the address,
this may add to the confusion.
(therefore I mentioned a few instructions where this looks opposite
67 e2 LOOP (uses ECX) even the 67h is defined for address-size toggle).
So if the result of
x000 66 e9 xx xx xx xx ;actual code address
x006 ... ; +6 + offset x
points to outside the 64KB real-mode segment, it may either
raise and real-mode exception,
truncate (ignore) the high 16 bits of the result,
or on a few CPU-clones, it jumps to an unpredictable location
and usually produce a crash there then.
| and how to add such prefix, for example, in gas
Sorry, I never used GAS. but I'd estimate:
db 66h ; in front of ..
db ... ; don't rely on your assembler to create correct sized
; parameters after a db 66h or more worse after db 67h.
[...]
| > I hope I didn't add too many confusion with the uncommon...
| no, you're justing "unconfusing" me :)
:) a rare seen answer to my posts.
__
wolfgang
.
- References:
- asm and nasm newbie
- From: Zhang Huan
- Re: asm and nasm newbie
- From: Frank Kotler
- Re: asm and nasm newbie
- From: Zhang Huan
- Re: asm and nasm newbie
- From: wolfgang kern
- Re: asm and nasm newbie
- From: Zhang Huan
- Re: asm and nasm newbie
- From: Zhang Huan
- asm and nasm newbie
- Prev by Date: Re: Is there any example of using int 15h,ax=e820h?
- Next by Date: Re: Getting Back to Real Mode problem
- Previous by thread: Re: asm and nasm newbie
- Next by thread: Re: Polling input from the mouse
- Index(es):
Relevant Pages
|