Assembler function with string return

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everybody,

I am using GCC with AVR Studio 4 and would like to write a function in assembler. Basicaly it is not a big problem but I dont know how to return a string.
I would like to use the funktion like any other functin.
Thus if I hav the assembler function myfunc(input_string*) I want to be able to call it with output_string = myfunc(input_string*); or also strlen(myfunc(input_string*));.
Is there any tutorial that describes that? And where can I find the "Register Usage Guidelines" of the avr-libc-documentation. I seem to be missing something.
Thank you very much for any help.
Best regards
D.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See this recent thread about returning a char array in C. The issues are exactly the same - where is the string located and how long will it live? At the end of the day it's a POINTER to a string that you will be passing round.

https://www.avrfreaks.net/index.p...

EDIT: forgot to paste URL

Last Edited: Wed. May 27, 2009 - 10:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Write the function in C
Compile with cc -S
Hand-optimise the resultant ASM code.
Voila.

You have satisfied all the relevant register conventions and linker information.

And most importantly, you never read the full documentation.

And guess what. It will work with any compiler or cpu family.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, now I have it.
Thaks a lot, that was easyer than I thought.
:-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on then. What was the solution?

Returning a pointer to a static or global array, or the Compiler register conventions?

David.