Pointers and references: Difference between revisions

m
Line 21:
We can load to or from memory with the 8086 in a few different ways. In the example below, the value in a memory address is loaded directly from RAM to a register, or vice versa. Assume the code below takes place immediately after the setup above:
 
<lang asm> mov ax,0FFFFh ;see note 1
mov word ptr [ds:tempWord],ax ;store hexadecimal value FFFF into tempWord
 
Line 33:
8086 Assembly doesn't enforce data types that much. While your variables may be intended to be byte or word length, there's nothing actually stopping you from using the "wrong" pointer type, as long as the register you're moving to/from matches the size of the pointer variable.
 
<lang asm> mov ax, byte ptr [ds:tempByte] ;assembler will generate an error - operands don't match
mov al, word ptr [ds:tempWord] ;assembler will generate an error - operands don't match
mov ax, word ptr [ds:tempByte] ;assembler will allow this even though the intended data size is wrong
Line 41:
You can also define a full double word address like so: <code>UserRamPtr dword UserRam</code>
Then this pointer can be loaded into a segment register and data register with a single command, like so:
<lang asm> LDS bx,UserRamPtr ;loads [ds:bx] with UserRamPtr</lang>
 
=={{header|68000 Assembly}}==
1,489

edits