3 ms·
> because Assembly doesn't have UB To be pedantic, old hardware like 6502 family chips (Commodore 64, Apple II, etc) had illegal instructions which were often
by redox99 5mo ago
> because Assembly doesn't have UB
To be pedantic, old hardware like 6502 family chips (Commodore 64, Apple II, etc) had illegal instructions which were often used by programmers, but it was completely up to the chip to do whatever it wanted with those like with UB.
- zahlman 5mo ago> illegal instructions... were often used by programmers Intentionally, with an expected effect? I'd need a citation for that.
- chuckadams 5mo agoSome desultory googling turned up: * https://www.nesdev.org/wiki/CPU_unofficial_opcodes#Games_using_unofficial_opcodes https://www.nesdev.org/wiki/CPU_unofficial_opcodes#Games_usi... * https://hitmen.c02.at/files/docs/c64/NoMoreSecrets-NMOS6510UnintendedOpcodes-20162412.pdf https://hitmen.c02.at/files/docs/c64/NoMoreSecrets-NMOS6510U... (doesn't name any software, but some copy protection schemes were already known to use them)
- boomlinde 5mo agoYes, many of those are perfectly stable. For example, the 6502 has an undocumented instruction commonly known as "LAX" which loads both the A and X registers at the same time in a predictable manner in most addressing modes, in the same time and space it would otherwise take to load either of those registers on their own. The benefits of being able to do stuff like this when you need to conserve resources are obvious, and common idioms have formed around their use. Check out https://csdb.dk/release/?id=198357 https://csdb.dk/release/?id=198357
- vardump 5mo agoSome instructions were very useful and they were simply discovered by programmers who tried out what each instruction did. People did not necessarily have access to documentation those days! So any instruction or hardware feature would get used, whether it's "officially" documented or not.