Saturday 30 September 2017

Assembler

I've written a Python assembler for the COP444. I think there might be one in Alfred Arnold's AS assembler, but it's not clear, and anyway it's not very long winded and it's harder to hack it the way I want.

It's a one pass back-wiring assembler, which means that it just saves all the Jump and Call routines and patches them back in at the end when all the labels are defined.

It's mostly fairly straightforward though the Jumps and Calls are a bit peculiar. Outside $80-$FF the opcodes $80-$FE are jump in page, and call in page 2 - so very regular calls can be reduced to a single byte opcode, but in that range it is a jump within pages 2 + 3.  Like most 4 bit microcontrollers it works in 64 byte pages, though unlike many it does allow code to just run from one page to another. A TMS1000 only has a 6 bit program counter and a 4 bit latch, rather than a full 10 bit program counter.

I've also started on an emulator for the COP444 ; this again is fairly straightforward apart from this Jump/Call peculiarity.  Hopefully in a couple of days there will be some actual working code up.

No comments:

Post a Comment