flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > ARM64: differences between "ldr w0,label" & "ldr w0,[label]"

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 16 Mar 2023, 12:50
I'm starting with ARM64 using FASMARM (thanks revolution!) and with FASMG with "aarch64.inc" (thanks tthsqe!)

The following instructions assemble correctly with FASMARM:
Code:
label_ldr:
    ldr x0,label_ldr
    ldr x0,[label_ldr]
    


But with tthsqe's inc, the following is not accepted:

Code:
label_ldr:
    ldr x0,label_ldr    ; ACCEPTED
    ldr x0,[label_ldr]  ; NOT ACCEPTED!
    


1) In any case, what's the difference between those 2 instructions?

2) Am I using an incorrect format for "ldr x0, [label_ldr]" on tthsqe's inc?

Thanks!
Post 16 Mar 2023, 12:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20217
Location: In your JS exploiting you and your system
revolution 16 Mar 2023, 16:18
They are the same instruction.

The bracketed version is the programmer friendly version that is less confusing to the reader. The un-bracketed version is how it is defined it officially.
Post 16 Mar 2023, 16:18
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 16 Mar 2023, 18:41
Thanks revolution!
Post 16 Mar 2023, 18:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20217
Location: In your JS exploiting you and your system
revolution 16 Mar 2023, 19:12
The output binary values can be seen here.
Code:
~ cat ldr.asm
processor cpu64_v8
use64
ldr x0,[$]
ldr x0,$

~ fasmarm -s ldr.fas ldr.asm
flat assembler for ARM  version 1.43 (built on fasm 1.73.02)  (2359008 kilobytes memory)
1 passes, 8 bytes.

~ listing -b 4 ldr.fas ldr.lst

~ cat ldr.lst
                        processor cpu64_v8
                        use64
00000000: 00 00 00 58   ldr x0,[$]
00000004: 00 00 00 58   ldr x0,$    


Last edited by revolution on 17 Mar 2023, 19:00; edited 1 time in total
Post 16 Mar 2023, 19:12
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 17 Mar 2023, 10:19
Great! Good commands for quick check Wink
Post 17 Mar 2023, 10:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.