Let's calculate full surface of the parallelepiped with ribs A, B and C, using "E97". A, B and C values will be stored in memory cells 40-44.
The parallelepiped surface formula is the following:
S = 2 * (A * B + A * C + B * C) = 2 * [A * (B + C) + B * C]
Let's program it in "E97" codes (don't be afraid that the program is so long,
it consists from several simple parts):
Address | Code | Operation | Comments |
---|---|---|---|
0000 | 0E6D |
100 ==> SP | Determine SP |
0004 | 9C0D |
input ==> R1 | A ==> R1 |
0008 | 011E |
R1 ==> (40) | A ==> (40) |
000C | 9C0D |
input ==> R1 | B ==> R1 |
0010 | 011E |
R1 ==> (42) | B ==> (42) |
0014 | 9C0D |
input ==> R1 | C ==> R1 |
0018 | 011E |
R1 ==> (44) | C ==> (44) |
001C | 01E0 |
(42) ==> R0 | B ==> R0 |
0020 | 0101 |
R0 ==> R1 | B ==> R1 |
0022 | 02E0 |
R0 + (44) ==> R0 | B + C |
0026 | 05E0 |
R0 * (40) ==> R0 | A * (B + C) |
002A | 05E1 |
R1 * (44) ==> R1 | B * C |
002E | 0201 |
R1 + R0 ==> R1 | A * (B+C) + B * C |
0030 | 0211 |
R1 + R1 ==> R1 | 2 * [A * (B + C) + B * C] |
0032 | 011E |
R1 ==> (46) | result ==> S |
0036 | 9C0D |
R1 ==> display | print S |
003A | 0F00 |
halt | stop |
003C | ---- |
--------------- | ---------------------------- |
0040 | 0002 |
A |   |
0042 | 0003 |
B |   |
0044 | 0004 |
C |   |
0046 | 0034 |
S (resut) | (note, that hex number 34 |
Try and examine, how it works in "E97". Input 3 integer values
and read the result on the display.
Attention please! You may have some difficulties
with input window (it can appear only once) in MS Internet Explorer v 5.0.
in Windows media. To correct the situation disable JAVA compiler - JIT,
using IE options.