variables question

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2007
Posts: 14
Reputation: rumencho is an unknown quantity at this point 
Solved Threads: 0
rumencho rumencho is offline Offline
Newbie Poster

variables question

 
0
  #1
Aug 12th, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 9
Reputation: gsbr is an unknown quantity at this point 
Solved Threads: 0
gsbr gsbr is offline Offline
Newbie Poster

Re: variables question

 
0
  #2
Aug 17th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum


Views: 602 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC