在ARMv7指令集中,如何确定由于浮点异常之一而发生的未定义指令异常?我还读到,默认情况下VFP单元是禁用的,当VFP指令第一次被应用程序使用时,内核将使用异常处理来启用VFP单元并让应用程序继续运行。我认为这个异常将是未定义的指令异常。我知道未定义的指令也可能是由于其他情况。我在文档ARM DUI 0471C
的128页上读了一些undef处理程序,上面写着
Examine the undefined instruction to see if it has to be emulated. This is similar to the way in which an SVC handler extracts the number of an SVC, but rather than extracting the bottom 24 bits, the emulator must extract bits [27:24]
If bits [27:24] = b1110 or b110x, the instruction is a coprocessor instruction
位字段似乎不能给我准确指示指令是浮点指令,例如位[27:24] of VADD =0010
。因此,这种方法似乎不是解决问题的最佳方法。
根据我在ARM ARM中读取的内容,我可以使用FPEXC.DEX
位来判断这是一个浮点指令异常。但这是在我们启用VFP单元后发生的。我首先需要在undef处理程序中做这个检查。检测浮点指令异常最合适的方法是什么?
发布于 2017-08-24 09:19:23
fpexc.en
位可用于此目的。想法很简单
处理程序看起来很像这样:
ctrl .req r0
push {...}
vmrs ctrl, fpexc // Check vfp status
tst ctrl, #(1 << 30) // fpexc.en
bne .L.undefinedHandler.die // if vfp enabled -> there is another reason for this exception
// enable VFP and try again
ldr ctrl, =fpexc.en.mask // enable vfp
vmsr fpexc, ctrl
// Reloading vfp state & d0-d31 regs
// some code is skipped here
pop {...}
subs pc, lr, #4 // return & try faulty instructions again
.L.undefinedHandler.die:
// F... really unknown instruction
简单地说,指令在禁用VFP和启用VFP的情况下执行两次。有效的VFP指令只会产生一次异常。未知指令将产生两次异常。优点:指令解析是多余的。
PS:有点晚了,但可能对某些人有用:)
https://stackoverflow.com/questions/32520424
复制相似问题