Professional Documents
Culture Documents
Coa Practical PDF
Coa Practical PDF
Coa Practical PDF
Decimal Addition
; Decimal Addition Program in 8085 Assembly Language
MVI A, 0AH ; Load A register with first decimal number (e.g., 10)
MOV B, A ; Move A to B for backup
ADD B ; Add B to A
HLT ; Halt
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
END
START:
MVI A, 20H ; Load the first number into accumulator A
MVI B, 10H ; Load the second number into register B
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
; 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
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
; 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
FIND_LOOP:
MOV A, M ; Load the next element of the array into accumulator A
; 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
EXIT:
HLT ; Halt the program