1. Fill in the blanks following the comments for each line,
    type in a text editor, save with .asm extension.

  2. Assemble using ml.exe

  3. Load the executable into the CodeView debugger and step through the execution, observe values in the registers and memory, make sure that the result of your program matches the one given in the comments.

  4. For the report, provide the filled in pages and 4 screen shots of the debugger (Alt+PrintScr, paste into the Word) with each of the programs loaded in.


NAME: _________________________________________________


; Program 1: The program using REGISTER INDIRECT addressing

        .MODEL SMALL

        .DATA

        VAR1 DB 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H, 0AH

        ;Define ten 1-byte variables with the label VAR1

        ;This construct can be treated as a byte array

VAR2 ________ ________ ;Define a 2-byte variable initialized as 0

        .CODE

        .STARTUP

        _________ ________, ________ ; Step1: Store the offset of VAR1 in an index register

        _________ ________, ________ ; Step 2: Store 0 in the accumulator

<>        _________ ________, ________ ; Step 3: Store 10 (number of elements in the array) in the register CX

LHERE : ADD ________, ________ ; Step 4: Use the register indirect addressing and the

                                                                    ; index register initialized in Step 1 to add the content of the memory location

                                                                    ; pointed by that index register to the register AL

        INC ________ ; Increment (add 1 to the content of a register) the index register (put the register name instead of the ________)

        LOOP LHERE  ; This instruction will decrement the number in CX and jump to address LHERE if CX is not equal to 0

                                ; The register AX must contain the number 37H as the result

        _________ ________, ________ ; Store the content of register AX in the memory at the address VAR2

.EXIT

END


;Program 2: The same program using REGISTER RELATIVE addressing

        .MODEL SMALL

        .DATA

VAR1 DB 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H, 0AH

        ;Define ten 1-byte variables with the label VAR1

        ;This construct can be treated as a byte array

VAR2 ________ ________ ;Define a 2-byte variable initialized as 0

        .CODE

        .STARTUP

        _________ ________, ________ ; Step1: Store 0 in an index register

        _________ ________, ________ ; Step 2: Store 0 in the accumulator

<>        _________ ________, ________ ; Step 3: Store 10 (number of elements in the array) in the register CX

LHERE : ADD ________, ________ ; Step 4: Use the REGISTER RELATIVE addressing
and the index register

                                                                    ; initialized in Step 1 to add the content of the memory location

                                                                    ; pointed by that index register to the register AL


<>        INC ________ ; Increment the index register (put the register name instead of the ________)

        LOOP LHERE

                                ; The register AX must contain the number 37H as the result

        _________ ________, ________ ; Store the content of register AX in the memory at the address VAR2

.EXIT

END



;Program3: The same program using BASE+INDEX addressing

        .MODEL SMALL

        .DATA

VAR1 DB 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H, 0AH

        ;Define ten 1-byte variables with the label VAR1

        ;This construct can be treated as a byte array

VAR2 ________ ________ ;Define a 2-byte variable initialized as 0

        .CODE

        .STARTUP

        _________ ________, ________ ; Step 1: Store 0 in an index register

<>        _________ ________, ________ ; Step 2: Store the offset of memory location VAR1 in a base register

        _________ ________, ________ ; Step 3: Store 0 in the accumulator

<>        _________ ________, ________ ; Step 4: Store 10 (number of elements in the array) in the register CX

LHERE : ADD ________, ________ ; Step 5: Use the BASE+INDEX addressing
and the base and index registers

                                                        ; initialized in Steps 1-2 to add the content of the memory location

                                                        ; pointed by the index register to the register AL

            INC ________ ; Increment the index register (put the register name instead of the ________)

LOOP LHERE

; The register AX must contain the number 37H as the result

            _________ ________, ________ ; Store the content of register AX in the memory at the address VAR2

.EXIT

END


; Program 4 - using stack

        .MODEL SMALL

        .DATA

VAR1 DB 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H, 0AH

        ;Define ten 1-byte variables with the label VAR1

        ;This construct can be treated as a byte array

VAR2 ________ ________ ;Define a 2-byte variable initialized as 0

        .CODE

        .STARTUP

        _________ ________, ________ ; Step 1: Store 0 in an index register

        _________ ________, ________ ; Step 2: Store the offset of memory location VAR1 in an index register

        _________ ________, ________ ; Step 3: Store 0 in the accumulator

        _________ ________, ________ ; Step 4: Store 5 (number of word elements in the array) in the register CX

LHERE : _______ _______                 ; Step 5: Push content of memory location pointed by the index register from Step 2 on the stack

           INC ________ ; Increment the index register (put the register name instead of the ________)
           INC ________ ; Increment the index register (put the register name instead of the ________)

LOOP LHERE

        _________ ________, ________ ; Step 6: Store 5 (number of word elements in the array) in the register CX

LHERE1 : _______ _______                 ; Step 7: Pop a number from the stack into the accumulator

       ADD _______ , ________         ; Step 8: Add content of the accumulator to content of VAR2

                                                          ; The register AX has a different result now. Explain why?

LOOP LHERE1

.EXIT

END