4 ms·
Need a couple of instructions for accessing memory (and possibly loading immediates) but otherwise seems like a perfectly adequate general-purpose instruction s
by Sharlin 1y ago
Need a couple of instructions for accessing memory (and possibly loading immediates) but otherwise seems like a perfectly adequate general-purpose instruction set. Might be fun (for some values of "fun") to write a compiler backend for it.
- jeffbee 1y agoTons of these have immediate operands. The question becomes is ADD with an implicit register destination and an immediate value in the next byte a "1-byte opcode"?
- Sharlin 1y agoYes, indeed. I'd allow only mov to have a memory or immediate parameter as the only exception to one-byte encoding.
- themafia 1y agoYou've always got the stack segment (SS) to play with and there's also: https://www.felixcloutier.com/x86/xlat:xlatb https://www.felixcloutier.com/x86/xlat:xlatb
- sparkie 1y agoThey're one byte opcodes, but not one byte ops. Most of them have operands which are encoded in a ModRM byte which follows the opcode. The ModRM may be followed by a SIB byte, and that may be followed by a a variable size immediate|displacement. There are also optional prefixes to the opcode.
- benlivengood 1y agoPush, pop, inc, and dec with a 16-bit register argument are one byte, so is ret. That technically gives you enough to do anything, but you can include jz/jnz (which do take immediate bytes, maybe cheating?), stosw, lodsw, clc, and stc to implement Brainfuck (a little harder to perform input/output with single byte instructions, but maybe pretend the OS uses int1 or int3 for calls).