yu34567890/bob16pp ? reverse-engineered prompt

Reverse engineered prompt

Build me a simple but fast bob16 emulator in C that stays binary compatible with normal bob16 programs, but also supports the extended arithmetic instructions through trap 4.

I want the base instruction set to behave the same as bob16, including loading programs in little endian, updating the condition codes correctly, and handling the usual traps and branching. Then add the trap 4 expansion so it can read the next word as a second instruction and execute SUB, MUL, IDIV, MOD, INC, DEC, MIN, MAX, and CMP exactly like described, with CMP only setting the flags and not writing a register.

Please keep the code clean and easy to understand, and make it run well with a plain C build. If there is any missing detail from the original bob16 behavior, look it up online if needed and match it as closely as possible. I’d also like a straightforward way to load a binary and run it from the command line, with basic error handling and no unnecessary complexity.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab