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 8299755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:16:43+00:00 2026-06-08T16:16:43+00:00

Below is a piece of code I have written in C and in-line assembly

  • 0

Below is a piece of code I have written in C and in-line assembly to load some short values from the array blk to ARM R registers.

...
short *blk; 
... //blk memory allocation and initialization
short tmp0, tmp1, tmp2;
asm volatile (
"ldrh %[tmp0], [%0]\n\t"
"ldrh %[tmp1], [%1]\n\t"
"ldrh %[tmp2], [%2]\n\t"
: [tmp0] "=r" (tmp0), [tmp1] "=r" (tmp1), [tmp2] "=r" (tmp2)
: "m" (blk[0])  , "m" (blk[8]), "m" (blk[8*2])
: 
);

I am getting this error message from arm gcc 4.6

/tmp/ccDEBLCN.s:266: Error: ARM register expected -- `ldrh r3,[[r5,#0]]'

GCC complains about ldrh %[tmp2], [%2] line, but I don’t see why. I took a look at LDRH instruction and it seems to me that my instruction template is right.

Load memory halfword [15:0] from register address + 5-bit immediate offset
LDRH <Rd>, [<Rn>, #<immed_5> * 2]

BTW this is the command I am using to compile this:

arm-none-linux-gnueabi-gcc -O2 -march=armv7-a -mthumb 
  • 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-06-08T16:16:44+00:00Added an answer on June 8, 2026 at 4:16 pm
    asm (
    "ldrh %[tmp0], %[ref0]\n\t"
    "ldrh %[tmp1], %[ref1]\n\t"
    "ldrh %[tmp2], %[ref2]\n\t"
    : [tmp0] "=&r" (tmp0), [tmp1] "=&r" (tmp1), [tmp2] "=r" (tmp2)
    : [ref0] "m" (blk[0])  , [ref1] "m" (blk[8]), [ref2] "m" (blk[8*2])
    : 
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of matlab code below which reads data from a table.
I have a piece of code written in C where some pointer arithmetic is
I have a piece of code (below) that can get the text of an
I have written a piece of code that detects installed application in android and
I have the below piece of code which checks the given key exists in
I have a doubt i use the following piece of code get data from
I have this piece of code for reading from an excel cell: public T
I have below piece of code in my actionscript file (defined in a function)
I have written a piece of code and it runs fine on my system.
I have the below piece of code: $(some_html_stuff).insertAfter('.some_element'); I then have other JS code

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.