Re: asm and nasm newbie



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


.



Relevant Pages

  • Re: load-balancing twin 10GbE?
    ... The confusion comes in only from the untrained minions ... size of computer storage, a prefix indicating 2^10, or 1024. ... characters a second under. ...
    (comp.os.linux.networking)
  • Re: load-balancing twin 10GbE?
    ... The confusion comes in only from the untrained minions ... size of computer storage, a prefix indicating 2^10, or 1024. ... "While computer scientists typically used k ... The governing body that is recognized by computer scientists is ACM ...
    (comp.os.linux.networking)
  • Re: Compact flash capacity
    ... >>binding definition of the 'k' prefix applicable is made by exactly the ... This silly confusion has gone on ... Anyway if you are worrying about the misuse of a SI prefix, ...
    (comp.arch.embedded)
  • Re: Near Suicidal!
    ... I'm not sure what the confusion is. ... One reason for confusion might be that "cbo" is a more or less standard ... prefix for the name of a combo box, ...
    (microsoft.public.access.formscoding)
  • Re: asm and nasm newbie
    ... in a word, 66h prefix is for operand size toggle and, 67h prefix is for ... address size toggle. ... directly, for example, mov 32bit-data, eax. ... since that using gcc and gas, i think i have better using gas either ...
    (comp.lang.asm.x86)