This is a homework question. Frankly, I'm not sure how a C program delivers a string parameter to the assembly level.
I have the function
StringSearchInString( text, searchString);
and the parameters
text = "Hallo Alles klar"
searchString = "ll"
I know ARM delivers the parameters into register R0, R1 respectively for text, searchString, but I'm not sure how this works with charactesr. If each character is 8 bits in length, then the register is mercilessly slaughtered by the incoming string.
I have since read that the ARM APCS converts the arguments as words, of which the first 4 bytes are stored in the register and the rest are loaded in reverse order on the stack.
Sooo... what? I'm not understanding this. The string text
would be stored in R0, the first four bytes, "Hall" are stored in R0, and the rest in reverse order on the stack? Am I understanding that right? How do I call them?
TL;DR: How do I pass a string argument from a C-Program into assembly and how do I work/load/do stuff with it?
ANSWER:
In the remote case that anybody is looking for a solution to this as well, here it is:
As Greg Hewgill has said, strings are passed as a pointer to the string. Therefore, the value in R0 is an address to the string. You therefore use indirect addressing to access the value like so:
StringSearchInString( text, searchString ); // calls the ARM function...
//Going into the ARM function...
LDRB R4, [R0], #1 // Load the first value of R0 into R4 and skip
// ahead one character(8 bits)
// Note the "B" in LDR. It indicates that you load ONLY 1 byte!
MOV R0, R4 // Move the value of R4 into R0. This destroys the pointer
// Stored in R0! Careful!
And success! If your string is "hallo Alles klar" like mine, you will have 0x68 loaded into register R0. This is the ASCII value of "h". From this you should be able to start working with strings.