Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: May 2013

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