ZX81/TS1000 Tips

See all articles from SINCUS v6 n6

9. Using a pocket calculator to convert decimal addresses (generally 5 numbers) to hexadecimal addresses(four digits):

[ An example will parallel the instructions 29279 ]

a) Zero calculator and memory.
b) Enter decimal address.                                   >29279<
c) Add it to memory.                                        m 29279
d) Divide by 4096.                          29279 / 4096 = 7.1481933
e) Write down the Interger part of the result.                 7___.
f) Multiply 4096 by the Interger.                    7 x 4096 = 28672
g) Subtract the result from memory.            m 29279 - 28672 = 607
h) Recall memory.                                            rm 607

The Interger obtained in step (d) is the most significant hexadecimal digit. If above 9, change it to the equivalent hex letter A to F. A=10, B=11, etc. For the next hex digit repeat steps (d) to (h) using 256 in place of 4096.

d) Divide by  256.                          rm 607 / 256 = 2.3710937
e) Write down the Interger part of the result.                 72__.
f) Multiply 256 by the Interger.                       7 x 256 = 512
g) Subtract the result from memory.                m 607 - 512 = 95
h) Recall memory.                                             rm 95

Follow the same process for the third hex digit using 16 in steps (d) and (f). The number resulting from step (h), after using 16, is the last and least significant digit of the hex address.

d) Divide by  16.                              rm  95 / 16 = 5.9376
e) Write down the Interger part of the result.                 725_.
f) Multiply 16 by the Interger.                          5 x 16 = 80
g) Subtract the result from memory.                    m 90 -15 = 15
h) Recall memory.                                             rm 15
Convert remainder to hex, in this case 15 = F in hex.           725F

Giving the complete hexadecimal number of 725F.

Note: m and rm are memory and recall memory tags.

In any step after the most significant digit, should the result from step g = 0, the hex digit of 0 would be the digit used to finish the four place hexadecimal code. eg. Decimal address 28672,

step:   a) clear memory
        b) enter address                                  28672
        c) add to memory                                m 28672
        d) Divide by 4096                        28672/4096 = 7
        e) Write the interger                 7___.
        f) Multiply 4096 by interger.           4096 x 7  = 28672
        g) Subtract result from memory     m 28672 - 28672 = 0
        h) Recall memory                                   rm 0

This then completes the hex code, 7000.

10. Using a pocket calculator to convert hexadecimal addresses to decimal addresses: If hex 0, then Decimal 0

[ Using the same sample number, now 725F, find the decimal equivalent.

 a) Zero calculator and memory.
 b) Enter the decimal equivalent of the most significant digit of the hex address.
Use table below to convert letters to numbers, F = 15.               7___.
 c) Multiply by 4096.                                    7 x 4096 = 28672
 d) Add the result to memory.                                    m 28672
 e) Enter the decimal equivalent of the next most significant hex digit. _2__.
 f) Multiply by 256.                                       2 x  256 = 512
 g) Add result to memory.                           rm 28672 + 512 = 29184
 h) Enter the decimal equivalent of the next hex digit.               __5_.
 i) Multiply by 16.                                          5 x 16 = 80
 j) Add result to memory.                            rm 29184 + 80 = 29264
 k) Enter the decimal equivalent of the last hex digit.          15=  ___F.
 l) Add it to memory.                                  15 + 29264 = 29279
 m) Recall memory.                                               rm 29279

    The calculator will now display the decimal address.            29279

NOTE: Dec. Intergers: 0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
      Hex digits:     0  1  2  3  4  5  6  7  8  9   A   B   C   D   E   F

11. Here is a short program for converting Decimal and/or hexadecimal numbers to SINCLAIR Floating Point Numbers. Use Positive Intergers only.

To copy the results on your printer, stop the conversions by pressing ENTER. The press the “Z” key for COPY, then ENTER. Make sure your printer is on before pressing ENTER for COPY.

Next time I will give you a couple of useful routines that uses Floating Point Numbers.

   1 REM ZZZZZZZZZZZZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
5 REM "F.P. -NUMBER"
10 LET A=16514
20 PRINT TAB 6;"WHEN ENTERING
ADDRESSES IN DECIMAL NUMBERS KEEP
THE NUMBER OF DIGITS ODD BY PRE
FIXING A 0 WHERE NEEDED. WHEN E
NTERING HEX A-DECIMAL NUMBERS KEEP
THE NUMBER OF DIGITS EQUAL TO 4
.";AT 20,16;"PRESS ENTER"
30 INPUT A$
40 CLS
50 PRINT TAB 4;"ADDRESS","F.P.
-NUMBER"
60 INPUT A$
70 IF A$=""THEN STOP
80 IF LEN A$/2-INT (LEN A$/2)=
0 THEN GOTO 140
90 IF LEN A$<1 OR LEN A$>5 THE
N GOTO 60
100 PRINT TAB 9-LEN A$;A$;" D",
110 POKE A+1, INT (VAL A$/256)
120 POKE A, VAL A$-256*INT (VAL
A$/256)
130 GOTO 180
140 IF LEN A$<>4 THEN GOTO 60
150 PRINT TAB 9-LEN A$;A$;" H",
160 POKE A+1,16*CODE A$+CODE A$
(2)-476
170 POKE A,16*CODE A$(3)+CODE A
$(4)-476
180 RAND USR 16535
190 GOTO 60

Editor’s Notes

Interger: is a whole number

Most significant digit: that part of a whole number, as in the number 12, the 2 is the least significant digit, because adding or subtract or performing almost any other function on it has less effect on the overall value of the number than if the 1 (most significant digit) was affected.

Floating Point numbers: real numbers

For more background on intergers, Floating Point numbers, real numbers, Most significant digit get a copy of TS 2068 Intermediate/ Advanced Guide, by Jeff Mazur, a SAMS book, and start at the beginning.