gpt4 book ai didi

assembly - 汇编指令陷阱有什么作用?

转载 作者:行者123 更新时间:2023-12-05 00:50:21 32 4
gpt4 key购买 nike

A program typically issues a software trap when the program requiresservicing by the operating system. The general exception handler forthe operating system determines the reason for the trap and respondsappropriately.

汇编指令陷阱是否与 BASIC 中的指令 TRAP 相似?答案似乎是肯定的。你能接受还是拒绝我的结论?

“不中断”的代码是根据我的指示:

noint:
PUSH r8
movia r8,0x003b683a # machine code for TRAP
ldw et,-4(ea) # read instr closest to return
cmpeq et,et,r8 # compare
POP r8
bne et,r0,TrapHandler # if equal, jump to traphandler

更新

你可以在 BASIC 中编写 AFAIK,例如

10 TRAP 20

使第 20 行成为处理错误的行。

最佳答案

不确定TRAP在BASIC中的作用,但是您链接的汇编器手册中的TRAP指令会生成可由操作系统处理的硬件异常。

程序员很少需要在他们的代码中使用这条指令。它的典型用途是由调试器在需要停止的点(断点)处插入正在调试的代码中,然后运行/继续程序,并在 TRAP 指令后重新获得控制权到达。

关于assembly - 汇编指令陷阱有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13557371/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com