Alp 9,10, 11
Alp 9,10, 11
Algorithm:
Step1: Start the program
Step2: Initialize C register as Zero
Step3: Load the 1st data divedent into accumulator
Step4: Load the 2nd data divisor into register B
Step5: Compare the value of A and B
Step6: If A< B, carry flag is set and move to step 9
Step7: If A>B, Subtract B from A
Step8: Increnment C, Jump to step 5
Step9: Store the value of result(Reamaindar) into memory location
Step10: Move the value of C into accumulator
Step:11: store the value of accumulator(quotient) into memory location.
Step12: stop
Start
If A< B
Yes
No
Subtract B from A
Increnment C
Stop
Program:
MVI C, 00
MVI A, 09
MVI B, 02
LOOP2:
CMP B
JC LOOP1
SUB B
INR C
JMP LOOP2
LOOP1:
STA 8050
MOV A,C
STA 8051
HLT
Result after Assembling:
Address OP Code
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
800A
800B
800C
800D
800E
800F
8010
8011
8012
8013
8014
8015
8016
8050
8051
Q.10. Write a program to find smallest element of an array and store it in memory
location.
Algorithm:
Step1: Start the microprocessor.
Step2: Store bthe address of first element to HL register pair
Step3: Store the block size to C
Step4: Decrement C.
Step5: Load the first number from memory
Step6: Increment the address of HL pair
Step7: Compare the incremented memory location to accumulator
Step8: Check for carry
Step9: If carry is not there move the memory to accumulator
Step10: If carry is there, decrement C
Step11: Check C for Zero
Step12: If C is not zero repeat from step 6
Step13: If C is zero, store the smallest number from accumulator to memory.
Step14: Stop the execution.
Flowchart:
Start
Decrement C
HL=HL+1
M<A True
Carry
False
A=M
C=C–1
False
C=0
True
End
Program:
LXI H, 8050
MVI C, 05
DCR C
MOV A, M
REPEAT: INX H
CMP M
JC SKIP
MOV A, M
SKIP: DCR C
JNZ REPEAT
STA 8055
HLT
Result after Assembling:
Address OP Code
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
800A
800B
800C
800D
800E
800F
8010
8011
8012
8013
8014
8050
8051
8052
8053
8054
8060
Q.11. Write a program to find largest element of an array and store it in memory
location.
Algorithm:
Step1: Start the microprocessor.
Step2: Store bthe address of first element to HL register pair
Step3: Store the block size to C
Step4: Decrement C.
Step5: Load the first number from memory
Step6: Increment the address of HL pair
Step7: Compare the incremented memory location to accumulator
Step8: Check for carry
Step9: If carry is there move the memory to accumulator
Step10: If no carry, decrement C
Step11: Check C for Zero
Step12: If C is not zero repeat from step 6
Step13: If C is zero, store the largest number from accumulator to memory.
Step14: Stop the execution.
Flowchart:
Start
Decrement C
HL=HL+1
M<A False
Carry
True
A=M
C=C–1
False
C=0
True
End
Program:
LXI H, 8050
MVI C, 05
DCR C
MOV A, M
REPEAT: INX H
CMP M
JNC SKIP
MOV A, M
SKIP: DCR C
JNZ REPEAT
STA 8060
HLT
Result after Assembling:
Address OP Code
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
800A
800B
800C
800D
800E
800F
8010
8011
8012
8013
8014
8050
8051
8052
8053
8054
8060