4 ms·
>you can raise software interrupts/exceptions exception handling requires that some unrelated region of memory is initialized and intact and ready to do the ri
by fsckboy 18d ago
>you can raise software interrupts/exceptions
exception handling requires that some unrelated region of memory is initialized and intact and ready to do the right thing, whatever that is, and that region is outside the scope of your control, it belongs to the operating system or the the embedded ROM, and it may not have been laid out to take care of your case.
assembly/machine code is operating at a lower layer: "I don't know what larger thing I'm a part of, but I know I need to stop."
- rep_lodsb 17d agoIf you don't know anything about the environment the code runs in, you can't rely on what action the undefined opcode handler will take either. (same for any other exception) Some operating systems used them for syscalls.
- fsckboy 17d ago1. you can use the opcode, it's guaranteed. if it does something else, that's not on you. 2. you might know everything about the environments and that's how you know that different environments use different interrupt tables, but you want a code snippet that will not rely on that, so you use this guaranteed opcode.
- rep_lodsb 15d agoUsually, you do know something about the environment that your code runs in. But in the case that you don't, causing an exception (whether "undefined opcode" or anything else) can't be guaranteed to terminate the process, because some operating systems actually did use it for other purposes. The assembly language equivalent of nasal demons :) https://devblogs.microsoft.com/oldnewthing/20041215-00/?p=37003 https://devblogs.microsoft.com/oldnewthing/20041215-00/?p=37...