home

casio fx-201p

the fx-201p is a most interesting machine from 1976 and possibly the first casio programmable hand-held. its programming style is remarkable and demonstrates early pioneering ideas.

the machine is rather large for a "pocket" calculator and is designed in the same style as other early pocket machines, notably the al-10 and fx-19 but bigger.

the machine operates as a ten digit scientific, although not all the operations give 10 digit results. sin, cos, tan, arcs and logs are only accurate to 8 digits, x^y only to 7, but 1/x and square root give 10 (casio had the good taste not to display the extra wrong digits). there is no operator precedence.

as well as the ubiquitous deg rad grad switch common to all early casio scientifics, there is a three way mode switch manual comp write. manual mode operates as a straightforward scientific calculator with 1 memory. comp and write are for running and writing programs. manual and comp are different because a few of the buttons differ in function between these modes, which indicates a button shortage, although no buttons share functions (in a given mode) and there are spaces on the second and bottom rows where buttons could have been.

the codes in red underneath some of the keys indicate the symbol displayed in write mode for that key.

casio continued this model making the fx-202p and the pro fx-1.

programming style

the machine programmes in a rather inefficient fortranesque style. there are ten memories labelled 0-9 and a special indirection memory. there are two red led annunciators on the display above the words ENT and ANS which serve to indicate if the machine is expecting the input of a number or is displaying the output of an answer. consequently, the program must contain instructions to accept a number and store it (eg ENT 1) and to output results (eg ANS 2) ENT and ANS must reference a memory.

program expressions are delimited by a colon ':' and every key press costs 1 step from a limit of 127. here is all that is allowed:

<memory#> = <expression> : eg 2 = 3 + 4 : (all numbers refer to memory locations)
2 = 2 + K 1 : (K introduces a constant)
expressions can chain and contain any normal calculator operations (except those not available because the buttons are redefined such as pi and1/x).
ST# <n> : lay down a label (eg ST# 4 : )
GOTO <n> : jump to label or subroutine. (eg GOTO 4 : )
interestingly all goto must remember the return address because the machine doesnt know a subroutine until it gets there. there is no stack, only 1 level of subroutine is allowed.
ENT <n1> : <n2> : ... get input numbers into memory. (eg ENT 1 : 2 : 3 : )
ANS <n1> : <n2> : ... display memory results (eg ANS 1 : 2 : 3 : )
MAC clear all memories
IF <n> = <expression> : <l1> : <l2> : <l3> : conditional branch to label or subroutine. you must have three labels l1, l2, l3 indicating the destinations for n < expr, n = expr and n > expr. you can share labels.
these tests really burn memory.
SUB# <n> : subroutine label.
the labels and subroutine labels share the same number space of 0-9. SUB# can be the destination of any jump. you cant nest subroutines. if another SUB# is encountered or step 127 is reached the program returns.

and thats all. aside from MJ the manual jump which is a special label to which you can jump to manually in comp mode. you also have an indirect memory which stores the number of another memory (0-9) from which to redirect. this is an advanced feature not seen later until the fx-502p.

unfortunately because of the limited memory and wasteful program notation, the machine is almost totally useless programmatically. as an exercise i tried to write something vaguely non-trivial: a program to calculate to one of 8 segments, the phase of the moon.

here it is as an example of a fx-201p program.


example program: moon phase

synopsys:

calculate the phase of the moon to the nearest segment.

ENT 1 : 2 : 3 : IF 2 = K 3 : 1 : 2 : 2 : ST# 1 : 1 = 1 - K 1 : 2 = 2 + K 1 2 : ST# 2 : 9 = K 1 0 10^x : 2 = 2 + K 1 : 3 = 1 * K 3 6 5 . 2 5 + 3 + 9 - 9 : 3 = 2 * K 3 0 . 6 + 3 + 9 - 9 - K 6 4 . 1 = / K 2 9 . 5 3 : 4 = 3 + 9 - 9 : 3 = 3 - 4 = * K 8 + K . 5 : ANS 3 :

usage:

<start>
enter year - 1900 (eg 2002 = 102) <ent>
enter month (1=jan,2=feb etc) <ent>
enter day <ent>
the whole part of the displayed answer is the moon segment as follows,
0 or 8 = new moon
1 = crescent (waxing)
2 = first quater (half moon)
3 = gibbous (waxing)
4 = full moon
5 = gibbous (waning)
6 = second quater (half moon)
7 = crescent (waning)

notes:

dates valid from 1/1/1900 to 31/12/2099

example:

What phase is the moon on July 24, 2002?
<start>
102<ent>
7<ent>
24<ent>
<ans>4.525736 
since the whole part is 4, the moon is full.

casio also published a separate program library for this model that was available as optional extra.