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

  • SEARCH
  • Home
  • 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 864833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:32:39+00:00 2026-05-15T09:32:39+00:00

I’m taking an operating systems design class in which they have given us a

  • 0

I’m taking an operating systems design class in which they have given us a microkernel written in C that we’re building on top of. The kernel seems to have been designed with 32-bit machines in mind and I’m running snow leopard. So a friend in the class and I have been trying to hack it into 64-bit addressing.

The biggest issue seems to be one line of code, where inline assembly is utilized to copy the current stack pointer into a temporary variable used by the dispatcher:

#define SET_STACK(s) asm("movl temp,%esp");

Naturally, the compiler spits back errors at me because %esp is a 32-bit register.

/var/folders/0A/0AVWZC-5HhOg6twWZBlDgU+++TI/-Tmp-//cckS2oq7.s:523:32-bit absolute addressing is not supported for x86-64
/var/folders/0A/0AVWZC-5HhOg6twWZBlDgU+++TI/-Tmp-//cckS2oq7.s:523:cannot do signed 4 byte relocation

So I replaced it with %rsp because it’s the 64-bit stack pointer register (and I think just %sp works as well, I read somewhere else on here that GAS is smart enough to put the right prefix). After replacing %esp with %rsp, I get this error:

/var/folders/0A/0AVWZC-5HhOg6twWZBlDgU+++TI/-Tmp-//cc8TLdjH.s:523:Incorrect register `%sp' used with `l' suffix

Now, I’m a bit at a loss because I’m not really experienced with assembler. I’ve tried replacing movl with mov, and movq, but nothing seems to work. Which leads me to believe that maybe tempis the wrong size?

Temp is a global variable, declared like so:

void* temp;   // temp pointer used in dispatcher

I wrote a quick program to print out the sizes of different datatypes, and it seems like void* in x86-64 are 8 bytes in size, which should be the right size, right?

Anyway, obviously I don’t expect anyone to solve this problem for me, but any tips that might point me in the right direction would be much appreciated!

  • 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-15T09:32:40+00:00Added an answer on May 15, 2026 at 9:32 am

    You need to use movq for 64bit moves.

    Here is a snippet of assembly doing some SSE work from one of my projects (part of a train simulator), The commented lines are 32bit intel asm, uncommented is 64bit AT&T.

    asm(
            //mykda calculation
            //mov eax, dword ptr [train_traction_ptr]
            //movaps xmm0, xmmword ptr [eax] //train_traction[i] + forceFront
            "movq %0, %%rax\n\t"
            "movaps (%%rax), %%xmm0\n\t"
    
            //mov eax, dword ptr [local_fgrr_ptr]
            //movaps xmm1, xmmword ptr [rax]
            //addps xmm0, xmm1
            "movq %1, %%rax\n\t"
            "movaps (%%rax), %%xmm1\n\t"
            "addps %%xmm1, %%xmm0\n\t"
    
            ... );
    

    After comment I looked further and found that all 64bit OSX code has to be position independant.

    Haven’t got a Mac to test, but

    asm ("movq temp(%rip),%rsp");
    

    Should work. If not, you need to use the appropriate PIC addressing for temp for your assembler.

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

Sidebar

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.