CSci250 Assembly Language Programming: Homework 2 Solutions
Due date (firm): Monday, September 29, 2008 in class
Each homework may have a different weight, which depends on its level of difficulty.
Absolutely no copying others' work

  1. A program without the statement exit can still be assembled successfully. Explain what would happen when the program executes.     (15%)
    Ans>

  2. What is the purpose of the identifier in the END statement?     (15%)
    Ans>

  3. 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 )

  4. 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     ...

  5. 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

  6. 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