943,752 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 714
  • Assembly RSS
Aug 12th, 2008
0

variables question

Expand Post »
Here is my question.

We declare: var1 db 1
and consider that in memory var1 will be placed at address 0100h

Now,when we move var1(byte long) in AX (which is 16 bits long) AX will be filled with value at memory location 0100h + value at 0101h, because AX must be filled with 2 bytes.

but what exactly happens if we write: mov AX [var1 + 1]

in the tutorial that I'm reading says that this statement puts in AX the value of two bytes beginning from adres 0101h ,not 0100h !

why?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rumencho is offline Offline
14 posts
since Sep 2007
Aug 17th, 2008
0

Re: variables question

Because [var+1] is a pointer to a location
as Var1 is declred as a Byte(a place HOLDER),It has nothing to do with the instruction.
The programmer MUST use the RIGHT instruction

0100h +1h ==>> 0101h
and the Instruction mov AX works on a WORD
If it was mov EAX[var1+1]it woud take 4 bytes starting from 0101h to 0104h and put them in EAX.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gsbr is offline Offline
9 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Assembly help - Compiling via TASM
Next Thread in Assembly Forum Timeline: Proc to set uo Tool Tips





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC