~ubuntu-branches/ubuntu/quantal/gnusim8085/quantal

« back to all changes in this revision

Viewing changes to doc/examples/sumofnumbers.asm

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2011-02-21 00:01:55 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110221000155-8k286v0kurbve3fp
Tags: 1.3.7-1
* New upstream release.
* debian/control
  - Update standards version to 3.9.1.
  - Reduce debhelper version required to 5 as no dh7 features are used.
  - Remove autotools-dev build-dep. Not needed anymore.
* debian/copyright
  - Update as per latest source.
* debian/rules
  - Exclude asm-guide.txt from compression as it is loaded by application.
* debian/source/format
  - Specify 1.0 source format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
 
 
5
;<Sum of Numbers>
 
6
 
 
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
 
11
jmp start
 
12
 
 
13
;code
 
14
 
 
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
 
18
 
 
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
 
24
        
 
25
        INR B      ;Update carry register
 
26
 
 
27
SAVE:     MOV C,A    ;Save sum
 
28
        INX H      ; point to next reading
 
29
        JMP nxtbyte ;Go back to get next reading
 
30
 
 
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
 
34
        MOV M,B
 
35
 
 
36
HLT