Closed DipeshChouhan closed 1 year ago
No, it reads the word at address r0 into the pc, just as described in the test.
t513:
; ARM 10: Load empty rlist
adr r0, t514
str r0, [mem]
mov r0, mem
dw 0xE8B00000 ; ldmia r0!, {}
f513:
m_exit 513
t514:
Is it adr instruction. My decoder decoding it as add instruction
The adr
instruction loads the address of label t514
into r0
. This is done by the assembler and ends up being an add
instruction.
Sorry for asking another question but which instruction is going to load pc. My emulator just exit with 513 code. Is pc (r15) included in ldmia r0!, {}
ldm with an empty register list loads from the base register into r15 and updates the base register by +/- 64 (if writeback is enabled). This is likely due to quirks in how the hardware finds the next set bit in the register list (trailing zero count) as well as how it computes the sum of set bits (population count) when the register list is empty.
Is it undefined behavior
Yes, it is. You don't need it for an emulator, but I included it out of curiosity.
Thanks for your help.
Is it always going to fail. Because pc is never updated for next instruction. ldmia r0!, {}