0% found this document useful (0 votes)
6 views2 pages

8085_Assembly_Programs

The document contains a series of 8085 assembly language programs for basic arithmetic and logical operations, including addition, subtraction, finding two's complement, exchanging memory contents, counting bits, checking even/odd status, multiplying numbers, finding the largest number in an array, and performing addition using indirect addressing. Each program is structured with comments explaining the purpose of each instruction. The programs utilize various addressing modes and control flow to achieve their respective tasks.

Uploaded by

tehminakhan9399
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)
6 views2 pages

8085_Assembly_Programs

The document contains a series of 8085 assembly language programs for basic arithmetic and logical operations, including addition, subtraction, finding two's complement, exchanging memory contents, counting bits, checking even/odd status, multiplying numbers, finding the largest number in an array, and performing addition using indirect addressing. Each program is structured with comments explaining the purpose of each instruction. The programs utilize various addressing modes and control flow to achieve their respective tasks.

Uploaded by

tehminakhan9399
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/ 2

8085 Assembly Language Programs

Add Two 8-bit Numbers (Direct Addressing Mode)


LDA 3000H ; Load first number from 3000H into Accumulator
MOV B, A ; Move it to register B
LDA 3001H ; Load second number from 3001H into Accumulator
ADD B ; Add the first number (stored in B)
STA 3002H ; Store the result in 3002H
HLT ; Halt the program

Subtract Two 8-bit Numbers (Direct Addressing Mode)


LDA 3000H ; Load first number into Accumulator
MOV B, A ; Store in B for later use
LDA 3001H ; Load second number into Accumulator
SUB B ; Subtract B (3000H - 3001H)
STA 3002H ; Store the result at 3002H
HLT ; Halt

Find Two's Complement of an 8-bit Number


LDA 3000H ; Load the number into Accumulator
CMA ; Complement the number (One's Complement)
ADI 01H ; Add 1 to get Two's Complement
STA 3001H ; Store result at 3001H
HLT ; Halt

Exchange Contents of Two Memory Locations


LDA 3000H ; Load first number into Accumulator
MOV B, A ; Store in register B
LDA 3001H ; Load second number into Accumulator
STA 3000H ; Store second number in 3000H
MOV A, B ; Move first number (from B) back to Accumulator
STA 3001H ; Store it in 3001H
HLT ; Halt

Count Number of 1s in an 8-bit Number


LDA 3000H ; Load the number
MOV B, A ; Copy to B
MVI C, 00H ; Initialize counter to 0

LOOP: RAR ; Rotate right (LSB goes to Carry)


JC INCR ; If Carry is set, increment count
JMP NEXT ; Otherwise, continue

INCR: INR C ; Increment count if Carry was set

NEXT: DCR B ; Decrement B (loop control)


JNZ LOOP ; Repeat until all bits are checked

STA 3001H ; Store the count in 3001H


HLT ; Halt
Check if a Number is Even or Odd LDA 3000H ; Load the number from memory into Accumulator
LDA 3000H ; Load the number ANI 01H ; AND the number with 01H (Check LSB)
ANI 01H ; AND with 01H to check the LSB JZ EVEN ; If result is 0, jump to EVEN section
JZ EVEN ; If result is 0, it's even
; If not zero, number is odd
MVI A, 01H ; Otherwise, it's odd
MVI A, 01H ; Load 01H into Accumulator (Odd)
JMP STORE STA 4000H ; Store result at 4000H
HLT ; Halt program
EVEN: MVI A, 00H ; Store 00H if even
EVEN:
MVI A, 00H ; Load 00H into Accumulator (Even)
STORE: STA 3001H ; Store the result STA 4000H ; Store result at 4000H
HLT ; Halt HLT ; Halt program

Multiply Two 8-bit Numbers Using Successive Addition


LDA 3000H ; Load first number
MOV B, A ; Copy to B (multiplier)
LDA 3001H ; Load second number (multiplicand)
MOV C, A ; Copy to C
MVI A, 00H ; Initialize Accumulator for result

LOOP: ADD C ; Add multiplicand


DCR B ; Decrease multiplier
JNZ LOOP ; Repeat until B becomes zero CHECK EVEN OR ODD USING INDIRECT METHOD
LXI H, 2000H ; Load the memory address of the number into HL
MOV A, M ; Move the number from memory into Accumulator
STA 3002H ; Store result at 3002H ANI 01H ; Perform AND operation with 01H (Check LSB)
HLT ; Halt LXI H, 2001H ; Load the result storage address (2001H)
MOV M, A ; Store result (00H = Even, 01H = Odd)
HLT ; Halt the program
Find Largest Number in an Array
LXI H, 3000H ; Load address of first number
MOV A, M ; Load first number
INX H ; Point to next location
MVI C, 04H ; Counter for 4 comparisons

LOOP: CMP M ; Compare with next number


JNC NEXT ; If A is greater, skip update
MOV A, M ; Else update largest number

NEXT: INX H ; Move to next number


DCR C ; Decrement counter
JNZ LOOP ; Repeat until all numbers checked

STA 3005H ; Store the largest number


HLT ; Halt

ADDITTION INDIRECT METHOD


LXI H, 2000H ; Load the address of the first number into HL register pair
MOV A, M ; Move the first number (at address 2000H) into Accumulator
INX H ; Increment HL to point to the next memory location (2001H)
ADD M ; Add the second number (at address 2001H) to Accumulator
INX H ; Increment HL to store the result in the next location (2002H)
MOV M, A ; Store the result at memory location 2002H
HLT ; Halt the program

Write SUB instead of ADD for subtraction program

You might also like