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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:14:57+00:00 2026-06-05T00:14:57+00:00

I am reading some linux assembly manuals and found idea about using printf() function.

  • 0

I am reading some linux assembly manuals and found idea about using printf() function. I need it to output register values for debugging reasons in binary form to terminal, but now I am tried simply to test that function with text.

I am stuck, because of segfault when I am using pushq instead of pushl. How can I change this program to output strings and binary form of registers?

.data
input_prompt:
    .string "Hello, world!"

printf_format:
    .string "%5d "

printf_newline:
    .string "\n"

size:
    .long 0

.text
.globl main
main:
    pushq $input_prompt
    call  printf

    movl  $0, %eax
    ret

It was compiled by GCC as:

gcc tmp.S -o tmp
  • 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-05T00:14:59+00:00Added an answer on June 5, 2026 at 12:14 am

    Linux (and Windows) x86-64 calling convention has the first few arguments not on the stack, but in registers instead

    See http://www.x86-64.org/documentation/abi.pdf (page 20)

    Specifically:

    1. If the class is MEMORY, pass the argument on the stack.
    2. If the class is INTEGER, the next available register of the sequence %rdi, %rsi, %rdx, %rcx, %r8 and %r9 is used.
    3. If the class is SSE, the next available vector register is used, the registers are taken in the order from %xmm0 to %xmm7.
    4. If the class is SSEUP, the eightbyte is passed in the next available eightbyte chunk of the last used vector register.
    5. If the class is X87, X87UP or COMPLEX_X87, it is passed in memory.

    The INTEGER class is anything that will fit in a general purpose register, so that’s what you would use for string pointers as well.

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

Sidebar

Related Questions

Okay, I'm reading about Linux kernel development and there are some code snippets using
When reading some documentation about assertions, I found: java -ea -dsa Enables assertions in
I remember reading some books about Linux Device drivers around the end of my
Reading some questions here on SO about conversion operators and constructors got me thinking
When reading some FreeBSD source code (See: radix.h lines 158-173), I found variable declarations
After reading some articles about XSS I have incorporated HTMLPurifier into my zend framework
I'm reading some XML with PHP and currently using the DOMDocument class to do
I have been reading about out of memory conditions on Linux, and the following
I have created some application, which is reading from System.in using the following method:
Recently, I am reading some Linux kernel space codes, I see this uint64_t used;

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.