UNIVERSITI TEKNOLOGI MARA
LAB TEST
COURSE : COMPUTER ORGANIZATION
COURSE CODE : CSC159
SEMESTER : MAC 2021 – OCT 2021
TIME : 9.00 AM – 12.00 PM
INSTRUCTIONS TO CANDIDATES:
1. Answer ALL questions within 3 hours.
This question paper consists of FOUR (4) parts.
QUESTIONS MARKS STUDENT SCORE
PART A 15
PART B 10
QUESTION 1 5
PART C
QUESTION 2 5
PART D QUESTION 1 10
TOTAL 45
2. You are NOT allowed to discuss/share/disseminate the questions and answers
amongst your classmates/course mates.
3. You are ALLOWED to use any EMU8086 to write/compile/debug your program.
4. If your answer is similar to your classmates/course mates, further actions can be
taken by your lecturer, and you will be penalised.
5. Submit your answer in PDF format.
NAME:
MATRIC NO:
GROUP:
LECTURER:
DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO
CONFIDENTIAL CS/JULY2021/CSC159
PART A (10 marks):
Answer TRUE (T) or FALSE (F) for the following statements.
Write your answers at ANSWER PART A.
1. An assembler is a program that converts or translates source-code programs in
assembly language into machine language (object code).
2. An instruction may contain zero, one, two or three operands.
3. The statement mov total, count is valid if it is in 16-bit size.
4. Div (divide) instruction performs division on unsigned numbers. If the source
operand is 16-bit, as in div bx, the quotient is stored in the bx, while the remainder
is stored in the dx.
5. The following assembly language program sets the values for Carry Flag, Sign Flag
and Auxiliary Flag to ONE (1)
Mov cx, 10d
Mov dx, 12d
Sub cx, dx
6. Immediate data cannot be used as an operand in the NOT instructions.
7. Given BH = 11h, the value of BX after execution of instruction AND BH, 88h is
0000 0000 0000 0000.
8. SAR instruction shifts each bit in the destination operand to the right and will replace
empty space with '0'.
9. Execution of cmp and test instruction do not change the value in the destination
operand and also do not affect the status flags.
10. Jump if CS is zero (jcxz) instruction transfer program to a label only if conditions
CX>0 is met.
ANSWER PART A
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
2
CONFIDENTIAL CS/JULY2021/CSC159
PART B (15 MARKS)
Write your answer at ANSWER PART B
1. What is type of the addressing mode of the below instruction?
MOV BX, [DX]
A. Immediate operand
B. Register operand
C. Memory operand
D. Index operand
2. Which of the following is CORRECT statement about status flag?
A. Auxiliary flag will set to zero if there is a borrow from bit 4 to bit position 3.
B. Register AH is DCh and AL is ABh, so the sign flag for register AX is negative.
C. The parity flag will reset if the result of AX equal to A781h.
D. Result arithmetic for register DX is 0080h, then the lower byte will reset the
overflow flag in sign number.
3. The statement below is FALSE about the mov (move) instructions EXCEPT:
A. MOV instruction copies data from 8-bit memory operand to 16-bit register.
B. The destination operand may be either a register, a memory operand or a
number.
C. The destination and source operand will be changed during mov instruction
execution.
D. Data can transferred to the destination operand from immediate value.
4. Given the following assembly language:
Mov dx,02F1
Mov dl,EE
Mov bh, CD
Xchg dh, bl
What are the value for register BX and DX?
A. BX= CD00 ; DX = 02EE
B. BX= CD02 ; DX = 00EE
C. BX= CDEE ; DX = 02F1
D. BX= CD02 ; DX = 00F1
3
CONFIDENTIAL CS/JULY2021/CSC159
5. Which instruction can transform segment program below into assembly language?
A = Temp
B=A
Temp = B
A. Mov AX,A
Mov BX,B
Xchg AX,BX
B. Mov AX,temp
Mov BX,AX
Mov temp,BX
Xchg AX,BX
C.
Mov temp, AX
Mov AX, BX
Mov BX, temp
D. Xchg AX,BX
Mov A,temp
Mov B,A
Mov temp,B
Xchg AX,BX
6. Y = b2 – 4ac
Choose the BEST arithmetic instructions to perform the above mathematical
equation (assume that a, b and c are one word long and are positive numbers):
I. Mov
II. Sub
III. Imul
IV. Mul
A. II and III
B. II and IV
C. I, II and III
D. I, II and IV
7. Identify the BEST reason for an Overflow Flag to be set to ONE (1) for an 8-bit
imul instruction.
A. The upper half of the multiplication is the sign extension of the lower half.
B. The result of the multiplication is out of range (-128d to +127d).
C. The result of the multiplication is within range (-128d to +127d).
D. The result of the multiplication produces a negative value.
4
CONFIDENTIAL CS/JULY2021/CSC159
8. The inc (increment) instruction has several features that distinguish it from the
add (addition) instruction. According to the list below, identify the different features
of inc (increment) instructions:
I. inc (increment) instruction affects all status flags except the Carry Flag.
II. The execution of inc (increment) instruction is faster compared to the
execution of add (addition) instruction.
III. The execution of inc (increment) instruction is slower compared to the
execution of add (addition) instruction.
IV. inc (increment) instruction is frequently applied in decrementing loop control
variables.
A. I and II
B. I and III
C. II and IV
D. III and IV
9. The statement below is TRUE about the sub (subtraction) instructions EXCEPT:
A. The format for sub instruction is: sub destination, source
B. The execution of a sub instruction affects all the status flags.
C. Immediate values are allowed to be placed as the destination operand.
D. sub instructions can be used to subtract both signed and unsigned numbers.
10. Which of the following instruction does NOT affect the destination operand?
A. SAR
B. MOV
C. CMP
D. ROL
11. Based on the program segment below, what is the value of the AX register and
Parity Flag (PF) after XOR instruction is executed?
mov AL,4Bh
XOR AL,2Ah
A. AX=6100, PF=0
B. AX=0061, PF=0
C. AX=002A, PF=1
D. AX=0061, PF=1
5
CONFIDENTIAL CS/JULY2021/CSC159
12. The statement below is TRUE about the shift instructions EXCEPT:
A. mov CL, 4
sal AX,CL is equal AX*24.
B. mov CL, 3
shr ax, CL is equal AX/23.
C. mov CL,8
sar AX, CL is equal AX/28.
D. mov CL, 2
shl AX,CL is equal AX/22
13. Which of the following instructions will turn on the Carry Flag once it has been fully
executed?
A. mov al, 34h
mov cl, 03h
rol al, cl
B. mov al, 34h
mov cl,02h
rol al,cl
C. mov al, 34h
rol al,1
D. mov al, 34h
mov cl,05h
rol al,cl
14. Based on the program segment below, which statements are CORRECT about
assembly language instruction?
Num1 db 88h
mov AL, 88h
cmp AL, Num1
I. The execution of cmp instruction perform operation sum AL, Num1.
II. The execution of cmp instruction do change the value in the destination
operand.
III. The execution of cmp instruction will make Zefo Flag become 1 (ZF=1).
IV. The execution of cmp instruction will give value for AX=0088h.
A. I, II and III
B. I, II and IV
C. I, III and IV
D. II, III and IV
6
CONFIDENTIAL CS/JULY2021/CSC159
15. Based on the program segment below, which statements are INCORRECT about
assembly language instruction?
mov ax, 20h
mov cx, 03h
jmp REPEAT
REPEAT:
add ax, 2h
xchg ah, al
loop REPEAT
add ax, 50h
exit
A. At loop REPEAT, register CX will be decremented by 1 and program control is
transferred to label REPEAT.
B. After the loop ends, program execution will continue at add ax, 50h
instruction.
C. The loop stops when CX>0 AND Zero Flag (ZF)=1.
D. The loop will be carried out for 3 times until the loop ends.
ANSWER PART B
ANSWER PART B
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
7
CONFIDENTIAL CS/JULY2021/CSC159
PART C
QUESTION 1
Questions (a) to (e) are related to each other.
Write an assembly language instruction based on each statement below:
(5 MARKS)
a) Declare a 16-bit of storage for variable named sum and initialize it (in hexadecimal
format) to value 4660d.
b) Declare a 8-bit of storage for variable named data1 and initialize it to 55.
c) Transfer 1111111110000000 to general purpose register using hexadecimal
format.
d) Total the lower byte of register from data1 and assign it in variable sum.
e) What is the content of variable sum.
8
CONFIDENTIAL CS/JULY2021/CSC159
QUESTION 2
Convert the following arithmetic expression into assembly language instructions. A,B
and C are one byte long variables and value for A=1210 , B=3010 and C=1510 .
FinalAnswer in word size.
FinalAnswer= A+(B*C)
(5 MARKS)
9
CONFIDENTIAL CS/JULY2021/CSC159
PART C
QUESTION 3
You are required to write a complete assembly language based on the given flowchart:
START
• Declare 3 variables; value1, value2 and
finalAnswer
• Each variable must use the db directive for
declaration purpose
• Assign the value of -100d in the variable value1
• Assign the value of -25d in the variable value2
• Assign the value zero in the variable finalAnswer
**the assigned values must be in hexadecimal
• Transfer data in value1 to AL register
• Transfer data in value2 to BL register
• Compare contents in both registers; AL and BL
Is the result of
YES NO
comparison
produces a
negative
value?
• Perform the logical or operation
Conditional jmp to MODULE1: between AL and BL registers
• Perform the rotate carry left • Perform the one’s complement
five times for BL register negation towards the result of
logical or performed earlier
• Assign the result of rotation to
the variable finalAnswer • Assign the result of one’s
complement negation to the
variable finalAnswer
END
(10 MARKS)
10
CONFIDENTIAL CS/JULY2021/CSC159
END OF QUESTION PAPER
11