Introduction to Assembler Assignment

(total marks are 50 with 4 bonus marks possible)

This assignment is to be done in controlled conditions, similar to a test . It is an open book assignment and you may use any notes you have taken or the web pages used as the tutorial for this unit of work.

The assignment is designed to test your understanding of the way programs are loaded and run from RAM by the CPU. The answers to the assignment need to be written out or printed from the debug screen.

1.    What is RAM ? Explain what it is used for, how it is organised and how it relates to the CPU.     (4)

2.    Draw a diagram of the CPU and explain the significance and basic operation of the

a. ALU     b. Instruction Set     c. IP reg     d. General purpose regs    e. Control unit                             (6)

3.
a.    What is the machine code for adding the AX register to the BX register ?
b.    What happens if the number is bigger than FFFFh after the addition (bonus marks for a good answer) ?
c.    What is the machine code for subtracting BX from the AX register ?
d.    What happens if the answer is a negative number ? (bonus marks possible)                                 (4)(2)

4.    A small program is loaded into RAM using debug. Explain how this can be done using either the edit or assemble commands.                                                                                                                                     (4)

5.    When a register dump is done, how can you tell what address in RAM will be executed if the t or g command is given ? (bonus marks possible)                                                                                                (2)(2)

6.    You are to assemble the following sequence into RAM at address 0100h in whatever segment debug is using

     
    XXXX:0100 mov AX,0008
                          mov BX,0006
                          add AX,BX

    using the t command, trace through the program and write down the contents of AX, BX and IP after each trace.

    Stop when you have executed the add AX,BX command

    Explain in words what is happening during this sequence.                                                             (10)
     

7.    You are to load a message into RAM at offset 200h of about 12 or so characters terminated with ASCII 24h ($).
     
    Assemble the code in RAM at address 100 so that your message prints out on the screen when the program is run. You must use the correct interrupts.

    Write out your program and explain what each command is doing.                                                 (10)
     
     

8.    Write out the code for loading a number into the AX and BX registers from RAM, multiplying them together and writing the result back to RAM.
    Assemble your code at offset 100h

    Use 200h as the data segment.

    Test the code using two easy numbers in RAM

    Run the code and have it checked by me.

    Note, the instruction for loading a value from RAM into ax is mov ax,[0200]

    and to write to RAM is mov [0200],ax                                                                                                     (10)