什么是汇编指令陷阱呢? [英] What does the assembly instruction trap do?

查看:322
本文介绍了什么是汇编指令陷阱呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RTFM

一个程序通常发出软件陷阱程序需要时
  由操作系统维护。对于一般的异常处理程序
  操作系统决定的陷阱和响应的原因
  适当。

A program typically issues a software trap when the program requires servicing by the operating system. The general exception handler for the operating system determines the reason for the trap and responds appropriately.

时的汇编指令陷阱都在BASIC指令陷阱?
答案似乎是肯定的。您可以接受或拒绝我的结论呢?

Is the assembly instruction trap alike the instruction TRAP in BASIC? The answer seems to be yes. Can you accept or reject my conclusion?

code无间断是根据我的指示:

Code for "no interruption" is according to my instructions:

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

更新

在AFAIK BASIC你可以写例如

AFAIK in BASIC you can write e.g.

10 TRAP 20

,使排20行用于处理错误。

to make row 20 the row for handling an error.

推荐答案

不知道什么陷阱确实在BASIC,你挂在汇编手册,但在 TRAP 指令生成硬件异常,可以由操作系统来处理

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.

有很少需要一个程序员在他们的code使用此指令。典型的应用是由一个调试器到code。在那里停车需要点(断点)正在调试插入,然后运行/继续程序,并重新控制一旦到达TRAP 指令。

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.

这篇关于什么是汇编指令陷阱呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