EmbDev.net

Forum: ARM programming with GCC/GNU tools long calls generating in gcc


Author: Bartłomiej Kubica (Guest)
Posted on:

Rate this post
0 useful
not useful
hi,

I'm confused with way how long calls are generated when compiling some 
example code

#pragma long_calls
void *reserve_ram ( void **buf, unsigned int size );
void *release_ram ( void **buf );
#pragma long_calls_off

extern unsigned int *ptr;

unsigned int main (unsigned int msg)
{
   reserve_ram (  &ptr, msg * 4 );
   release_ram ( &ptr );

   return 0;
}

with following options
arm-elf-gcc -mthumb -save-temps -Os -Wall -c main.c

compiler assembled it to

  .code  16
  .file  "main.c"
  .text
  .align  2
  .global  main
  .code  16
  .thumb_func
  .type  main, %function
_main_:
  push  {r4, lr}
  ldr  r4, .L3
  lsl  r1, r0, #2
  ldr  r3, .L3+4
  mov  r0, r4
  bl  .L5
  mov  r0, r4
  ldr  r3, .L3+8
  bl  .L5
  @ sp needed for prologue
  mov  r0, #0
  pop  {r4, pc}
.L4:
  .align  2
.L3:
  .word  ptr
  .word  reserve_ram
  .word  release_ram
  .size  main, .-_main_
  .ident  "GCC: (GNU) 4.3.3"
  .code 16
  .align  1
.L5:
  bx  r3


SO i have a question, is any way to generate calls directly by bx/blx 
instruction?. I mean something like this
/* ... */

_main_:
  push  {r4, lr}
  ldr  r4, .L3
  lsl  r1, r0, #2
  ldr  r3, .L3+4
  mov  r0, r4
  blx  r3
  mov  r0, r4
  ldr  r3, .L3+8
  blx  r3
  @ sp needed for prologue
  mov  r0, #0
  pop  {r4, pc}

/* ... */


regards,
Bartek

Author: A. K. (prx)
Posted on:

Rate this post
0 useful
not useful
You need an ARMv5 architecture for the BLX instruction. If your have, 
tell the compiler about it.

Author: Bartłomiej Kubica (Guest)
Posted on:

Rate this post
0 useful
not useful
i have that architecture. Problem seems to be solved.

thanks,
Bartek

Reply

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.