Specifying an array in Assembler

I want to specify a 512 x 32 bit array in the assembly file, and it looks like this:

#define FUNCTION_01     test
#define LABEL_01(name)  .L ## test ## _ ## name

  .section ".data"
  my_array:
  .word 0x10101010
  .word 0x20101010
  .word 0x30101010
  .word 0x40101010
  ...

    .section ".text"
    .align 4
    .global FUNCTION_01
    .type   FUNCTION_01,#function

FUNCTION_01:

  add  %g0, 12, %l7           
  ld   [%l7 + my_array], %l7
  ...      
    ret
    restore

    LABEL_01(end):
    .size    FUNCTION_01,LABEL_01(end)-FUNCTION 

So what I'm trying to do in function_01 is to access the 4th element in my array. However, when I try to compile the assembly above for the SPARC architecture, I get the following error:

(.text+0x75c): relocation truncated to fit: R_SPARC_13 against `.data'
collect2: ld returned 1 exit status

Not sure what to do with this error. Does this mean that the array is large or something else is wrong in the code?

+3
source share
2 answers

WARNING: I have never used the assembly of sparks, but, seeing no one else answered, I did a quick tutorial to find out if I can help.

, ld 4KiB . , , . , , 4 KiB . , , % l7 12 ld. set ( , sethi or.).

set  my_array,%l7
ld   [%l7 + 12],%l7
+2

ld [%l7 + my_array], %l7 32- , ( ) 13- my_array (.. ). - , , 32- 13- ...

32- , , sethi ( 22 ) or ( 10 ). :

sethi  %hi(my_array), %l7
or     %l7, %lo(my_array), %l7
ld     [%l7+12], %l7

. - set:

set    my_array, %l7
ld     [%l7+12], %l7

. sethi 22- or 10- . , , my_array, , , . . ( .so), .

0

All Articles