Vars
Vars
name DB value
name DW value
ORG 100h
RET
VAR1 DB 7
var2 DW 1234h
Compiler is not case sensitive, so "VAR1" and "var1" refer to
the same variable.
You can see that there are some other instructions after
the RET instruction, this happens because disassembler has
no idea about where the data starts, it just processes the
values in memory, and it understands them as valid 8086
instructions.
Arrays
Arrays can be seen as chains of variables. A text string is an
example of a byte array, each character is presented as an
ASCII code value (0..255).
Here are some array definition examples:
You can access the value of any element in array using square
brackets, for example:
You can also use any of the memory index registers BX, SI,
DI, BP, for example:
MOV SI, 3
MOV AL, a[SI]
for example:
c DB 5 DUP(9)
is an alternative way of declaring:
c DB 9, 9, 9, 9, 9
Reminder:
In order to say the compiler about data type,
these prefixes should be used:
For example:
BYTE PTR [BX] ; byte access.
or
WORD PTR [BX] ; word access.
MicroAsm supports shorter prefixes as well:
sometimes compiler can calculate the data type automatically, but you may not and should not rely on that
when one of the operands is an immediate value.
Here is first example:
ORG 100h
RET
VAR1 DB 22h
END
ORG 100h
RET
VAR1 DB 22h
END
These lines:
LEA BX, VAR1
MOV BX, OFFSET VAR1
are even compiled into the same machine code: MOV BX, num
num is a 16 bit value of the variable offset.
1, 2, 3, 4, 5
5+2