Skip to contentSkip to conversation

add with PC in argument

Qemu-devel claude vittoria 3 participants 3 messages Feb 24, 2008 – Feb 25, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

I got a problem in an IRQ handler of mutek OS (https://www-asim.lip6.fr/trac/mutekh), target ARM Integrator/CM 922T-XA10. I try to port it on Qemu. A porting has been done for Skyeyes

So in qemu I don't get the same comportement. The add of lr = pc + 4 gives lr = pc + 8 into qemu. I think that s->pc += 4 at start of disas_arm_insn alters the result.
Could you confirm ?

0x7c    add    lr, pc, #4
0x80    ldr    pc, =SystemInterrupt
0x84    ldr    r3, [sp, #PSR_OFF]  <= never executed in Qemu
0x88    msr    spsr_cxsf, r3        @ put cpsr in SPSR
0x8c    ldmia    sp, {r0-r15}^        @ restore Context

B.R.
Claude

#1 lore raw
Quoted 10 lines · claude vittoria

Hello,

I got a problem in an IRQ handler of mutek OS
(https://www-asim.lip6.fr/trac/mutekh), target ARM Integrator/CM 922T-XA10. I try to port it on Qemu. A porting has been done for Skyeyes

So in qemu I don't get the same comportement. The add of lr = pc + 4 gives lr = pc + 8 into qemu.
I think that s->pc += 4 at start of disas_arm_insn alters the result. Could you confirm ?

All ARM mode instructions (at least, on modern ARMs) read PC as current instruction + 8. The code you've posted looks wrong.

IIRC there were some older ARM processors with a different value.

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery
#2 lore raw
In reply to claude vittoria
Quoted 11 lines · claude vittoria

So in qemu I don't get the same comportement. The add of lr = pc + 4 gives lr = pc + 8 into qemu.
I think that s->pc += 4 at start of disas_arm_insn alters the result. Could you confirm ?

 0x7c    add    lr, pc, #4
 0x80    ldr    pc, =SystemInterrupt
 0x84    ldr    r3, [sp, #PSR_OFF]  <= never executed in Qemu
 0x88    msr    spsr_cxsf, r3        @ put cpsr in SPSR
 0x8c    ldmia    sp, {r0-r15}^        @ restore Context

The add lr,pc, #4 will put 0x88 into lr. As Daniel wrote, in ARM mode, when an instruction which address is addr reads the PC, it will read addr + 8.

Given the mutekh link you provide has no source code for ARM (at least I couldn't find it), we can't guess where the ldr pc jumps to.

Laurent