Faculty of Information Science & Technology
Faculty of Information Science & Technology
Group Members:
No. Student ID Student name
Work Distribution
Question Member
1 LOH MIN YI
2 TAN SOO CHIN
3 LOONG JIEHYI
4 TAN SOO CHIN
5 LOONG JIEHYI
1
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
1. Write a program that finds the factorial of a number stored in memory address 1000H and
stores the result in memory location 1001H.
Input:
1000H = 04H
Output:
1001H = 18H
Assembly Program:
LDA 1000H
MOV C,A
MOV B,A
DCR C
BACK: XRA A
MOV E,C
CALL MULTI
MOV B,A
DCR C
JNZ BACK
STA 1001H
HLT
MULTI: NOP
LOOP: ADD B
DCR E
JNZ LOOP
RET
2
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
Flowchart:
3
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
2. Find the number of negative elements (most significant bit 1) in a block of data. The length of
the block is in memory location 1001H and the block itself begins in memory location 1002H.
Store the number of negative elements in memory location 1000H.
Input:
1001H = 03H
1002H = 13H
1003H = 9AH
1004H = C4H
Output:
1000H = 02H
Assembly Program:
LDA 1001H
MOV C, A
MVI B, 00
LXI H, 1002H
BACK: MOV A, M
ANI 80H
JZ SKIP
INR B
SKIP: INX H
DCR C
JNZ BACK
MOV A, B
STA 1000H
HLT
4
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
Flowchart:
5
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
3. Write an assembly language program to separate even numbers from the given list of 50
numbers and store them in another list starting from 2300H. Assume starting address of 50
number list is 2200H.
Assembly Program:
LXI H, 2200H
LXI D, 2300H
MVI C, 32H
BACK: MOV A, M
ANI 01H
JNZ SKIP
MOV A, M
STAX D
INX D
SKIP: INX H
DCR C
JNZ BACK
HLT
6
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
Flowchart:
7
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
4. Write a program to multiply two numbers stored in memory locations 1000H and 1001H and
store the result in memory location 1002H. the multiplication should be performed using
multiple addition, e.g. 7*3 = 7+7+7, 6*5 = 6+6+6+6+6.
Input:
1000H = 07H
1001H = 03H
Output:
1002H = 15H
Assembly Program:
LDA 1001H
MOV C, A
LDA 1000H
MOV B, A
MVI A, 00H
LOOP: ADD B
DCR C
JNZ LOOP
STA 1002H
HLT
8
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
Flowchart:
Start
NO
Is counter = 0 ?
YES
End
9
COMPUTER ARCHITECTURE AND ORGANIZATION TAO1121
5. Write a program to find the largest number in a block of memory and store it in memory
location 1000H. The size of the block is stored in memory location 1001H and the block starts
at memory address 1002H.
Input:
1001H = 05H
1002H = 16H
1003H = 3AH
1004H = A5H
1005H = FAH
1006H = 99H
Output:
1000H = FAH
Assembly Program:
LDA 1001H
MOV C, A
LXI H, 1002H
MOV B, M
DCR C
LOOP: INX H
MOV A, M
CMP B
JC SKIP
MOV B, A
SKIP: DCR C
JNZ LOOP
MOV A, B
STA 1000H
HLT
Flowchart:
10