Sums of five lists

Description

Published by Dave Britten in MoHPC - General Software Library

This program lets you quickly accumulate and sum five separate lists/columns of numbers by using the five matrices. In addition to the matrices, the program occupies 11 registers and only uses storage registers 0, 1, and I, so it can be run with DIM (i) = 0 to store up to 54 list items across the five lists.

Usage

Press f MATRIX  0 to clear all data.

To append an item to list A, B, C, D or E enter the number into X and press f A , f B , f C , f D or f E respectively. Alternatively, enable USER mode with f USER and press A , B , C , D or E directly.

If flag 1 is clear (g CF 1), the matrix descriptor for the list that the number was appended to will be left in X, showing the name of the matrix and the new count of items.

If flag 1 is set (g SF 1), the list's matrix descriptor will be displayed briefly, and then the new total returned in X. (This option increases the processing time for adding an item to the list, as the sum has to be recalculated on each new entry.)

To calculate the sum of the list whose matrix descriptor is in X, press GSB 9.

To calculate the sums of all lists in sequence, press GSB 1. The program will briefly display the first list's matrix descriptor, followed by the sum of that list. Press R/S to show the next list. Empty lists, or lists with a sum of 0 will be skipped.

Example

Calculate the sums of two lists:

List 1: 250, 150, 525, 275, 300
List 2: 10, 10, 2, 100, 10

(User input shown in strong, displayed results in normal font.)

f MATRIX 0
g CF 1
f USER (if USER mode is not already enabled)
250 AA 1 1
150 AA 2 1
525 AA 3 1
275 AA 4 1
300 AA 5 1
10 Bb 1 1
10 Bb 2 1
2 Bb 3 1
100 Bb 4 1
10 Bb 5 1
GSB 1 → A 5 1 (briefly)1,500.0000
R/Sb 5 1 (briefly)132.0000
R/S0.0000 (listing is finished)

Note that items may be added to the lists in any order, i.e. you aren't required to first fill list A, then B, etc. as is done in the example.

Program Resources

Labels

Name Description Name Description
 A Add value in X register to list A  0 #
 B Add value in X register to list B  1 Sum a each list
 C Add value in X register to list C  2 #
 D Add value in X register to list D  8 #
 E Add value in X register to list E  9 Sum of list in X register

Storage Registers

Name Description
I

Flags

Number Description
1 0: show matrix and the new count of items 1: show matrix descriptor briefly, then the new total

Program

Line Display Key Sequence Line Display Key Sequence Line Display Key Sequence
000 024 34 x↔y 048 43 32 g RTN
001 42,21,11 f LBL A 025 42,23,25 f DIM I 049 42,21, 1 f LBL 1
002 45,16,11 RCL MATRIX A 026 44,43,24 STO g (i) 050 45,16,11 RCL MATRIX A
003 22 0 GTO 0 027 33 R⬇ 051 32 2 GSB 2
004 42,21,12 f LBL B 028 33 R⬇ 052 45,16,12 RCL MATRIX B
005 45,16,12 RCL MATRIX B 029 45 25 RCL I 053 32 2 GSB 2
006 22 0 GTO 0 030 43, 6, 1 g F? 1 054 45,16,13 RCL MATRIX C
007 42,21,13 f LBL C 031 22 2 GTO 2 055 32 2 GSB 2
008 45,16,13 RCL MATRIX C 032 43 32 g RTN 056 45,16,14 RCL MATRIX D
009 22 0 GTO 0 033 42,21, 9 f LBL 9 057 32 2 GSB 2
010 42,21,14 f LBL D 034 44 25 STO I 058 45,16,15 RCL MATRIX E
011 45,16,14 RCL MATRIX D 035 45,23,25 RCL DIM I 059 32 2 GSB 2
012 22 0 GTO 0 036 33 R⬇ 060 43 35 g CLx
013 42,21,15 f LBL E 037 43 20 g x=0 061 43 32 g RTN
014 45,16,15 RCL MATRIX E 038 43 32 g RTN 062 42,21, 2 f LBL 2
015 42,21, 0 f LBL 0 039 33 R⬇ 063 32 9 GSB 9
016 44 25 STO I 040 42,16, 1 f MATRIX 1 064 43 20 g x=0
017 33 R⬇ 041 0 0 065 43 32 g RTN
018 45,23,25 RCL DIM I 042 36 ENTER 066 34 x↔y
019 43 20 g x=0 043 42,21, 8 f LBL 8 067 42 31 f PSE
020 13 10ˣ 044 40 + 068 34 x↔y
021 34 x↔y 045 u 45 24 USER RCL (i) 069 31 R/S
022 1 1 046 22 8 GTO 8 070 43 32 g RTN
023 40 + 047 40 +