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 8423585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:45:44+00:00 2026-06-10T03:45:44+00:00

I am trying to write a function in assembly that is callable from Objective-C

  • 0

I am trying to write a function in assembly that is callable from Objective-C code. I’ve gotten simple results by setting %rax and returning directly, but when I try to use the stack to store local variables, I get EXC_BAD_ACCESS. Could someone take a look at this and tell me what’s going wrong? My assembly looks like this:

.global _fn
_fn:
pushq %rbp
movq %rsp, %rbp
subq 0x8, %rsp
addq 0x8, %rsp
popq %rbp
ret

Xcode dumps this and indicates the crash is at sub 0x8,%rsp when I call fn from main:

0x0000000100020000  <+0000>  push   %rbp
0x0000000100020001  <+0001>  mov    %rsp,%rbp
0x0000000100020004  <+0004>  sub    0x8,%rsp
0x000000010002000c  <+0012>  add    0x8,%rsp
0x0000000100020014  <+0020>  pop    %rbp
0x0000000100020015  <+0021>  retq
  • 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-06-10T03:45:46+00:00Added an answer on June 10, 2026 at 3:45 am

    The mere subtraction of 8 from rsp should not cause an exception.

    Most likely you need to prefix the constants with the dollar sign. If you don’t, (g)as will treat those numbers as memory operands at the corresponding addresses.

    And accessing memory at address 8 is usually as good on the x86 platform as a NULL pointer dereference.

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

Sidebar

Related Questions

im trying to write a function that will sanitize data coming from the client
I'm trying to write a function that will remove a query argument from a
I was trying to write a function that deletes a node from the linked
I'm trying to write a function in assembly (but lets assume language agnostic for
I am trying write a function that generates simulated data but if the simulated
I am trying to write a function that will allow me to browse for
I am trying to write a function that can take three parameters: an SqlDataReader,
I'm trying to write a function that will: If there is no region selected,
I am trying to write a function that will output every other attachment caption
Im trying to write a function that counts down to a date which works

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.