最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to use shifter operands in GNU arm assembly syntax? - Stack Overflow

programmeradmin0浏览0评论

I know in arm assembly we can use shifter operands like bellow:

mov r0, r1, lsl #2

I use gcc to compile, therefore I have to adapt syntax.

I already tried this:

mov w0, w1, lsl 2

It didn't work: unexpected characters following instruction at operand 2. To me it says it can't handle the third operand.

Is there any alternative syntax that does the same job in gnu?

I know in arm assembly we can use shifter operands like bellow:

mov r0, r1, lsl #2

I use gcc to compile, therefore I have to adapt syntax.

I already tried this:

mov w0, w1, lsl 2

It didn't work: unexpected characters following instruction at operand 2. To me it says it can't handle the third operand.

Is there any alternative syntax that does the same job in gnu?

Share Improve this question asked Nov 19, 2024 at 16:39 imahmadrezasimahmadrezas 33 bronze badges 1
  • 3 That is not a question of gnu or not gnu. That is a question of 32 or 64 bit arm. mov r0, r1, lsl #2 works fine with gnu assembler for ARM. It does not assemble for aarch64. Decide if you want 32 or 64 bit. If 32 bit, use 32 bit ARM binutils. If 64 bit, rewrite the code (e.g. lsl w0, w1, 2) – Jester Commented Nov 19, 2024 at 17:29
Add a comment  | 

1 Answer 1

Reset to default 1

mov r0, r1, lsl #2 works fine for me in gnu as.

I have GNU assembler (2.35.2-2+14+b2) 2.35.2

Probably you didn't specify the correct command line flags or options in the file.

Try adding to the top of your file something like:

.syntax   unified
.cpu      cortex-m4
发布评论

评论列表(0)

  1. 暂无评论