assembly midterm exam

Upload: khaled-sharif

Post on 04-Jun-2018

245 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Assembly Midterm exam

    1/10

    Zaid

    teishat

    uestion 1 :study the following program and determine contents of the registers listed in the pagebelow

    after executing the following program :

    .Model tiny

    . code

    . starup

    MOV AX, 5000h

    MOV ES, AX

    MOV AX, 6000h

    MOV BX, 7000h

    MOV CX, 8000h

    MOV DX, 9000h

    MOV DI, 0700h

    MOV BP, 0800h

    MOV SI, 0002h

    MOV SP, 6000h

    PUSH AX

    PUSH BX

    PUSH DX

    POP DX

    PUSH SI

    PUSH SX

    PUSH BP

    PUSH SP

    POP DI

    PUSH DI

  • 8/13/2019 Assembly Midterm exam

    2/10

    Zaid

    teishat

    POP SI

    POP BX

    POP AX

    POP BP

    .exit

    END

    What is the values of DI,BP,AX,DX and SP ?!

    Question 2 :

    Imagine we consrust an assembly program that consists of three assembly instructions to

    perform a certain job . the corresponding logical addressassociated with each instruction as

    shown below :

    0018:0020 Assembly Instruction 1

    0018:0023 Assembly Instruction 2

    0018:0026 Assembly Instruction 3; three bytes long

    Answer the following qwestions :

    (a) At which memory segment the above intsructions are stored ?

    (b) What are the physical addresses generated to fetch instruction 2 considering real

    mode memory addresses ?

    (c) What are the physical addresses gencrated to fetch instruction 3 considering

    protected mode memory addressing ? ( Consider an 80286prcessor that has 24-bit get

    further benefit from Appendix D .

  • 8/13/2019 Assembly Midterm exam

    3/10

    Zaid

    teishat

    Figure 1. part of global and local descriptor tables where all of the mentioned values are inhex

    Question 3 :Classify the following instructions according to their addressing modes?

    1) MOV CX,[1000H]2) MOV CX,[BX+SI+6000H]3) MOV [BX],AX4) MOV AL,[EBX+4*ECX]

    Question 4 :state whether each of following is valid or invalid in addition the major cause for that :

    1) MOV SS,DS

    Local Descriptor Table (L O T)

    Descriptor 1

    L O T: Descriptor 2 L O T : Descriptor 3

    00 00 00

    00 00 00

    FE FA FF

    10 10 20

    00 40 10

    00 30 10

    FF FF 00

    FF FF FF

    Global descriptor Table (G D T):

    Descriptor1

    G D T: Descriptor 2 G D T: Descriptor 2

    00 00 00

    00 00 00

    9F 9A 9E

    10 10 40

    00 10 10

    00 00 10

    11 22 66

    FF FF FF

  • 8/13/2019 Assembly Midterm exam

    4/10

    Zaid

    teishat

    2) MOV DX,CH3) MOV [BX],1234H4) MOV DX,[AX]5) MOV BH,[EBX+5*ECX]6) MOV CS,DX7) MOV CH,[XP+8000H]

    Question 5 :the following table shows the logical memory addresses along with their contents. You need

    to consider this table for answering questions below .

    (a) What will be the value of BX after exccuting following code ?MOV AX, 0C000h

    MOV DS, AX

    MOV BH, 30H

    MOV BI, 70H

    (b) What will be the contents of CX and DX after exccuting the following code ?MOV CH, [000Dh]

    MOV CL, [0006h]

    MOV DX, [0005H]

    (c ) What will be the contents of BP after executing the following code ?

    MOV SI,[000AH]

    MOV BX,[000EH]

    MOV BP,[BX+SI]

    Question 6 :Study the following Assembly program named Mid carefully , given that the starting offset

    address of the data segment DS is 0009H

    .Model small

    .data

    X DW 0004H

    Y DW 558CH

    Z DW 4FFCH

    K DW 0FFCBH

    .code

  • 8/13/2019 Assembly Midterm exam

    5/10

    Zaid

    teishat

    .startup

    MOV DI,OFFSET X

    MOV BX,X

    MOV DX,[BX+DI-2]

    MOV CX,Y[BX-2]

    .exit

    END

    Write down the value of registers DI,BX,DX and CX after executing this code above.

    Question 7 :

    The following variables are declared in the data segment , where DS= 1000H and the starting

    offset = 0020H

    .DATA

    DATA1 DW 11C2H

    DATA2 DW 264CH

    DATA3 DW 3FFCH

    DATA4 DB 40 DUP(ODEH)

    (a) What will be the content of DI register after executing the following instructions ?LEA DI,DATA1

    (b) How does the follownig instruction affect the data segment (DS) ?MOV WORD PTR [DI+4],0FFFFH

    QUESTION 8 :Find the equivalent assembly instructions for these machine instructions :

    898D0070H

    8CDAH

  • 8/13/2019 Assembly Midterm exam

    6/10

  • 8/13/2019 Assembly Midterm exam

    7/10

  • 8/13/2019 Assembly Midterm exam

    8/10

  • 8/13/2019 Assembly Midterm exam

    9/10

  • 8/13/2019 Assembly Midterm exam

    10/10