;TITLE SUM OF FIRST 10 NATURAL NUMBERS
MVI D,1 ;DATA
MVI A,0 ;SUM
MVI C,10 ;COUNTER
AGAIN: ADD D
INR D
DCR C ;COUNTER CHECK
JNZ AGAIN
STA 0000H ;STORE
THE SUM AT 0000H ADDRESS.
HLT
We can program this using only registers A and C. Register C acts as counter as well as data. Here is the program.
ReplyDeletemvi c,10
mvi a,0
again: add c
dcr c
jnz again
sta 0000h
hlt