1
;Copyright (C) 2010 Kirantej J L <kirantej1920@gmail.com>
2
;Distributed under same license as rest of the program i.e. GPL v2 or later.
3
;See COPYING file for license text.
7
; This program reads the numbers from the memory location 50 till it
8
;finds 00 (end of input) and then sums up and stores the result in
9
;0080H(LOB),0081H(HOB) respectively.
10
; this program demonstrates 1) comparision and 2) addition
15
start: LXI H,50 ;set up HL as memory pointer
16
MVI C,00H ;clear C to save sum
17
MOV B,C ;Clear B to save carry
19
nxtbyte: MOV A,M ; Transfer current reading to (A)
20
CPI 00h ;Is it last reading
21
JZ OUTPUT ;If yes go to output section
22
ADD C ;Add previous sun to accumulator
23
JNC SAVE ; Skip CY register if there is no carry
25
INR B ;Update carry register
27
SAVE: MOV C,A ;Save sum
28
INX H ; point to next reading
29
JMP nxtbyte ;Go back to get next reading
31
OUTPUT: LXI H,80H ;Point to 080H memory location
32
MOV M,C ;Store low-order byte of sum in 080h
33
INX H ; ;Point to 081H memory location