| | |
variables question
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2007
Posts: 14
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Aug 2008
Posts: 9
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- Basic Variables Question (Visual Basic 4 / 5 / 6)
- A little Help (C++)
- Threading question... (Java)
- Uber-N00B question (C++)
- Using string variables in a label or text box? (VB.NET)
Other Threads in the Assembly Forum
- Previous Thread: Assembly help - Compiling via TASM
- Next Thread: Proc to set uo Tool Tips
Views: 602 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





