MEMORY AND NUMBER REPRESENTATION

The LGP-21 (and LGP-30) have a very strange memory word arrangement, to those of us who grew up on modern "integer" arithmetic machines.

The factory documentation says that words in memory are '31 bits with a spacer' or '30 bits with a sign'. The most-significant bit, 0, is on the left. The least-significant bit, 30, is on the right. However, there is a "spacer" bit, always 0, to the right of bit 30:

0  1  2  3  4  5  ...   28 29 30 31
s  d  d  d  d  d         d  d  d  0

Where s is the sign bit, d are data bits, and 0 is the spacer bit.

To make sense of the LGP-21 and LGP-30 memory structure you have to keep in mind that the designers considered the binary point (decimal numbers, decimal point; binary numbers, binary point) to be to the left of the MS bit; between bits 0 and 1. On nearly any modern machine I know (1970's and later) the "binary point", if it's mentioned at all, is to the right of the LS bit. In other words, the base numerical convention is positive integers or 2's complement integers.

You can use the LGP-21 and LGP-30 as you would a whole-integer machine, but if you do, data in memory will appear to be shifted to the left one bit!

As is common of machines of this era, the binary point is made explicit in various places, and for this machine there is a shorthand nomenclature, called q-scaling, which simply specifies, to the right of which bit is the binary point?

An example: The LGP-21, with the point to the right of bit 0, handles numbers in the range of -1 < N < 1. To represent directly the decimal value, say, +50.5635, you would simply move the point to the right sufficient for there to be room for the integer portion, 50, in this case, 2^^6, or 64. Therefore, you store 50.5635 in the LGP-21's memory at a q of 6.

Note that if you think of numbers the way the designers do, the spacer bit, dangling off the LS end of a numeric value, is of literally little significance in calculations. Only when try to think of it as a value of "1", as it would in a whole-integer machine, is it so boggling.

Computers like this were considered calculators, not general purpose symbol crunchers, hence the single "extract" instruction (AND), and single conditional instruction (negative accumulator). Programmers spent a lot of time scaling. Actually, programmers today should spend slightly more time scaling, and suchlike, and we'd probably have a lot fewer buffer-overflow errors in shipped code. But I digress.

NUMBERS

The following table illustrates how various numerical values appear in memory, viewed as an array of bits, in the positive-integer mindset. (Spaces are added every 8 bits or 3 decimal digits, for clarity, they have no significance.)

bits in memory simh shows... LGP value... meaning
00000000 00000000 00000000 00000000 0 0 zero
00000000 00000000 00000000 00000010 2 0.000 000 000 931 322 574 615 478 515 625 smallest positive integer
01111111 11111111 11111111 11111110 7ffffffe 0.99999... largest positive integer
11111111 11111111 11111111 11111110 fffffffe -0.000 000 000 931 322 574 615 478 515 624 smallest negative integer
10000000 00000000 00000000 00000000 80000000 -1 largest negative integer

In summary, values in memory are shifted left one position, with a zero bit filler ('spacer') on the right.

INSTRUCTION WORDS

There is only one instruction format, with the opcode in bits 12 through 15. Memory address is 12 bits, stored in bits 18 - 29, with bits 30 and 31 ignored, and generally 0-filled. Therefore, the address portion of an instruction is shifted left two places.

The instruction format is simple:

0  1  2  3  ...  12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
s  x  x  x  ...   i  i  i  i  x  x  t  t  t  t  t  t  k  k  k  k  k  k  x  0

Where s, the sign bit, modifies some instructions, x is ignored, i is the opcode, t and k the track and sector memory address, respectively (since there are logically 64 tracks and 64 sectors, memory address can be considered to be linear space 0 - 4095).

Note that the address field ttttttkkkkkk LS bit is 29, and data-stored-in-memory LS bit is 30. Therefore, adding "1" to an instruction does NOT increment it. The convention is to use the STOP instruction as a constant (STOP opcode, Z, is 0), for example Z0001.

(The LGP-30 and LGP-21 do not have index registers; to index an array, for example, you modify the address field of an instruction, with the B or Y instruction, usually by adding or subtracting 1.)

All works here unless otherwise specified are copyright 2026 by Tom Jennings. Permission is granted for personal use with no remuneration. Corporations or any organization or their agents, employees, consultants or other relationships human or otherwise, expressly prohibited without written permission.