Commodore PET User Manual page 231

Table of Contents

Advertisement

All~99991
Bl
1~99991
Let's look step by step at how the multiplication works. using the values of
AH. AL. BH. and BL from our example:
AH
1~99991
BH
1~99991
The first multiplication is BL
x
AL;
~~
xêEI
~
89991
89991
89991
89991
99980001
The second multiplication is BL
x
AH. as shown in the diagram below:
AH
1
9999
1 ...........
ŒD
x
[]8]
Bl~
99980001
999800010000
Notice that P2 is not directly beneath P1. but four spaces to the left (recall
the rules for Iining up the products of 2-digit multiplication problems). To con-
tinue in the same manner. the third multiplication should be as follows:
[AH]
Al 199991
BH~---[K]
999800010000
The fourth and final multiplication should be as follows:
AH
1
9999
1) ŒJ
BH~
ŒJ
9998000100000000
Remember that only the values of the four segments are multiplied;
this means that the actual multiplication done by AL x BH, etc. yields the
same number, 99980001, for ail four products.
50,
in the program the pro-
ducts are aligned by converting the products into strings and concatenating
the necessary number of zeros onto the end of the strings to align them pro-
perly. This occurs in statements 1070 through 1100.
1070 P1$=STR$(BL*AL)
1080 P2$=STR$(BL*AH)+F$
1090 P3$=STR$(BH*AL)+F$
1100 P4$=STR$(BH*AH)+F$+F$
218

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents