The Sharp CE-125 is a printer and microcassette recorder that is compatible with a range of their more pocket-sized pocket computers. Having the microcassette recorder built in means you could save or load programs and data without needing to carry around a separate data cassette recorder (as you would with most of the more traditional printer and cassette interface options), making it a very convenient and compact option for computing on the go.
The CE-125 contains a rechargeable nickel-cadmium battery pack and unfortunately these are now showing their age by leaking a corrosive liquid that destroys the circuit boards they're connected to. If you buy one second-hand be prepared to do some repair work; you will need to replace the battery pack at the very least as the charger is not sufficiently powerful to operate the unit on its own. Even worse, the battery pack is used to clamp the charger's unregulated voltage to a suitable level, and without a healthy battery pack the charger can fry the circuits inside the CE-125.
When poking around inside the CE-125 you may notice that the top right corner of the unit has a cover that can be popped off to reveal an additional connector socket that's not mentioned in the user manual. It's not directly mentioned in the service manual, either, though it is shown in the circuit diagram and labelled "check terminal". It's a 9-pin connector that shares a lot of pins in common with the 11-pin connector that goes directly to the computer:

The 9-pin connector does have a few notable differences, though:
- The cassette recorder pins MTout1, MTout2 and MTin are missing.
- SEL1 and SEL2 for device selection are missing; in their place, OP2 and ACL are provided.
- VP is added; this provides a direct connection to the negative side of the battery pack.
The pocket computer has two device selection pins, SEL1 and SEL2, that are used to address which device it's addressing. As per the service manual, these are connected to a "2-to-4 decoder" and this should give us four states. The service manual, however, only documents three of them in the following table:

There is clearly a missing state here where both SEL1 and SEL2 are 0; if OP1 and OP3 are documented, where is OP2? OP1 and OP3 are outputs from PCU; OP2 is also shown on the circuit diagram, but the service manual describes it as "Additional I/O select (not used)".

