What does the assembly instruction trap do?

心不动则不痛 提交于 2019-12-07 15:38:28

Not sure what TRAP does in BASIC, but the TRAP instruction in the assembler manual that you linked generates a hardware exception that can be handled by the operating system.

There is rarely need for a programmer to use this instruction in their code. The typical use of it is to be inserted by a debugger into the code being debugged at the point where a stop is desired (breakpoint), then running/continuing the program, and regaining control once the TRAP instruction is reached.

User processes can transition into the operating system kernel voluntarily, to request that the kernel do some operation on the user’s behalf. A system call is any procedure provided by the kernel that can be called from user-level. Most processors implement system calls using a special trap instruction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!