A few months ago I was thinking again about Pavel Panchenka’s (LLM-assisted) “We’d be Better Off with 9-bit Bytes”, which posits that standardizing on nine-bit bytes would have saved us from a number of encodings running out of space while not having much of a downside. They’re even historically plausible given the PDP machines from DEC with 18-bit and 36-bit words. But what would the impact have been on small systems, those that got the most out of every byte, if not necessarily every bit?
ROSE-8 in customasm
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.
Relative References in ARM64 Disassembly
POV: You are a compiler targeting arm641, 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 code2, and if we knew how far away it was we could reference it that way.
That’s what the adrp instruction’s for.
Older Posts
- 2020-01-28 ROSE-8: Console Mode
- 2020-01-13 ROSE-8
- 2016-05-23 So You Want to Be a (Compiler) Wizard