0% found this document useful (0 votes)
14 views5 pages

Coa Practical PDF

Uploaded by

Vinay Kumar
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)
14 views5 pages

Coa Practical PDF

Uploaded by

Vinay Kumar
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/ 5

1. Write a program using 8085 Assembly language.

Decimal Addition
; Decimal Addition Program in 8085 Assembly Language

ORG 0000H ; Start address

MVI A, 0AH ; Load A register with first decimal number (e.g., 10)
MOV B, A ; Move A to B for backup

MVI A, 05H ; Load A register with second decimal number (e.g., 5)

ADD B ; Add B to A

MOV C, A ; Move result to C register

HLT ; Halt

END ; End of program

2. HexeDecimals
ORG 0000H ; Set origin to 0000H

START:
MVI A, 0AH ; Load 0AH (10 in decimal) into accumulator A
MVI B, 05H ; Load 05H (5 in decimal) into register B
ADD B ; Add contents of register B to accumulator A
MOV C, A ; Move result to register C

HLT ; Halt the program

END

3. Subtraction of two Numbers


ORG 0000H ; Origin of the program

START:
MVI A, 20H ; Load the first number into accumulator A
MVI B, 10H ; Load the second number into register B

SUB B ; Subtract the second number from the first number

; The result is stored in the accumulator A

HLT ; Halt the program

END ; End of the program

4. Write a program using 8085 mu p for addition & substruction of two BCD No's.
ORG 0000H ; Origin of the program

START:
MVI A, 65H ; First BCD number (65 in BCD = 101 in binary)
MVI B, 27H ; Second BCD number (27 in BCD = 0100111 in binary)

; Addition
MOV C, A ; Copy first number to register C
MOV A, B ; Move second number to accumulator A
ADD C ; Add the numbers
DAA ; Decimal Adjust Accumulator after addition

; Display result of addition


; Here you would send the result to an output device or display

; Subtraction
MOV C, A ; Copy first number to register C
MOV A, B ; Move second number to accumulator A
SUB C ; Subtract the numbers
DAA ; Decimal Adjust Accumulator after subtraction

; Display result of subtraction


; Here you would send the result to an output device or display

HLT ; Halt the program

END ; End of the program

5. Write a program to perform multiplication and division of two 8 bit numbers


ORG 0000H ; Origin of the program

START:
MVI A, 12H ; First 8-bit number (12 in decimal)
MVI B, 0AH ; Second 8-bit number (10 in decimal)

; Multiplication
MOV C, A ; Copy first number to register C
MOV A, B ; Move second number to accumulator A
MVI D, 00H ; Initialize D register to 0 for result
MVI E, 08H ; Set loop counter to 8 (8 bits)
MULT_LOOP:
RLC ; Rotate left accumulator through carry
JNC NOT_ADD; If carry is not set, skip addition
ADD C ; Add first number to result in register D
NOT_ADD:
DCR E ; Decrement loop counter
JNZ MULT_LOOP ; Continue looping until all bits are processed

; Display result of multiplication


; Here you would send the result to an output device or display

; Division
MOV A, C ; Move result of multiplication to accumulator A
MOV B, 03H ; Divisor (3 in decimal)
MVI C, 00H ; Initialize quotient to 0
MVI D, 08H ; Set loop counter to 8 (8 bits)
DIV_LOOP:
RLC ; Rotate left accumulator through carry
CMP B ; Compare A and B (divisor)
JC NOT_SUB ; If A is less than B, skip subtraction
SUB B ; Subtract B from A
INR C ; Increment quotient
NOT_SUB:
DCR D ; Decrement loop counter
JNZ DIV_LOOP ; Continue looping until all bits are processed

; Display result of division


; Here you would send the quotient to an output device or display

HLT ; Halt the program

END ; End of the program

6. Write a program to find the largest and smallest no in the array.


ORG 0000H ; Origin of the program

MVI H, 00H ; Initialize HL pair to point to the beginning of the array


MVI L, 05H ; Assuming array starts at memory location 0500H

; Load the first element of the array into accumulator A


MOV A, M
MOV C, A ; Initialize smallest number with the first element
MOV B, A ; Initialize largest number with the first element

INX H ; Move to the next element of the array


DCR L ; Decrement array size counter

FIND_LOOP:
MOV A, M ; Load the next element of the array into accumulator A

; Compare with current smallest number


CMP C
JC NOT_SMALL ; If A is greater than or equal to C, skip updating smallest number
MOV C, A ; Update smallest number
NOT_SMALL:

; Compare with current largest number


CMP B
JNC NOT_LARGE ; If A is less than or equal to B, skip updating largest number
MOV B, A ; Update largest number
NOT_LARGE:

INX H ; Move to the next element of the array


DCR L ; Decrement array size counter
JNZ FIND_LOOP ; Continue looping until all elements are processed

; Display result
; Now, smallest number is in register C and largest number is in register B
; You would send these values to an output device or display
HLT ; Halt the program

END ; End of the program


7. Write a program to arrange an array of Dates in ascending and descending Number
ORG 0000H ; Origin of the program

MVI H, 00H ; Initialize HL pair to point to the beginning of the array


MVI L, 05H ; Assuming array starts at memory location 0500H

; Load the array into registers


MOV A, M ; Load the first element of the array into accumulator A
MOV B, A ; Initialize the smallest number with the first element
MOV C, A ; Initialize the largest number with the first element
INX H ; Move to the next element of the array

; Find the smallest and largest dates


DCR L ; Decrement array size counter
JC EXIT ; If array size is 1, exit
FIND_LOOP:
MOV A, M ; Load the next element of the array into accumulator A

; Compare with current smallest date


CMP B
JC NOT_SMALL ; If A is greater than or equal to B, skip updating smallest date
MOV B, A ; Update smallest date
NOT_SMALL:

; Compare with current largest date


CMP C
JNC NOT_LARGE ; If A is less than or equal to C, skip updating largest date
MOV C, A ; Update largest date
NOT_LARGE:

INX H ; Move to the next element of the array


DCR L ; Decrement array size counter
JNZ FIND_LOOP ; Continue looping until all elements are processed

; Ascending order sorting


LXI H, 0500H ; Point to the beginning of the array
MOV L, C ; Store the largest date at the last position
MOV M, C
INX H
MOV A, M
MOV M, B ; Store the smallest date at the first position
LXI H, 0501H ; Point to the second position of the array
MOV M, A

; Descending order sorting


LXI H, 0500H ; Point to the beginning of the array
MOV L, B ; Store the smallest date at the last position
MOV M, B
INX H
MOV A, M
MOV M, C ; Store the largest date at the first position
LXI H, 0501H ; Point to the second position of the array
MOV M, A

; Display the sorted array


; Here you would send the array to an output device or display

EXIT:
HLT ; Halt the program

END ; End of the program

You might also like