Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 899389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:12:34+00:00 2026-05-15T15:12:34+00:00

This is a homework question. Frankly, I’m not sure how a C program delivers

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:12:35+00:00Added an answer on May 15, 2026 at 3:12 pm

    The short answer is that in C, strings are passed as a pointer to the character data somewhere else. For example, R0 might contain the value 0x01000078, which would be interpreted as a pointer to the "Hallo Alles klar" data in memory, followed by a null character (00 byte).. This is not unique to ARM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.