dlkulp
dlkulp

Reputation: 2284

ARM asm equ array length

I'm again trying to do something relatively simple in x86 NASM syntax but I'm having a horrible time finding anything about it in ARM. I'm trying to get the length of a static array so that I have something to compare against in a loop.

This nicely shows that equ is like a #define statement in c but that still doesn't really help me find the length of a static array.

In x86 NASM you'd do this:

SECTION .data
    brownFox:       db "The quick brown fox jumps over the lazy dog!", 10, 0
    brownFox_bytes: equ $-brownFox

In ARM I would assume that there's something similar but I really can't seem to find anything about this. I tried doing this:

.C.0.1569:
    .word 0
    .word 1
    .word 2
    .word 3
    .align 2
@ other stuff like .LC0-2 and main
.L4:    .align 2
.L3:
    .word   .LC0
    .word   .LC1
    .word   .LC2
    .word   .C.0.1569
    .equ    len, $-.L3+16

But that obviously fails as this isn't NASM on x86.

If it helps I'm using Qemu emulating an ARMv7 system running Debian linking with GCC.

Upvotes: 1

Views: 1396

Answers (1)

Jester
Jester

Reputation: 58822

I am somewhat confused about which toolchain you are using. You link the manual for the ARM compiler toolchain but then mention gcc and also your file seems to be gnu syntax. I'll stick with gnu for the time being, and please clarify your question if that's not the case.

In gnu as, the current location symbol is not $ but .. As such, the original nasm example can be rewritten as:

.data
brownFox: .string "The quick brown fox jumps over the lazy dog!\n"
.equ brownFox_bytes, .-brownFox

Similarly for your word data, I just can't figure out what you really wanted there.

PS: you can find the gnu as manual online here.

Upvotes: 1

Related Questions