Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:01:09+00:00 2026-05-30T05:01:09+00:00

How can I retrieve data from a .long statement? For example: .data data_items: .long

  • 0

How can I retrieve data from a .long statement?
For example:

.data 
data_items:
    .long 3,67,34,222,45,75,54,34,44,33,22,11,66,0

.text

.globl _main
    _main:
         movl    $0, %edi
         movl    data_items(,%edi,4), %eax

Gives a large series of errors about absolute addressing not being allowed in x86_64. How can I access this data? I’m fairly new to assembly, so I apologize if my terminology is confusing.

EDIT: I am using GNU Assembler/GCC

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:01:11+00:00Added an answer on May 30, 2026 at 5:01 am

    The problem is that your data is in the data segment and your code is in the text segment. The linker is set up to require relocatable code, which means you can’t use an absolute address, since you cannot know the absolute address until runtime.

    To use relocatable code, you need to access data_items as an offset from the instruction pointer, rip.

    _main:
         movl    $0, %edi
         leaq    data_items(%rip), %rax
         movl    (%rax,%rdi,4), %eax
    

    The leaq instruction gets the address of data_items using an offset of the instruction pointer, which can be calculated at link time. Then the movl instruction uses that address as the base for loading the data. Note that I used rdi in the addressing. When you write to edi, the upper 32 bits of rdi are automatically cleared, so this will work unmodified as long as the value in edi is unsigned. You could use edi and eax, but that would truncate addresses which use more than 32 bits, and the compiled code would be larger since the default address size is 64 bits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I retrieve the meta data such as Description, Modified/Create Dates etc from
I'm making this method retrieve records from the Data Base. As you can see
I want to retrieve the last row from the data store so how can
I can retrieve the text of a web page, let's say https://stackoverflow.com/questions with some
I know I can retrieve some settings.xml parameters using properties, like, for example ${settings.localRepository}
In asp.net, you can retrieve MULTIPLE datatables from a single call to the database.
I developp a Java application using Windows Desktop Search from which I can retrieve
I'm making an iPhone app in which I retrieve JSON data from http://maps.googleapis.com/maps/api/geocode/json?address=canada&sensor=true ,
I'm trying to retrieve list data from a Sharepoint 2010 server using the webservice
//hi i am trying to retrieve the data from database and display in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.