0% found this document useful (0 votes)
27 views12 pages

Alp 9,10, 11

The document describes algorithms and programs to find the minimum and maximum elements of an array in 8-bit assembly language. It provides step-by-step algorithms and flowcharts for finding the minimum and maximum values and storing them in memory. Code segments are given that implement the algorithms to find the minimum and maximum values.

Uploaded by

Yogendra Kshetri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views12 pages

Alp 9,10, 11

The document describes algorithms and programs to find the minimum and maximum elements of an array in 8-bit assembly language. It provides step-by-step algorithms and flowcharts for finding the minimum and maximum values and storing them in memory. Code segments are given that implement the algorithms to find the minimum and maximum values.

Uploaded by

Yogendra Kshetri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Q.9. Perform 8 bit division of given two numbers.

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

Initialize C register as zero for quotient

Load the first data dividend into


accumulator

Load the second data divisor into register B

Compare the value of A and B

If A< B
Yes

No
Subtract B from A

Increnment C

Store the value of result(Reamaindar)


into memory location

Move the value of C into


accumulator

Store the value of result(Quotient)


into memory location

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

HL= Address of first element

C=Block size of data

Decrement C

A=Load from memory pointed by HL pair

HL=HL+1

Compare the current memory with accumulator

M<A True
Carry

False
A=M

C=C–1

False
C=0

True

Store the largest number from accumulator to memory

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

HL= Address of first element

C=Block size of data

Decrement C

A=Load from memory pointed by HL pair

HL=HL+1

Compare the current memory with accumulator

M<A False
Carry

True
A=M

C=C–1

False
C=0

True

Store the largest number from accumulator to memory

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

You might also like