Sunday, September 13


Daily News Stuff 12 September 2020

ABCD Goldfish Edition

Tech News

  • I sat down this evening to put in an hour or two on Imagine-Emu, starting by updating PyCharm and getting some proper Nim support, and fairly quickly realised two things.

    First, while pairing 10-bit registers A, B, C, and D into 20-bit registers AB and CD might be historically accurate and aesthetically pleasing, it turns the emulator code into a bramble of special cases.

    And second, I shouldn't be writing a CPU emulator at all.  I should be writing a CPU emulator generator.

    These five architectures have between them a total of 15,872 opcodes.  Just write a program that loops through all the general cases and the special cases and spits out the exact code required to implement each one.  Each emulator then consists of some register and memory definitions, a few helper functions like the indexed address calculator, and one huge case statement.

    Same applies to the DSPs that exist in four of the five machines.  Graphics hardware I will need to write some specific code for.

    After pulling out some misfeatures from my original design, the Imagine and the Dream CPUs are looking very similar.  The main difference is that the Dream has twice as many general-purpose registers - eight each in 12-bit and 24-bit lengths.  The Mirage will likely slot in between the two, with four accumulators and eight general purpose registers.

  • Or of course you could just download an Amiga.  (Tom's Hardware)

    Workbench 3.1 was kind of ugly.  The original blue 1.x series was nicer.

  • A benchmark for a Radeon RX 6000 has leaked, putting it in line with an Nvidia RTX 2080 Ti.  (WCCFTech)

    Which is right this minute the fastest graphics card available but very shortly will not be.

    However, it's not clear what card actually leaked, whether this is the long-awaited Big Navi or merely the new high-midrange part.  We'll see, at some point, probably.

  • 6000 Euros for a plastic toy car?  (The Guardian)

    Albeit a plastic toy car that seats two slim adults and can hit 45km/h.

  • Just say false.  (NoYAML)

    YAML is readable JSON.  That turned out to be a really bad idea.

    Also, that "If SQL were built on YAML" example?  That's Elasticsearch, only Elasticsearch is much less elegant and changes arbitrarily every few months.

  • Apple continues to shit all over its customers.  (

    Their latest bright idea is that game streaming services must submit every streamable game to the App Store as an individual app.  The streaming service app itself then acts as a catalog for all the other apps - which are all absolutely identical because all they do is stream a game.  And for this unmitigated fuckery Apple will skim 30% off the top of every single transaction.

  • Or you could just say fuck you, Apple and get an Xbox Series S for $25 per month including constantly updated libraries of downloadable and streamable games from Microsoft and EA.  No payment up front and you own the device outright after two years.  It actually works out $60 cheaper than buying the device and paying for the service for two years.

  • In Australia the Series S is $499 and the Series X is $749.  With exchange rates and sales tax that makes the S about 10% more expensive here and the X about 1% cheaper.

  • Noted.

Disclaimer: MNO goldfish.

  • So, on registers:

    The Imagine was designed with four 10-bit general-purpose registers, called, reasonably enough, A, B, C, and D.  The Z80 had those too.  Nice and cosy.

    Then I added four 20-bit index registers - W, X, Y, and Z.  X and Y are traditional - they were used on the 6809, and the Z80 had IX and IY.

    The playn was to use AB, CD, W, and X as general-purpose 20-bit registers, and allow you to also address WL, WH, XL, and XH as 10-bit registers, and this is where everything came unstuck.

    First, this meant that the instruction encoding didn't map directly to a register, even with an offset, but instead needed a lookup table.

    Worse, instructions writing to any 10-bit register - which is what the CPU will spend most of its time doing - need to perform bit-masking to keep the 20-bit combined register intact.  Or alternately any 20-bit access to those registers - and these are by definition the 20-bit registers used most often - would need to read two 10-bit values and shift and combine them.

    At this point a wise CPU designer in the minicomputer division at our fictitious company in the late 1970s said, and I quote, "What if we don't do that?"

    Instead of that horrible that affects every commonly used instruction, just have four 10-bit registers, four 20-bit registers, and one special transfer instruction that can do those mappings.

    The Imagine has a total of 10 20-bit registers.  The easily remembered W, X, Y, and Z, plus the stack pointer, program counter, loop counter, user stack, refresh counter, and timer, which make up the acronym SPLURT.

    I did not plan that.

  • The Dream on the other hand has 26 registers, everything from A to Z.  Two - the interrupt vector I and the refresh counter R - are not accessible by regular instructions, but the rest are.  I still have have to jiggle the register mapping around a little, but the instruction encoding works out fairly neatly:

    4 bits for the opcode
    1 bit for the word length (0 = 12 bits, 1 = 24 bits)
    3 bits for the destination
    4 bits for the source / address mode

    That allows for 8 accumulators in both 12 and 24 bit modes - all independent - plus four special source registers like the flags register and program counter, plus four main addressing modes.

    The four modes are quick page, PC-relative, immediate, and indexed, with indexed mode using a second byte to specify the base and offset and autoincrement/autodecrement modes.  (This is all stolen from the 6809.)

    That's pretty nice.  It's just a two-address register-memory design, but it's a pretty nice one.  If you took a 6809 and expanded it until it was almost a 68000 but not quite, it would look rather like this.

Posted by: Pixy Misa at 12:53 AM | Comments (2) | Add Comment | Trackbacks (Suck)
Post contains 1036 words, total size 8 kb.

1 "I shouldn't be writing a CPU emulator at all.  I should be writing a CPU emulator generator."
If you were writing this in Java, you could be writing a CPU emulator factory.

Posted by: Kurt Duncan at Sunday, September 13 2020 01:15 AM (7AkDP)

2 *turns self in down at the MPD* "I am Spartacus!"

Posted by: normal at Monday, September 14 2020 01:23 AM (obo9H)

Hide Comments | Add Comment

Apple pies are delicious. But never mind apple pies. What colour is a green orange?

55kb generated in CPU 0.0163, elapsed 0.112 seconds.
58 queries taking 0.1002 seconds, 343 records returned.
Powered by Minx 1.1.6c-pink.