- A program without the statement
exit
can still be assembled successfully.
Explain what would happen when the program executes.
(15%)
Ans>
The exit
statement calls a predefined MS-Windows function that halts the program.
Running a program without the statement may have an abnormal ending, which may cause an unexpected result such as crashing the DOS window.
- What is the purpose of the identifier in the
END
statement?
(15%)
Ans>
It is the name of the program's startup procedure (the procedure that starts the program execution).
- Declare a string variable containing the string “This is only a test.”, including the end-of-string symbol 0, repeated 100 times.
(15%)
Ans>
myString BYTE 100 DUP ( "This is only a test.", 0 )
- Show the order of individual bytes in memory (lowest to highest) for the following variables:
(20%)
val1 DWORD 123h
val2 BYTE 0ABh
val3 WORD 4, 5
lowest
Byte 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
... |
23 |
01 |
00 |
00 |
AB |
04 |
00 |
05 |
00 |
|
|
... |
- Show how to calculate the number of elements, 200 in this example, in the following array and assign the value to a symbolic constant named
arraySize
:
(15%)
myArray DWORD 10 DUP( 10 DUP( ?, ? ) )
Ans>
myArray DWORD 10 DUP( 10 DUP( ?, ? ) )
arraySize = ( $ - myArray ) / 4
- Use
TEXTEQU
to create a symbol named string
for a string constant of repeating the word “Hello”, without the end-of-string symbol 0, 10 times and the word “World”, without the end-of-string symbol 0, 5 times by using the DUP
operator.
After the declaration, use the symbol when defining a string variable named myString
.
(20%)
Ans>
string TEXTEQU <10 DUP( "Hello" ), 5 DUP( "World" )>
myString BYTE string