大佬教程收集整理的这篇文章主要介绍了mmix 中的 setjmp 和 longjmp 实现,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经在 MMIX 中编写了 setjmp 和 longjmp 的实现(假设没有名称修改)。
我也是手工组装的。
任何人都可以发现任何错误吗?
// Memory stack pointer is stored in $254.
// jmp_buf is rO,next address after setjmp call,memory stack pointer,// frame pointer,then possibly other data (for sigsetjmp/siglongjmp).
// rG is preserved over a longjmp call
// (not that it should change over one,anyway)
setjmp IS @
GET $1,rO // FE01000A
STOU $1,$0,0 // AF010000
GET $1,rJ // FE010004
STOU $1,8 // AF010008
STOU $254,16 // AFFE0010
STOU $253,24 // AFFD0018
SETL $0,0 // E3000000
POP 1,0 // F8010000
longjmp IS @
LDOU $254,0 // 8FFE0000
SAVE $255,0 // FAFF0000
GET $1,rG // FE000013
// why 15? We save 13 special registers,two local registers,// and the number 2,as well as any global registers.
// That's 256-rG + 16,and we add only 15 because $255 is the address
// of the saved rGA.
SETL $0,271 // E300010F
SUBU $1,$1,$0 // 26010100
SLU $1,3 // 39000003
// Now $255 is topmost saved register,$255+$1 is bottommost such,// $254 is rO after.
SUBU $0,$254,$1 // 2600FE01
LDOU $2,$255,$1 // 8E02FF01
STOU $2,$1 // AE020001
INCL $1,8 // E7010008
PBNZ $1,@-12 // 5B01FFFD
OR $255,0 // C1FF0000
UNSAVE 0,$255 // FB0000FF
// Now we have restored rO,but not other stuff
LDOU $253,24 // 8FFD0018
LDOU $254,16 // 8FFE0010
LDOU $0,8 // 8F000008
PUT rJ,$0 // F6040000
OR $0,0 // C1000100
POP 1,0 // F8010000
寄存器堆栈是这里的难点。 SAVE
和 UNSAVE
之间的所有内容本质上都只是“正确设置 rO
”;之后,根本不需要时间来修复其他寄存器并返回。
如果您有任何其他问题,我很乐意解释我对该代码的每个 tetra 的原因。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的mmix 中的 setjmp 和 longjmp 实现全部内容,希望文章能够帮你解决mmix 中的 setjmp 和 longjmp 实现所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。