LC-3 Compiler User Manual for SHARP PC-1261/PC-1262

This is a compiler for Pocket Computer created around 1987~1988.

  • Compiler and Runtime Library are very compact and can coexist in memory.
    • You can edit, compile, and run source code in memory.
  • A lot of useful instructions for the game.
  • The generated code is small and fast because variables are stored in RAM.

I recently made PockEmul compatible with the LC-3 Compiler for the Sharp PC-1261/1262. It will be part of PockEmul 2.10.0

This required extensive groundwork, as the compiler relies heavily on undocumented features of the SC61860 processor, many of which had not yet been implemented in the emulator.

The compiler enables developers to write programs directly in BASIC, using special instructions, and then compile the code into LM format, all within the pocket computer itself.

It is particularly well-suited for creating fast-paced graphical games.

Originally developed in Japan, the compiler had no existing English documentation available until now.

To address this, I’ve translated the X thread by @poyokoma_danna, which details LC-3 functionalities, and supplemented it with a translation of the official documentation (hiroog/LC3_Compiler: LC-3 Compiler for SHARP PC-1261/PC-1262).

Continue reading “LC-3 Compiler User Manual for SHARP PC-1261/PC-1262”

An SC61860 bug since 25 years

Incredible — a bug in the SC61860 CPU used in classic Sharp devices has been fixed after 25 years!

Usually, a CPU bug is spotted quickly because everything crashes. But this one was a subtle side effect in batch instruction processing.

When I requested a batch of 0xFF, the loop exited without doing anything, instead of executing 256 times.

Turns out, it was just a while () {} that needed to be replaced with a do {} while ().

Now, the LC-3 compiler works correctly — it’s the one that uses 0xFF batches, unlike the standard ROM which never does.

It took me ages to find this bug, I was so convinced my algorithm was solid. obviously, after 25 years of faithful service…