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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:15:30+00:00 2026-06-17T05:15:30+00:00

This code assembles fine using GCC in terminal: .globl _sub _sub: push %rbp mov

  • 0

This code assembles fine using GCC in terminal:

.globl _sub
_sub:
    push %rbp
    mov %rbp,%rsp
    mov $0xBEEF,%eax
    pop %rbp
    ret

.globl _main

_main:
    push %rbp
    mov %rbp,%rsp
    call _sub
    mov $0,%eax
    pop %rbp
    ret

But when I run the a.out file, I get this error:

Segmentation fault: 11

If I run it in GDB this is the error I get:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000001
0x0000000000000001 in ?? ()

Any ideas as to why this might be happening?

  • 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-17T05:15:32+00:00Added an answer on June 17, 2026 at 5:15 am

    mov %rbp, %rsp corrupts the stack pointer. You probably want mov %rsp, %rbp instead.

    Due to historical reasons, some assemblers consider operands to be left-to-right while others take them right-to-left.

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

Sidebar

Related Questions

I don't understand why this code #include <iostream> using namespace std; int main(){ int
I've been scratching my head over this one for some time. I'm using GCC
Problem: I would like to share code between multiple assemblies. This shared code will
I use this code to load a .Net assembly to PowerShell: [System.Reflection.Assembly]::Load(System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
I have this code to register dlls into my gac Assembly asm = Assembly.LoadFrom(argument);
I am trying to understand this inline assembly code which comes from _hypercall0 here
I'm trying to produce assembly code like this (so that it works with nasm)
The machine I use is 64-bit I wrote assembly code like this: movl $0x12e48ead
I got this piece of Assembly code extracted from some piece of software, but
I'm desperate for a solution to this. I'm trying to develop Assembly code allowing

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.