Forum: ARM programming with GCC/GNU tools Debugging on Arm9 LDMIA instruction is crashes my program execution when its time to return

Author: wellington machingauta (Company: Newcastle university) (wellyjinx)
Posted on:

Rate this post
0 useful
not useful
STMDB and LDMIA are not popping and pushing correctly hence my program 
execution crashes at this instruction

I am using GCC 4.3.2 tools to make an elf file for an Arm9 
"arm926ej-s"(at91sam9261) the example Disassemble is as listed below

    4378:  e5931000   ldr  r1, [r3]
    437c:  e5d12036   ldrb  r2, [r1, #54]
    4380:  e3cc30ff   bic  r3, ip, #255  ; 0xff
    4384:  e152042c   cmp  r2, ip, lsr #8
    .This Code left for as its not neccessary
    43b8:  e8bd8070   pop  {r4, r5, r6, pc}
    43bc:  ebfff066   bl  55c <OS_CPU_SR_Restore>
    43c0:  e5c56000   strb  r6, [r5]
    43c4:  e3a00001   mov  r0, #1  ; 0x1
    43c8:  e8bd8070   pop  {r4, r5, r6, pc}
    43cc:  000219e4   .word  0x000219e4
    43d0:  000219e8   .word  0x000219e

When I debug the image on an ARM at91Sam The program loses control at 
instruction 43c8(pop  {r4, pc}, In the debugger this instruction is 
dissassembled to:
     LDMIA  R13!, {R4, PC}
Which is a thumb instruction, how can i enforce that this is not used if 
it is the source of my problems

Author: alibaba (Guest)
Posted on:

Rate this post
0 useful
not useful
could be a stack overflow. If you say execution crashes, what 
exception/interrupt vector is the processor going to?

Author: wellington machingauta (Company: Newcastle university) (wellyjinx)
Posted on:

Rate this post
0 useful
not useful
Thank you for the reply. The program does not point to an interrupt.
its actually the PC that runs wild after loading from an address with no 
valid instruction, I have since found out more, and need help to fix the 
problem with the stack pointer and memory/RAM that is addressable. If i 
move the stack pointer to a lower address than 00027A00 the program 
executes fine for a while until reset and SP goes back to that address 
range. The STMDB/STMFD instruction is unable to write to the address 
that the SP will be pointing to, then on the POP instruction the 
"2A2A2A2A" is loaded as PC

I arm trying to run the uC-OS II that I have compiled on this board, . 
I have made a simple startup file and linker script from the templates 
online, examples smaller size


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.