public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
To: noloader@gmail.com, gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: invalid 'asm': invalid operand for code 'H'
Date: Mon, 09 Jul 2018 09:46:00 -0000	[thread overview]
Message-ID: <34f026e1-4399-2097-d87f-66017a414235@arm.com> (raw)
In-Reply-To: <CAH8yC8nw9v_1wMJJZLP+qFSBZ3PKFyGt__sJ7q0rAmEHGDLkzA@mail.gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1396 bytes --]

On 08/07/18 06:03, Jeffrey Walton wrote:
> Hi Everyone,
> 
> I'm working from an ARM guide. The doc provides this code:
> 
> $ cat move.c
> int main(int argc, char* argv[])
> {
>     int a;
>     asm volatile("movw %0,%L1 \n"
>                  "movt %0,%H1 \n"
>                  : "=r"(a) : "i"(0x12345678));
>     return a;
> }
> 
> It results in:
> 
> $ gcc -march=armv7 move.c
> move.c: In function ‘main’:
> move.c:4:5: error: invalid 'asm': invalid operand for code 'H'
>      asm volatile("movw %0,%L1 \n"
>      ^
> 
> The guide says this about the modifiers:
> 
> L - The lowest-numbered register of a register pair, or the low 16
> bits of an immediate constant.
> H - The highest-numbered register of a register pair, or the high 16
> bits of an immediate constant
> ....
> 
> Is this an ARM extension not present in GCC? Or am I doing something wrong?
> 
> Jeff
> 

The L and H modifiers are for dealing with 64-bit /register/ quantities
where you need two registers to hold the entire value.  Your example
only has a single 32-bit value.  You don't need qualifiers in this case.
 For an immediate like this, you'll have to hand-code the reduction into
the appropriate fields, either in the operands you pass to the ASM or
within the ASM expansion itself.  Something like:

asm volatile ("movw %0, %1;movt %0, %2": "=r"(a) : "i"(imm & 0xffff),
"i" (imm & 0xffff0000));

R.

  reply	other threads:[~2018-07-09  9:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-08  5:03 Jeffrey Walton
2018-07-09  9:46 ` Richard Earnshaw (lists) [this message]
2018-07-09  9:53   ` Richard Earnshaw (lists)
2018-07-09 11:53     ` Jeffrey Walton
2018-07-09 12:48       ` U.Mutlu
2018-07-09 12:53       ` Richard Earnshaw (lists)
2018-07-09 16:57       ` Richard Earnshaw (lists)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34f026e1-4399-2097-d87f-66017a414235@arm.com \
    --to=richard.earnshaw@arm.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=noloader@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).