5 ms·
What's your favorite weird CPU instruction? any architecture, any time period
- nickdothutton 5y agoNot an instruction, but a register. The R register on the z80 was a useful source of (somewhat)random numbers.
- vincent-manis 5y agoThe IBM 1401 had instructions for reading a punch card, printing a line on the printer, and punching a card. It also had an instruction (Write, Read, and Punch) that did all 3 at once (this machine had no channels/DMA, so this was how you got overlap). I'm told that watching a program run was funny: the machine would sit silent, then all 3 peripherals would spring into action, and then there would be silence. The past is truly a different world.
- Dr_Jefyll 5y agoPicking up on the "three at once" theme, the 1-bit computer I built in the 1980's has an instruction that does three things. The computer only has one instruction, so I didn't bother to give the instruction a name. But it performs an input, an output and a 2-way branch. I hope this is weird enough to deserve mention in this thread. :) The project was mentioned at least twice previously on HN: https://news.ycombinator.com/item?id=12469790 https://news.ycombinator.com/item?id=12469790 https://news.ycombinator.com/item?id=7616831 https://news.ycombinator.com/item?id=7616831
- coder4life 5y agoMotorola 8-bit 6809 (used in Radio Shack's mid 80s CoCo - Color Computer) HFC - Halt and Catch Fire edit: thought it was branch and....corrected https://x86.fr/investigating-the-halt-and-catch-fire-instruction-on-motorola-6800/ https://x86.fr/investigating-the-halt-and-catch-fire-instruc...
- gabrielsroka 5y agoI think you meant HCF.
- fargle 5y agoPPC: eieio (enforce in-order execution of io)
- perl4ever 5y agoPowerPC also had instructions like "rlwimi." with five operands plus implicitly cr0. It's rather startlingly complex for a "RISC" architecture.
- mikewarot 5y agoXLAT - Table Translate I once used this to speed up text search by a few orders of magnitude in the days of MS-DOS. My search went from 30 seconds to scan 3 Megabytes to faster than disks could read it. (<3 seconds)
- kwertyoowiyop 5y ago68000 - ABCD. Really it’s just the mnemonic that’s nice. It adds BCD numbers.
- fkfeppsk 5y agoPDP-11, a single 1-word (16-bit) instruction that, if run from the top of the RAM, overwrites all of it with copied of itself: MOV -(PC),-(PC)
- convolvatron 5y agobmm - make your own instruction block register transfer - a contiguous block of registers to/from a contiguous block of memory explicit cache manipulation (invalidate, validate w/o read, prefetch) start a thread (Tera MTA) full/empty bits on the MTA (read full blocks on empty memory until its filled)
- rep_lodsb 5y agousername related - read lots of stuff while doing nothing useful with it :) other fun x86 ones: CALL SP will call whatever code has been pushed on the stack. Unlike PUSH SP, it works the same on 8086 and newer CPUs RET -2 (16 bit; -4 or -8 for 32/64 bit) return but leave address on stack LAR load access rights; doesn't trap to kernel, so you can use this in ring3 code to scan through segment selectors and find out which are accessible and what type they are. On any x64 Linux, you can switch between 32 and 64 bit modes via far call, and syscalls will work in both modes (though they use different numbers).
- Doxin 5y agoDo nonexistent CPUs count? Redcode, used in the CoreWars programming game, has a SPL instruction which boils down to "branch both ways". You end up with two execution pointers taking turns. One keeps going as if the SPL is a nop. The other keeps going as if the SPL is an unconditional jump. Of course you're not limited to calling this just the once.