12 January 2025
Last week a friend shared the existence of hlorenzi’s customasm, a tool that can serve as the assembler for arbitrary CPU architectures just by defining a mapping of instructions to encodings.
Hey, I made a CPU once! How hard would it be to make a customasm definition for ROSE-8? Turns out…not very! I played around with it for about two hours, and by the end of it I’d translated an entire ROSE-8 program to customasm, with most of the definition file looking basically the same as the text reference for the ISA encoding.
(Continue reading…)
Posted in Technical.
Tags:
ROSE-8,
Assembly
14 May 2022
POV: You are a compiler targeting arm64, and you want some code to reference this global variable from the same library. The classic way to do this is to emit an instruction that loads “the address of X”, which will be determined at run time by the dynamic loader. But that’s not super efficient! For one thing, addresses are 64 bits long, and instructions are only 32 bits, so you can either break it up into multiple instructions, or load the address from some other location. But more importantly, the global variable is in the same library. The dynamic loader isn’t going to break it up from this code, and if we knew how far away it was we could reference it that way.
That’s what the adrp instruction’s for.
(Continue reading…)
Posted in Technical.
Tags:
Assembly,
Debugging,
Objective-C
28 January 2020
A few weeks ago I got sucked into designing a toy 8-bit CPU, ROSE-8, and got as far as writing an emulator for the machine that you could manually feed instructions to. At the end, I listed some future projects, the first of which was
- An assembler/interpreter, i.e. running from a text file (and outputting to a binary file, I guess). Writing arrays of instructions by hand (as shown above) isn’t so bad except for manually computing addresses and offsets, so I still want to get to this at some point.
(Continue reading…)
Posted in Technical.
Tags:
Assembly,
Source code,
ROSE-8