** In assembly language, an array is just a sequence of memory bytes or word.
For Example : To define a three-byte array called B_ARRAY, whose initial values are 10h, 20h, and 30h, we can write,
B_ARRAY DB 10H,20H,30H
The name B_ARRAY is associated with the first of these bytes, B_ARRAY+1 with the second, and B_ARRAY+2 with the third. If the assembler assigns the offset address 0200h to B_ARRAY, then memory would look like this :
Symbol Address Contents
B_ARRAY 200h 10h
B_ARRAY+1 201h 20h
B_ARRAY +2 202h 30h
In the same way, an array of words may be defined.
Example :
W_ARRAY DW 1000,40,29887,329
sets up an array of four words, with initial value 1000, 40,29887, and 329.
The initial word is associated with the name W_ARRAY, the next one with W_ARRAY+2, the next with B_ARRAY+4, and so on. If the array starts at 0300h, it will look like this :
Symbol Address Contents
W_ARRAY 0300h 1000d
W_ARRAY+2 0302h 40d
W_ARRAY +4 0304 29887d
W_ARRAY +6 0306h 329d
High and low Bytes of a Word
Sometimes we need to refer to the high and low bytes of a word variable. Suppose we define
WORD1 DW 123H
The low byte of WORLD1 contains 34h, and the high byte contains 12h. The low byte has symbolic address WORD1, and the high byte has symbolic address WORD1+1.
Character Strings
An array of ASCII codes can be initialized with a string of characters.
Example :
LETTERS DB 'ABC'
is equivalent to
LETTERS DB 41H,42H,43H
Inside a String the assembler differentiates between upper and lower case. Thus, the string "abc" is translated into three bytes with values 61h,62h, and 63h
It is possible to combine characters and number in one definition;
Example :
MSG DB 'HELLO', 0AH, 0DH, 'S'
is equivalent to
MSG DB 48H, 45H, 4CH, 4CH, 4FH, 0AH, 0DH, 24H
No comments:
Post a Comment