Transputer emulator in Javascript This is a Javascript port of my transputer emulator written originally in C for my series of articles about the transputer processor. In the old times, Javascript was an interpreted language, but since many years ago it is implemented as a JIT (Just-In-Time) compiler, so it can approach speeds closer to the C language. Other implementation caveat here is that Javascript treats bitwise operators as generating 32-bit signed integers. This was avoided using the >>> 0 operator (logical right-shift) because it generates a 32-bit unsigned integer. You can try 0x80000000 >> 0 and see how it gives back a negative number, while 0x80000000 >>> 0 preserves the unsigned value. Another "new" thing in Javascript is Uint8Array, it is way faster than a normal array and saves memory, as there are several of these arrays (including one of 40MB to hold the entire hard disk drive!). For the drive images, I tried using an initialized array but the source code used 20 megabytes for a binary of 3 megabytes. I figured a good trick to reduce the Javascript source code size using Base64 in my bin2.c utility to encode the 3MB of data for the hard disk drive, and window.atob gets a decoded string that is copied directly to the hard disk drive's Uint8Array. I didn't expected to have a floating-point emulation, but I discovered the Float32Array and Float64Array types (added in 2010) and how these can be shadowed with an Uint32Array, so the emulator can work with real floating-point math, and uses the Uint32Array to get the floating-point binary data to replicate in the transputer internal memory. Finally, for the display I was pretty fortunate to find jsTerm by Peter Nitsch with a compatible license. I removed the Telnet and sockets portion. And as it used a bitmap for the font, I was able to replace it with my original font from 1996 and use it, so you can see the single-line borders for the text windows, and other special characters. My font was based on ECMA-...
First seen: 2025-04-04 07:00
Last seen: 2025-04-04 19:02