ASM Diaries 4: Don’t Optimise Error Paths
This piece should really be called ‘optimise the path which is not the error path’ but that’s a very unsexy title. The point here is that your code’s error path is (usually) executed a single time before returning to the user for input. That says that it’s not time-sensitive and you don’t need to optimise …. Read More
ASM Diaries 3: Eliminate Jumps by Pre-loading
Writing the code to validate ranges in type definitions in Quiche-Z80 I needed to test for some values. I could easily handle the cases where both values where unsigned or both values where signed but the case where one was signed and the other unsigned allowed a nice little optimisation. Due to the typing rules …. Read More
ASM Diaries 2: A Hack for Case Insensitive Identifiers
This article will make a lot more sense with an ASCII table to look at. I don’t have quick access to a copyright free one, but you view one at https://www.asciitable.com Case insensitive comparisons in assembler are hard work. The design of the ASCII codes splits letters into two blocks. That requires your code to …. Read More
ASM Diaries 1: Type Identifier Equals Data Length
A few years ago I reverse engineered Amstrad CPC BASIC. I’m currently writing a compiler for my Pascal-like language (called Quiche). This is an occasional series of articles where I note observations about assembly programming and, in particular, Z80 assembly language. This is a trick I learnt while reverse engineering the Amstrad BASIC interpreter. The …. Read More
Why Your Amstrad CPC Might Crash in 2104!
Recently I was reading the source code of the firmware routine which updates the system TIME in the Amstrad CPC. This code contains a bug which will eventually crash your machine! Read on for the full gory details! Updating the Timer The TIME counter is a is 32-bit wide integer (four bytes) which is updated …. Read More
Passing Code Pointers as Data in Amstrad CPC BASIC
One of my secret coding pleasures is passing a function as a parameter to a subroutine. Most modern languages have what’s called ‘first class code’. That means that you can assign the address of a function to a variable, store it in an array, and pass it as a parameter to a function. This enables …. Read More
How Amstrad CPC BASIC Compresses Error Messages
Amstrad CPC BASIC saves a few bytes by using some interesting compression in the way it stores error messages. Let’s take a look at how it works and how much space it saves. Below is the table of error messages. The messages are stored in what I refer to as ASCII7 format – bit 7 …. Read More
Couch to 64k Part 3: Adding a Character LCD Display to our Z80 Breadboard Computer
In the previous part of this series we attached a ROM chip to our Z80 so we can run programs. But running programs is of little use unless our computer has some way to communicate with the outside world. We need input and output (I/O). In this part we’ll discuss how input and output work …. Read More
Couch to 64k Part 2: Adding ROM to Our Breadboard Z80 Computer
In part one of this series we explored the Z80 processor and found out what various pins do. And we explored a few of the Z80s opcodes by manually feeding them into the data pins. But feeding instructions and data in manually is hard work. We need to add some memory so we can feed …. Read More
Understanding the RC2014 512k ROM 512k RAM Board
The One Where I Show How-It-Works And How To ‘Burn’ Data To The ‘ROM’ (If you want the source code without the waffle here’s the repository). I recently upgraded my RC2014 to use the 512K ROM 512K RAM board available on Tindie). Most people use this board to run RomWbW but I have different plans …. Read More