LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1709|回复: 3

Trap的含义

[复制链接]
发表于 2009-11-18 17:21:55 | 显示全部楼层 |阅读模式
有这么一段英文:
The trap bit (T) can be set or cleared under program control.When trap,a processor trap will occur through location 14 on completion of instruction execution and a new Processor Status Word will be loaded.This bit is especially usefull for debugging programs as it provides an efficient method of installing breakpoints.
请问trap在这里指的是什么意思?一般翻译为“陷阱”或“俘获”。想知道这个位是怎么应用的呢?
这是PDP-11/40 Processor HandBook 里面的一段话,对应的寄存器如下:
15   14  13    12 11          8 7       5   4    3    2    1     0
--------------------------------------------------------------------
|           |           |                |           |  T |  N |  Z |  V |  C |
--------------------------------------------------------------------
15,14:Current Mode
13,12revious Mode
7,6,5riority
4:Trap
3,2,1,0:Condition Codes
麻烦大家解答,谢谢!
发表于 2009-11-18 19:41:24 | 显示全部楼层
I learned trap in troff, but I think the function should be similar.

After you have set a trap at the Nth inch from the top page, troff will automatically execute the macro specified by that trap when you reached that location.

e.g

a simple example of setting headers and footers.
(things between ".de" and ".." are macro content
         
          .de hd                \" Page header
          '  sp .5i
          .  tl 'Title''date'
          '  sp .3i
          ..
          .
          .de fo                \" Page footer
          '  sp 1v
          .  tl ''%''
          '  bp
          ..
          .
          .wh 0   hd            \" trap at top of the page
          .wh -1i fo            \" trap one inch from bottom

say if you write an essay, each page will contain a header and footer since the troff process each page from top to bottom.

hope that helps.
回复 支持 反对

使用道具 举报

发表于 2009-11-18 19:47:02 | 显示全部楼层
According to the excerpt you gave. I think if you write a sequence of instructions, then the things related to that trap will happen whenever 14th line is reached. (the trap bit should be set, of course)

Anyway, I am a mega noob, that can be incorrect!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-11-18 20:05:24 | 显示全部楼层
Thanks!
I still learning yet.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表