Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

BYTE PTR vs WORD PTR ? (confused)

Does WORD PTR designating the size

of the ADDRESS operand (needing 16 bits

to "point" to the location of the operand)?

And does it mean that the actual operand to

which a WORD PTR points to might be only

8 bits in length? In other words, does

WORD PTR mean an 8 bit operand pointed to

by 16 bits (either in the instruction or by

an r/m code for a 16 bit register)?

And so what does BYTE PTR designate? Only

8 bits are need to point to the operand?

I am all befuddled over this - it can't really

be that impossible to grasp, can it?

Help.

Jerry Burnett [email protected]






Comments

  • : Does WORD PTR designating the size

    : of the ADDRESS operand (needing 16 bits

    : to "point" to the location of the operand)?

    : And does it mean that the actual operand to

    : which a WORD PTR points to might be only

    : 8 bits in length? In other words, does

    : WORD PTR mean an 8 bit operand pointed to

    : by 16 bits (either in the instruction or by

    : an r/m code for a 16 bit register)?

    : And so what does BYTE PTR designate? Only

    : 8 bits are need to point to the operand?

    : I am all befuddled over this - it can't really

    : be that impossible to grasp, can it?

    : Help.

    : Jerry Burnett [email protected]



    Look, it's simple. If you code



    mov memoryword, ax



    you don't have to use PTR, because the CPU sees, oh, it's AX, so it is a word. Now if you code



    inc memoryvar



    the cpu just increases the byte at [memoryvar]. But what if that causes an owerflow. There may be two cases:



    1. You are adressing a byte: the carry flag is set, and the byte is set to zero



    2. You are adressing a word: the following byte is increased by one.



    So here you have to give a PTR, because the CPU cannot know which case you mean.



    If you access a byte variable with PTR WORD, the following date may be corrupted. (because the next byte belongs to some other data)



    The adress itself can be either 8 or 16 Bits. It depains on the length. If the adress is lower than 128, the assembler uses the shorter form.



    I hope this helps a bit. If not, please repost or mail me.



    -stw




Sign In or Register to comment.