CSC270 Example 6811 Program

From dftwiki3
Revision as of 08:42, 21 March 2011 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- ; compute the sum of the contents of an array (table) ; of 5 bytes. The result is stored in a variable called ; sum ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut 09:42, 21 March 2011 (EDT)



     ; compute the sum of the contents of an array (table) 
     ; of 5 bytes.  The result is stored in a variable called
     ; sum

                          ;--- data section ---
                          ORG   0000
     0000 02       table  FCB   2,3,4,1,7        ; create an array of 5 bytes
     0001 03
     0002 04
     0003 01
     0004 07
     0005 00       sum    FCB   0 


                   ;--- code section ---
                          ORG   0010
     0010 CE 00 00 START: LDX   #0000            ; IX = 0, address of 1st byte of array
     0013 A6 00           LDAA  0,X              ; ACCA = mem[0]
     0015 AB 01           ADDA  1,X              ; ACCA = ACCA + mem[1]
     0017 AB 02           ADDA  2,X              ; ACCA = ACCA + mem[2]
     0019 AB 03           ADDA  3,X              ; ACCA = ACCA + mem[3]
     001B AB 04           ADDA  4,X              ; ACCA = ACCA + mem[4]
     001D 97 05           STAA  05               ; sum = ACCA

     001F 7E FC 00        JMP   FC00             ; Restart the monitor (OS)