The Programming Project: Assembly Level Language
Showing posts with label Assembly Level Language. Show all posts
Showing posts with label Assembly Level Language. Show all posts

Sunday, April 6, 2014

8085 Programming


Program to ADD the 8-bits N numbers stored sequentially from m/m location 0001H, the value of N being stored at 0000H if D6 is 1
LXI H, 0000H
MOV B,M
XRA A
MOV D,A ; To store the sum
MOV E,A ; To store the carry
INX H ; Pointing to the first 8-bit number
LOOP: MOV A,M
ANI 40H ****
CPI 40H
JNZ SKIP
MOV A,M
ADD D
MOV D,A
JNC SKIP
INR E
SKIP: INX H
DCR B
JNZ LOOP
LXI H, 2000H
MOV M,D ; Store the sum at 2000H
INX H
MOV M,E ; Store the carry at 2001H
RST5

****
D7D6D5D4D3D2D1D0
40H 0 1 0 0 0 0 0 0 AND operation
0 1 0 0 0 0 0 0 40H

Monday, June 10, 2013

Interchanging specific bits

There are N bytes stored from m/m location 0001H. The value of N is stored in 000H. Write an 8085 program to interchange the bits D2 and D6 and store them into the m/m locations starting from 0010H.

LXI H,0000H
MOV B,M
INX H
LXI D,0010H
XRA A
MOV C,A
LOOP: MOV A,M
ANI 0EDH
ADD C
MOV C,A
MOV A,M
ANI 02H
RLC
RLC
RLC
ADD C
MOV C,A
MOV A,M
ANI 10H
RRC
RRC
RRC
ADD C
MVI C,00H
STAX D
INX H
INX D
DCR B
JNZ LOOP
HLT


Saturday, May 25, 2013

One's Compliment

To find 1's compliment without complimenting the accumulator or using XOR in 8085 Assembly Language

LDA 0000H
MVI B,09H
LOOP: RAR
CMC
DCR B
JNZ LOOP
STA 0001H
HLT

Tuesday, May 14, 2013

Sum of numbers with specified condition


N numbers stored consecutively from 0001H. The value of N stored at 0000H. Find the sum of the numbers whose 6th bit is 1 and store the sum and carry at 0010H, 0011H respectively

LXI H,0000H
MOV B,M
XRA A
MOV D,A
MOV E,A
INX H
LOOP: MOV A,M
ANI 40H
CPI 40H
JNZ SKIP 
MOV A,M
ADD D 
MOV D,A
JNC SKIP
INR E
SKIP: INX H
DCR B
JNZ LOOP
LXI H,0010H
MOV M,D 
INX H
MOV M,E 
HLT

Wednesday, May 1, 2013

Factorial in 8085 Programming


To find the factorial of n <=6 stored at 0000H. Result stored at memory location 0001H

LDA 0000H
MOV B,A
CPI 00H
JZ LAST1
CPI 01H
JZ LAST1
XRA A
MOV D,B
DCR B
MOV C,B
MOV E,C
LOOP: ADD  D
DCR C
JNZ LOOP
MOV D,A
XRA A
DCR E
MOV C,E
DCR B
JNZ LOOP
MOV A,D
STA 0001H
JMP LAST
LAST1: MVI A,01H
STA 0001H
LAST: HLT

Tuesday, April 30, 2013

Program to add 16 bit numbers in 8085


Two 16 bits number 2498H and 54A1H is to added the lower 8-bit sum stored at 0000H, higher 8-bit sum at 0001H and the carry at 0002H

LXI H,2498H
LXI D,54A1H
XRA A
MOV B,A
MOV A,E
ADD L
STA 0000H
MOV A,D
ADC H
JNC SKIP
INR B
SKIP: STA 0001H
MOV A,B
STA 0002H
HLT


Thursday, March 28, 2013

M#1


Two 8-bits numbers (say x,y) are stored in memory location 0000H and 0001H.This program finds the value of 2(x*y) and stores the result at 0002H and 0003H.
First we add x with itself y times to get x*y, the sum is stored in register D and carry in register E(if any). Then the byte is register D is added twice and if any carry is generated is stored in register C, finally the carry in register E is added twice withe itself and then with C to get the result
LXI H,0000H
MOV B,M
INX H
MOV C,M
XRA A
MOV D,A
MOV E,A
LOOP: ADD B
JNC SKIP
INR E
SKIP: DCR C
JNZ LOOP
MOV D,A
XRA A
MOV C,A
MVI B,02H
LOOP1: ADD D
JNC SKIP1
INR C
SKIP1: DCR B
JNZ LOOP1
STA 0002H
MVI B,02H
XRA A
LOOP2: ADD E
DCR B
JNZ LOOP2
ADD C
STA 0003H
HLT