Professional Documents
Culture Documents
Solution COAL Mid Term Updated
Solution COAL Mid Term Updated
Question 02: Consider the following code fragment. What are the contents of the ax, bx and cx registers
after the code fragment has been executed? Show your work. [3
marks]
.data
Var1 dw 5
Var2 dw 6
.code
mov ax, Var1
mov bx, ax
mov cx, ax+2
add bx, Var2
add cx, bx
mov ax, cx
Solution:
AX = 18
BX = 11
CX = 18
Question 03: Consider a C++ program with the following instructions: [3 marks]
int a , b ;
cin >> a ;
cin>> b ;
If(a < b){ cout<< a << " is greater"};
PMAS Arid Agriculture University Rawalpindi
University Institute of Information Technology
.data
.code
main proc
mov ax, @data
mov ds, ax
jmp ainput
jmp binput
ainput:
mov ah,1;
int 21h
mov bl,al
binput:
mov ah,1;
int 21h
mov bh,al
cmp bl,bh
jl agreater
agreater:
mov ah,2
mov dl,13
int 21h
mov ah,2
mov dl,10
int 21h
mov ah,2
mov dl,bl
int 21h
mov ah,9
lea dx,MSG
int 21h
cmp bh,bl
jg bgreater
PMAS Arid Agriculture University Rawalpindi
University Institute of Information Technology
jmp exit
bgreater:
mov ah,2
mov dl,13
int 21h
mov ah,2
mov dl,10
int 21h
mov ah,2
mov dl,bh
int 21h
mov ah,9
lea dx,MSG
int 21h
exit:
mov ah, 4ch
int 21h
main endp
end main
Question 04: consider that you have the following logical address for 8086 microprocessor’s instruction.
A4FBh : 4872h
find the physical address using the given logical address and then find the logical address with the
segment = 0008h along with the physical address computed. [3 marks]
Solution:
segment = A4FBh
offset = 4872h
physical address = (segment x 10h) + offset
physical address = A9822h
now, segment = 0008h and physical address = A9822h
So,
Logical address = (physical address) - (segment x 10h)
Logical address = A98A2
*****Good Luck*****