Author Archives: Harald Haugli
LLVM Exercise IV
How about calling another function: int foo() { return 0xFF; } int bar() { return foo(); } Code snippets: … def CC_HP41MCODE : CallingConv<[]>; … def SDT_HP41MCODENCXQ : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>; def HP41MCODENCXQ : SDNode<“HP41MCODEISD::NCXQ”, SDT_HP41MCODENCXQ, [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, SDNPVariadic]>; … def calltarget : Operand; … let isCall=1 in { def NCXQ : HP41MCODEInst<0x001, … Continue reading
Superdense Coding Emulation on a TI-84 Plus CE-T
This is sort of the opposite of the Quantum Teleportation we have covered earlier. Here you use quantum bits to transfer classical bits: We have all the building blocks we need from the previous episode, so let me just show you the additional code: #Alice bits a1=1 a2=1 print(“Alice bits:”,a1,a2) #Initialize inputs q=[[1],[0],[0],[0]] #Build circuit … Continue reading
LLVM Exercise III
Let us return a larger constant: int foo() { return 0xFF; } For numbers up to 12 bits we can use the LDI S&X instruction. Some code snippets: def immSExt12 : PatLeaf<(imm), [{ return isInt<12>(N->getSExtValue()); }]>; def : Pat<(i32 immSExt12:$in), (LDI imm:$in)>; def LDI : HP41MCODEInst<0x130, (outs RC:$r), (ins i32imm:$sx), “LDI S&X HEX: $sx”, [(set … Continue reading
LLVM Exercise II
A tiny addition to the empty function. Returning zero: int foo() { return 0; } Remember, we will not care about returning values to the calculator registers (at not least for now). We will only generate functions callable from MCODE. So as a convention we will choose to return values in the C register. So … Continue reading
LLVM Exercise I
How to make a compiler? As an exercise I have already threatened to produce at least some assembly code for the Nut CPU used in the HP-41 calculator. There will be huge compromises (it is after all just an exercise): I will copy and strip down an existing compiler backend in the LLVM project, then … Continue reading
HP-41CV Microcode
The HP-41 calculators can be programmed with microcode, aka MCODE. This is how their normal instructions are implemented. The emulator even has an MCODE console where you can step though its instructions. On the physical machine running your own MCODE requires making ROMs (or something that pretends to be a ROM…). I am not familiar … Continue reading
More Synthetic Programming on the HP-41CV
If you have the PPC ROM synthesizing instructions is much easier, and you don’t have to “jailbreak” the calculator. I believe assemblers/compilers that also work with the emulator makes this even easier. I have actually not tested this, but I do think they support synthetic instructions.
Synthetic Programming on the HP-41CV
One of the most fun things to do on an HP-41 is to start utilizing instructions you cannot key in but that still are actually functioning codes. Slicing bytecodes together to make these instructions is called “Synthetic Programming”, as they will have to be “synthesized” in some more or less artificial manner than using the … Continue reading
More Calculator Emulators
There is actually an online emulator for my very first programmable calculator, the TI-51 III, aka TI-55. Just start pushing buttons! Even the on/off switch works.
Calculator Emulators
The TI screenshots below were downloaded from the “TI-SmartView CE-T Emulator Software”, as getting screenshots from the calculator itself does not work regardless of connection method. The HP screenshots were taken in the “V41” virtual HP-41. Programs were also downloaded from the emulator and decompiled using “HP41UC“, an ancient 16-bit HP-41 compiler/decompiler that today must … Continue reading