Why is this pin routed to the hidden connector, in that case? Two of the documented states, "OP1 (remote)" and "PCU" relate to functions directly handled by the CE-125 itself (remote control of the microcassette recorder's motor or sending data to the printer). The other two states are the generic "OP3 (ACL)", sent to reset the device (e.g. when the AC button is pressed on the computer) and the mystery "OP2 (additional I/O)" which are exposed on this hidden connector. Could it be that other devices were planned that could be plugged in to the CE-125 to provide some additional functionality to the pocket computer? Providing full access to the CE-125's battery pack would also allow such devices to draw power directly from the unit rather than having to have their own power supplies.
Unfortunately, I have not been able to find any reference to such optional add-on devices; the only commercially released devices all seem to be variations on the theme of printer and/or cassette interface. For example, the CE-126 is a smaller printer that connects to the computer via a cable (rather than being a larger unit that the computer docks with) and has audio jacks for connection to an external data cassette recorder. Its service manual mentions OP2, but only says it's "not used" and looking at the circuit diagram it's not connected to anything (no hidden option port on the CE-126, as far as I can tell).
A further oddity is that this hidden port is completely missing on one of my CE-125 units. The port cover is still there, but if you open it up there is no corresponding socket to connect anything. This particular example has a 1985 date code; all of my other CE-125 units are from 1983. Could it be that add-ons were planned, hence the inclusion of the port, but then the idea was abandoned and the port was removed from later revisions of the CE-125?
The PC-1251 seems to have been the computer the CE-125 was designed for; at least, the CE-125's included microcassette of sample application software is only fully compatible with the PC-1251 as that computer has an unusually wide LCD capable of displaying 24 characters. Other pocket computers that can be connected to the CE-125 tend to have narrower screens only capable of displaying 16 characters, and so their instruction manuals contain details on how to modify the software included with the CE-125 to fit on their respective screens.

If the PC-1251 was the intended computer to use with the CE-125, maybe it can provide some clues as to what these additional devices would have been. Its service manual is, sadly, not much use – it only mentions the CE-125 as an option, not even the CE-124 cassette interface and CE-126 printer that were available for it. However, the way that the PC-1251 communicates with its options can end up being quite revealing.
As a point of comparison, the PC-1500 computer had a variety of different options – as well as the traditional printer and cassette interface, there was an RS-232 serial interface and a "software board" membrane keyboard. These devices plug into a very large connector on the side of the computer with a whopping 60 pins that exposes the computer's internal buses. The computer itself doesn't know how to communicate with each option it can be connected to; for example, even though the PC-1500's keyboard has shortcuts for tape operations such as CLOAD and CSAVE on them pressing these just yields a ~ on the screen and an error when you try to execute them unless the computer is connected to the cassette interface at the time. The code to handle the option is stored on a ROM inside the option itself, and when the PC-1500 starts up it searches for additional BASIC keyword handlers in these ROMs.
The PC-1251 isn't that sophisticated or extensible, and all support for compatible options has to be built into its own internal ROM. Whilst this is ultimately somewhat limiting, it does mean that if Sharp had planned to support additional options then code to handle them might still be lurking inside the computer's BASIC interpreter in the form of undocumented BASIC statements and functions. These can be found in a couple of ways; you could try using the computer's ability to expand an abbreviated keyword to reveal additional keywords. For example typing K. and pressing Enter returns a syntax-related ERROR 1, but if you press the left arrow key you can see that K. has been expanded to KEY and this keyword is not documented in the PC-1251 manual. Some keywords might need some additional letters to find; for example, O. expands to ON (which we already know about) but OU. expands to OUTSTAT which is also undocumented.
A less labour-intensive method is to remember that each BASIC keyword gets tokenised to a single-byte form when stored in memory. Using a table of known BASIC token values we can build a program externally that uses token byte values that are in the gaps between the known tokens, then list them on the computer to find out what keywords they correspond to. Eventually, the following undocumented keywords can be found on the PC-1251:
- COM$
- INSTAT
- KEY
- OUTSTAT
- ROM
- SETCOM
All of these produce errors when run, though. KEY, OUTSTAT and SETCOM produce an ERROR 1 (syntax error) but COM$, INSTAT and ROM produce an ERROR 8 which indicates an I/O error. Could these keywords be related to accessing an external device?
COM$, INSTAT, OUTSTAT and SETCOM are particularly interesting as I had seen those keywords before in the manual for the CE-158 RS-232 serial interface for the PC-1500. From that I could see that OUTSTAT needs a numeric argument to set the state of the serial port's handshaking lines, and indeed trying OUTSTAT 3 turned the error from a syntax ERROR 1 into an I/O ERROR 8. SETCOM needs arguments to configure the serial port – the example given in the user manual is SETCOM 300,7,E,1. Trying that on the PC-1251 still yielded a syntax ERROR 1, with the "7" highlighted by a flashing block cursor. After a bit of trial and error I found that swapping the parity parameter with the data size changed the error – still an ERROR 1, but the cursor is a solid underscore at the end of the line rather than a flashing block over a particular character, indicating the error is a lack of input rather than a mistake earlier in the line.
At this point I tried adding additional parameters, starting with A (flashing block over the A), B (flashing block over the B) and then C (solid underscore after the C). I tried adding further characters after the C, until it finally accepted CI and the error changed from syntax ERROR 1 to I/O ERROR 8.
At this point I realised that the PC-1251 combined the CE-158's SETCOM and SETDEV statements into a single SETCOM statement. The way the CE-158 serial port on the PC-1500 works is that instead of having a series of additional statements and functions specifically to transfer data via the serial port it instead redirects existing I/O devices via the serial port. The CI device refers to the cassette input device, and when redirected (using SETDEV) attempts to load data from the cassette (e.g. using CLOAD or INPUT #) will instead read the data from the serial port. It looks like the PC-1251 can also do that, as its SETCOM statement accepts the following device names that the CE-158 handles with its dedicated SETDEV statement:
- KI (Keyboard Input)
- DO (Display Output)
- PO (Printer Output)
- CI (Cassette Input)
- CO (Cassette Output)
However, none of this was any use if all that could be generated was an ERROR 8, and so to fix that the actual I/O devices that the computer was trying to communicate with would need to be recreated. Fortunately, the serial data transfer protocol is described in the CE-125 service manual:

I had previously experimented with this, as I'd first picked up a CE-125 without a compatible pocket computer and wanted to see if I could drive it myself from a little microcontroller circuit. However, I couldn't get it to print other than very occasionally and I wasn't sure why – turns out, if I'd checked a copy of the CE-126 service manual then I would have found the missing piece of the puzzle. What the CE-125 service manual neglects to mention is that after sending 24 characters of data to print, you need to send the print command of &0D:

One slightly annoying property of Sharp's devices from this era is their use of negative supply voltages – that is to say that GND is connected to the positive side of the batteries and the power supply going into the computer and printer is connected to the negative side of the batteries. Logic levels are still set that a 0/"low" level has a voltage lower than a 1/"high" level, it's just that a 1/"high" level is connected to ground and a 0/"low" level has a negative voltage.

As a result you'll find a lot of PNP transistors inside these devices, as confirmed by the PC-1251 service manual above which denotes SEL1 and SEL2 as "P-type open drain" connections. It's not too difficult to connect a modern microcontroller to such a circuit, you just need to be careful as the power supply looks like it's connected "backwards"! In my case I decided to use AVR microcontrollers, and whilst they can be connected to an N-type open drain circuit quite easily (using the weak pull-up resistor offered by GPIO pins to idle at a logic high and driving the pin low to assert a logic low) an external pull-down resistor is instead required to idle at a logic low with the pin driven high to assert a logic high.
My initial test circuit just captured any data received from the PC-1251 (via the CE-125's 9-pin port) when OP2 ("additional I/O select") was high and sent it to my PC. For each received value I then tried sending back various responses until the PC-1251 was happy with the data I was returning (knowing now that I needed to terminate data transfers with &0D, as per the CE-126 service manual). By trying all of the undocumented BASIC keywords previously uncovered from the PC-1251, the following command bytes were identified:
- &2B: COM$.
- &2E: KEY ON or KEY OFF .
- &70: SETCOM.
- &71: OUTSTAT.
- &72: PRINT when SETCOM redirects DO.
- &73: LPRINT when SETCOM redirects PO.
- &74: LLIST when SETCOM redirects PO.
- &75: CSAVE when SETCOM redirects CO.
- &76: PRINT # when SETCOM redirects CO.
- &77: INSTAT.
- &78: INPUT when SETCOM redirects KI.
- &7A: CLOAD when SETCOM redirects CI.
- &7B: INPUT # when SETCOM redirects CI.
- &7C: ROM.
- &7E: Requests a key when KEY ON is enabled.
Most of the data responses were quite straightforward (just a byte value or tokenised string followed by a &0D terminator, for example) but others took a bit more puzzling out – for example, when using CSAVE the computer transfers a plain dump of the BASIC program in memory, but if you try to return this to the computer in response to CLOAD you just get an error message as you need to include additional checksums in the data stream. Even with that satsified there were still problems with the last line of loaded programs being corrupted and MEM returing the wrong amount of free space as the loaded data needed to be padded with an appropriate number of bytes. Eventually I had all of the commands sorted out, and set about creating three dedicated devices based on the identified add-on option types:
- ROM program module,
- PS/2 keyboard adaptor, and
- RS-232 serial interface.
The ROM program module was the simplest type of add-on; this just contains a single program in its ROM that can be loaded by typing ROM on the computer.
The PS/2 keyboard adaptor allows you to use a PS/2 keyboard to control the computer when enabled with KEY ON. I'm not sure what the plan might have been with this – possibly a PC-1251 equivalent to the PC-1500's CE-159 "software board" keyboard. One interesting aspect of this is that when using an external keyboard a much larger number of defined programs can be used compared to on the PC-1251 alone. A defined program starts a program line with a single-character string (e.g. "A") and this program is run when DEF and the specified key (e.g. "A") is pressed on the keyboard. Normally only alphabetic keys from the lower two rows of the keyboard (A-L, Z-M), space and the equals sign can be used but when using the external keyboard pretty much any character can be used – even the block character used as a flashing cursor. In my case I set the F1 to F10 keys on the connected keyboard to access defined programs "1" to "9" for F1 to F9 and then "0" for F10.
Finally, the RS-232 serial interface is possibly the most interesting and useful device. Trying to keep things cheap and simple I use a "poor man's" RS-232 interface (i.e. a bunch of zener diodes and resistors instead of a serial driver like the MAX232 chip) but it seems to work well enough, within the limitations of the software support of the PC-1251. For example, only three baud rates are available – 110, 300, and 1200. There are some additional oddities like LLIST (for printing out program listings) hard-wrapping the content at 24 columns, which makes sense for the CE-125's 24-column-wide printer but is awkward for an external serial printer which might support 80 characters per line. There is also no way to configure mapping of special characters or redefine line ending/terminator characters, which can be done on the PC-1500's CE-158, and the result is that the implementation seems a little incomplete.
Even more puzzling is that the SETCOM statement has been disabled on the PC-1245. If you load a program that uses it onto the computer it shows up as S (i.e. S followed by spaces) but can't be executed or typed into programs. The other serial-port-specific keywords (COM$, INSTAT, OUTSTAT) are still present and operational, which made me wonder if the rest of the code for serial port access is still present in the PC-1245 ROM. After all, once configured via SETCOM, all of the heavy lifting is performed by the other keywords that have had their I/O device redirected to the serial port, so assuming that the serial port redirection status is stored in a set of flags somewhere in RAM, we just need to find out where that is.
The PC-1245 and PC-1251 have similar ROMs so the assumption was made that the address of the flags would be the same on the PC-1245 and PC-1251. A program was therefore written for the PC-1251 that would probe a range of memory addresses, enabling each I/O device via SETCOM in turn and logging any changes:
10 REM FIND SETCOM ADDRESS 20 INPUT "START ADDRESS? ";A 30 INPUT "END ADDRESS? ";B 40 IF A>B GOTO 20 50 SETCOM OFF 60 V=PEEK A: SETCOM ,,,,CI: GOSUB 90 70 V=PEEK A: SETCOM OFF : GOSUB 90 80 GOTO 60 90 IF PEEK A=V GOTO 210 100 SETCOM OFF :O=PEEK A 110 SETCOM ,,,,KI:K=PEEK A 120 SETCOM ,,,,DO:D=PEEK A 130 SETCOM ,,,,PO:P=PEEK A 140 SETCOM ,,,,CI:C=PEEK A 150 SETCOM ,,,,CO:X=PEEK A 160 IF O=K AND O=D AND O=P AND O=C AND O=X GOTO 210 170 LPRINT USING "######";"ADDRESS",A 180 LPRINT " OFF KI DO PO CI CO" 190 LPRINT USING "####";O;K;D;P;C;X 200 LPRINT USING ;"" 210 A=A+1: IF A<=B THEN RETURN 220 SETCOM OFF 230 END
After running for a while the computer has found some possible matches:
The most promising address is 50871 (&C6B7) as this has bit values that correspond directly with the known device bit values, and indeed on the PC-1245 POKEing a value into this memory address redirects the specified I/O device to the serial port (e.g. POKE &C6B7,&18 redirects CO and CI cassette devices, so CSAVE and CLOAD go via the serial port). I don't know why SETCOM was disabled on the PC-1245, but this is at least a workaround. Unfortunately as there isn't a way to transmit the serial port settings this does mean the port ends up stuck at the default of 300 baud, No parity, 8 data bits, 1 stop bit – it works, but it is incredibly slow!
Incidentally, the PC-1251 only provides three baud rates that I could find (110, 300 and 1200). When you use the SETCOM statement in BASIC two bytes are transmitted to the serial interface: one containing the port settings and another containing the bit flags specifying which devices are to be redirected.
The format of the port settings byte is %00SDPPBB, where:
- S = Stop bits: 0 = 1 stop bit, 1 = 2 stop bits
- D = Data bits: 0 = 8 data bits, 1 = 7 data bits
- PP = Parity:
- 00 = No parity
- 01 = Even parity
- 10 = Odd parity
- BB = Baud rate:
- 00 = 300
- 01 = 110
- 10 = 1200
As two bits are used for the baud rate, a fourth baud rate could be specified as BB = 11. I can't find any way to express this as a parameter to the SETCOM statement normally, however one quirk is SETCOM OFF. This disables all device redirection, however it still sends both parameter bytes to the serial interface, with the device bits set to zero (as expected when disabling them) and the port settings byte being the value previously specified. To be able to retain the port settings byte value from before, it must be stored somewhere in memory and sure enough it's present at &C6B8.
It's a bit of a hacky workaround, but custom port settings could be sent to the serial interface as follows:
- POKE &C6B8 with the desired port settings.
- SETCOM OFF to send these settings to the serial interface.
- POKE &C6B7 with the desired redirected device settings.
I did this and implemented five additional baud rates; BB = 11 is assigned to 600 baud, then the previously unused sixth bit is used to enable a eight-times multiplayer when set, so 300 baud becomes 2400, 1200 becomes 9600 and 600 becomes 4800. 880 baud isn't valid, so 110 becomes 75 instead.
Unfortunately, the presence of the port settings in memory doesn't help the PC-1245 as unlike the device redirection (which is handled entirely on the pocket computer side) the port settings still need to be sent to the serial interface, and this is done with the missing SETCOM statement.
Fortunately, the PC-1245 and PC-1251 are programmable in machine code, so it should be possible to find the appropriate routines in ROM that can be called to directly transfer data to the serial interface and configure it as desired. Interestingly, the PC-1251's instruction manual does contain an example program for the CE-125 which shows how to store binary data inside the computer's printer buffer and transfer it directly to the CE-125 via machine code, and this can be used to show additional characters (including lowercase ones) that the printer supports even if the computer doesn't. Unfortunately, that program also comes in three different flavours that you're expected to POKE into memory depending on the value PEEKed from somewhere else in memory, indicating that different ROM revisions shuffled the code around and there's no standard fixed entry point for interacting with I/O devices.
As I'm specifically interested in the PC-1245, I dumped its ROM and started digging through it using an ESR-H reference. This snippet is what I came up with as a replacement to SETCOM (you need to POKE the desired settings into &C6B7 and &C6B8 before calling it):
LIA 70 ; 0x70 is the SETCOM command byte
CALL PCU_WRITE_BYTE ; Write it directly to the PCU
LIDP C6B8 ; Set DP to point at the communication parameters byte
LDD ; Load from DP into A
CALL PRINT_QUEUE ; Queue up the communications
CAL SETDEV_PTR ; Set DP to point at the device redirection byte
LDD ; Load from DP into A
JP 6C1E ; Jump into the middle of OUTSTAT
When assembled into machine code and incorporated into a BASIC program, the result is something like this:
10 DIM Z$(1)*6 20 POKE &C5BE,2,112,120,125,111,16,198,184,87,120,123,145,241,102,87,121,108,30 30 POKE &C6B7,&04,&42 40 CALL &C5BE 50 PRINT COM$
Line 30 sets the redirected device to PO (Printer Output) and the communication parameters to 9600 8N1 so the program should display "9600,N,8,1,PO" on the computer's LCD. It's not exactly elegant, but at least it's possible to make it work at all on the PC-1245 unlike later pocket computers.
As you can probably tell from the descriptions above these add-on options are all a bit rudimentary and limited. Ultimately, I wanted to try to match the three devices I put together – ROM program module, keyboard interface and serial port – to what might have been done at the time the computer was released. The BASIC statements are there to be overridden; an obvious improvement to the ROM module would be to implement cassette save redirection so that programs could be stored on it with CSAVE (rather than it just being a read-only device). The serial port's INSTAT and OUTSTAT allow easy transfer of a single byte of data to or from the computer, which could be used to drive eight GPIO lines and allow the computer to control all manner of external hardware. Input devices (such as temperature sensors, barcode scanners or iButton readers) might instead be better suited to being keyboard devices, as they could trigger a named subroutine in the program automatically then "type in" the received value so it can be read by the pocket computer.
I'm happy where I got to with this; the code, circuit diagrams and PCB layouts can be found on GitHub as "Sharp CE-125 Options".


