11 Microprocessor Systems Lecture No 11 Arrays and Symbolic Constants
11 Microprocessor Systems Lecture No 11 Arrays and Symbolic Constants
Systems
Lecture No 11 Arrays and Symbolic
Constants
By Nasir Mahmood
This Lecture
Using the DUP Operator
Declaring Unitialized Data
Calculating the Size of a Byte Array
Symbolic Constant
3
Declaring Unitialized Data
Use the .data? directive to declare an
unintialized data segment:
.data?
Within the segment, declare variables with "?"
initializers:
smallArray DWORD 10 DUP(?)
4
Mixing Code and Data
The assembler lets you switch back and forth between code
and data in your programs. You might, for example, want to
declare a variable used only within a localized area of a
program.
The following example inserts a variable named temp between
two code statements :
.code
mov eax,ebx
.data
temp DWORD ?
.code
mov temp,eax
...
Symbolic Constants
A symbolic constant (or symbol definition) is
created by associating an identifier (a symbol)
with an integer expression or some text.
Symbols do not reserve storage. They are used
only by the assembler when scanning a
program, and they cannot change at runtime
Equal-Sign Directive
name = expression
expression is a 32-bit integer
(expression or constant)
may be redefined
PI EQU <3.1416>
No Redefinition Unlike the = directive, a symbol
defined with EQU cannot be redefined in the
same source code file
Examples EQU Directive
Example 1
Example 2
TEXTEQU Directive
The TEXTEQU directive, similar to EQU, creates
what is known as a text macro. There are three
different formats: the first assigns text, the second
assigns the contents of an existing text macro, and
the third assigns a constant integer expression:
name TEXTEQU <text>
name TEXTEQU textmacro
name TEXTEQU %constExpr
A symbol defined by TEXTEQU can be redefined
at any time
Examples TEXTEQU Directive
Example 1
Example 2
THE END