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

The Programming Project: Sum of numbers with specified condition

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

No comments:

Post a Comment