there is one very important thing to remember: If you are planning to return from a procedure (with the RET instruction), don't jump to it! As in "never!" Doing that will cause a segmentation fault on Linux (which is OK – all your program does is terminate), but in DOS it may blow up in your face with various degrees of terribleness.
但我不明白为什么会导致段错误。听起来就像从函数返回一样。
我有一种情况需要实现逻辑“如果 X 发生,调用过程 A。否则,调用过程 B。”除了像袋鼠一样跳来跳去编意大利面代码,还有什么办法吗?
最佳答案
因为 CALL
将当前指令地址压入堆栈,而 RET
将其拉出以返回调用点。 JMP
(及相关指令)不会将任何内容压入堆栈。
关于linux - 汇编:为什么跳转到通过 ret 返回的标签会导致段错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9847706/