|
-
Apr 18th, 2006, 01:11 PM
#1
Thread Starter
Frenzied Member
confused about this code...
I read this in a tutorial and I'm wondering if someone could explain how this is true.
Code:
value_two dw 0
value_three dd 0
mov byte ptr [value_three + 1],"o"
mov word ptr [value_three + 2],2020h
here's the quote:
"mov byte ptr [value_two + 1],"l" : Same as above, except for the +1. The +1 means the assembler has to add one to the address of value_two. This way, an "l" is stored in the second byte of the word value_two (still get it?)
mov word ptr [value_three + 2],2020h : Word ptr means that we want to store a word. (this way the bytes will be stored in reverse order, see part 1) The +2 indicates that we want to store the value in the second word of the dword value_three."
I don't understand how "+2 indicates that we want to store the value in the second word of the dword value_three". Shouldn't it be stored in the location right after the dword value_three. Because if the quote is true, then the quote:
"mov byte ptr [value_two + 1],"l" : Same as above, except for the +1. The +1 means the assembler has to add one to the address of value_two. This way, an "l" is stored in the second byte of the word value_two (still get it?)"
would mean that +1 means the an "l" is stored in the "first"(not second) byte of the word value_two. Is +1 and +2 refering to bytes? or is +1 referring to a byte for each, since it is a byte pointer, and +2 referring to a word for each so its +2 words? I'm confused.
-
Apr 25th, 2006, 12:04 AM
#2
Re: confused about this code...
The latter.
If memory servers that this:
 Originally Posted by benmartin101
is +1 referring to a byte for each, since it is a byte pointer, and +2 referring to a word for each so its +2 words?
...is correct.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|