Around the same time, I wrote a JVM for the PalmPilot [1]. I think it had to fit into 128K of ram with an additional 256K of memory for data (like the class libraries). I was able to fit the entire JDK 1.0.2 runtime into it by transforming the byte code.
The hardware was interesting too. It bit-banged the video display circuit, leaving only the re-trace interval for general purpose computation, including running BASIC programs. Yet the result was an extremely simple and inexpensive design.
Every early microcomputer had to come up with a solution to the video display problem. As I understand it, the Apple II had a bus architecture that interleaved the clock timing of the video circuit and the CPU, sharing a single bus. The Commodore computers had custom video graphics chips. And so forth.
But 4K...wow!
[1] http://lampwww.epfl.ch/~mcdirmid/papers/ghost.pdf