Return to the Entry "Computer camp".

My emulated decimal computer

The computer

To avoid teaching the concept of binary numbers, the students worked with an emulated decimal computer, which had 1,000 words of four decimal digits each (positive numbers only). When treated as instructions, the first decimal digit was the operation code ("opcode"), and the remaining three digits the address.

The computer was, of course, very primitive. Its only purpose was to teach the concepts of computer programming. In loops, the address portion of instructions were modified (hence the sta = "store address" instruction below). Subroutines could be written, but only by modifying the address of its final jump instruction (called "tra", for "transfer") to set up the address to which they had to return. Thus, subroutines were not re-entrant. The only comparison instruction checked for an exact match.

The instruction set

Code Mnem. Operation
0 - Halt, or input-output instruction (see next table).
1 add x Add. The contents of memory location x is added to the contents of the accumulator. The sum is left in the accumulator, and the contents of x is unchanged. If the sum is greater than 9999, then the number 9999 is left in the accumulator.
2 sub x Subtract. The contents of memory location x is subtracted from the contents of the accumulator. The difference is left in the accumulator, and the contents of x is unchanged. If the subtraction results in a negative number, then 0000 is left in the accumulator.
3 mlt x Multiply. The contents of memory location x is multiplied by the contents of the accumulator. The product is left in the accumulator, and the contents of x is unchanged. If the product is greater than 9999, then the number 9999 is left in the accumulator.
4 dvd x Divide. The contents of memory location x is divided into the contents of the accumulator. The quotient is left in the accumulator, and the contents of x is unchanged. The remainder of the division is lost. If x contains 0000, the result of the division is 9999.
5 get x Get. The contents of memory location x is placed in the accumulator. The contents of x is unchanged. The previous contents of the accumulator is lost.
6 sto x Store. The contents of the accumulator is placed in memory location x. The previous contents of x is lost. The contents of the accumulator is unchanged.
7 sta x Store address. The last three digits (the address section) of the accumulator are stored in the last three digits of memory location x. The original last three digits of x are lost, but the first digit of x remains unchanged. The contents of the accumulator is unchanged.
8 tra x Transfer. The next instruction is taken from memory location x, instead of from the next sequential memory location.
9 sad x Skip if accumulator different. If the contents of the accumulator and the contents of memory location x are exactly the same, this instruction has no effect, and the next instruction is taken from the next sequential memory location. However, if the contents of the accumulator and the contents of x differ, the instruction following the sad x instruction is skipped, and the next instruction is taken from the memory location two places beyond that of the sad x instruction.

Input-output instructions

The instruction code 0 represents either an input-output instruction or a halt. Which one is determined by the address of the instruction. There are three input-output devices connected to the computer. These are:

1.  A special electric typewriter (a Friden "Flexowriter")
2.  A paper tape reader
3.  A paper tape punch

The possible instructions are:

Code Mnem. Operation
<0996 hlt The computer halts.
0996 tyi Type in. The computer waits until a typewriter key is struck. The two digit code for that character is then placed in the two right-hand digit positions of the accumulator. The two left-hand digits of the accumulator are set to 0. The previous contents of the accumulator are lost. The computer then precedes normally to the next instruction in sequence.
0997 tyo Type out. The character represented by the two digit code in the two right-hand digits of the accumulator is typed out. The two left-hand digits of the accumulator are ignored, and the contents of the accumulator remain unchanged.
0998 rpt Read paper tape. A single character (a single "line" of tape) is read from the paper tape in the tape reader. The two digit code for this character is placed in the two right-hand digits of the accumulator, and the two left-hand digits are cleared. The previous contents of the accumulator are lost. Blank tape and deleted lines are ignored.
0999 ppt Punch paper tape. The character represented by the two digit code in the two right-hand digits of the accumulator is punched by the paper tape punch. The two left-hand digits of the accumulator are ignored, and the contents of the accumulator remain unchanged.

The Flexowriter code

  0 1 2 3 4 5 6 7 8 9
00 sp
sp
"
1
'
2
~
3

4

5

6
<
7
>
8

9
10
st
st





0
?
/
S
s
T
t
20 U
u
V
v
W
w
X
x
Y
y
Z
z

=
,
bl
bl
re
re
30 tab
tab

_
·
J
j
K
k
L
l
M
m
N
n
O
o
P
p
40 Q
q
R
r


+
-
]
)
|
-
[
(

A
a
50 B
b
C
c
D
d
E
e
F
f
G
g
H
h
I
i
lo
lo
.
×
60 up
up
bk
bk

ret
ret
tap
tap





In the above table:

sp = space
st = stop code (for punching tape only)
bl = typewriter black shift (typing only)
re = typewriter red shift (typing only)
lo = lower case shift Lower case retained until upper case shift encountered.
up = upper case shift Upper case retained until lower case shift encountered.
bk = backspace When punching tape, this does not backspace the tape,
          but rather punches the code for backspace onto the tape.
ret = carriage return
tap = blank tape if punching tape. Types a space if sent to the typewriter.

For each of the boxes in the above chart, the specified code will cause printing of the upper character if the typewriter is in upper case, and of the lower character if the typewriter is in lower case.

Empty boxes indicate illegal codes. If these are typed out on the typewriter, they will cause the typewriter to jam momentarily. These codes may be punched on paper tape, but they will be ignored when the tape is listed on an off-line flexowriter.

The highest code ever placed in the accumulator by an input instruction is 63. If an output instruction is ever executed with a code greater than 64 in the right-hand two digits of the accumulator, the character represented is determined by the contents of the accumulator minus 64.

Some additional notes

Students wrote their programs in assembly language. I actually assembled them using the PDP-1 computer's assembler, by adding some instructions in front of the student's program. These started with the assembler commands "decimal" and "expunge". The former switched the assembler to default to decimal numbers, and the second erased all of the assembler's PDP-1 opcodes. These commands were then followed by commands defining the opcodes of the emulated computer, e.g. "add=1000", "sub=2000", and so on. The assembler would then assemble the students' programs, and place them in memory to be run by the emulator I had written in PDP-1 assembly language.

Return to the Entry "Computer camp".


Blog index   Numeric index   Memoirs index   Alphabetic index
Blog home   Keyword list   Help   FAQ
Click here to send me e-mail.
This page was posted June 24, 2010