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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:41:06+00:00 2026-05-14T02:41:06+00:00

I am writing a program in assembly and it isn’t working, so I’d like

  • 0

I am writing a program in assembly and it isn’t working, so I’d like to output variables in x86 functions to ensure that the values are what I expect them to be. Is there a simple way to do this, or is it very complex?

If it makes it simpler, the assembly functions are being used from C functions and are being compiled with 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-14T02:41:07+00:00Added an answer on May 14, 2026 at 2:41 am

    It appears that your question is along the lines of “How can I print out variable values in x86 assembler”. The x86 itself doesn’t know how to do that, because it depends entirely on what output device you’re using (and the specifics of the OS-provided interface to that output device).

    One way of doing it is to use operating system syscalls, as you mentioned yourself in another answer. If you’re on x86 Linux, then you can use the sys_write sys call to write a string to standard output, like this (GNU assembler syntax):

    STR:
        .string "message from assembler\n"
    
    .globl asmfunc
        .type asmfunc, @function
    
    asmfunc:
        movl $4, %eax   # sys_write
        movl $1, %ebx   # stdout
        leal STR, %ecx  #
        movl $23, %edx  # length
        int $0x80       # syscall
    
        ret
    

    However, if you want to print numeric values, then the most flexible method will be to use the printf() function from the C standard library (you mention that you’re calling your assembler rountines from C, so you are probably linking to the standard library anyway). This is an example:

    int_format:
        .string "%d\n"
    
    .globl asmfunc2
        .type asmfunc2, @function
    
    asmfunc2:
        movl $123456, %eax
    
        # print content of %eax as decimal integer
        pusha           # save all registers
        pushl %eax
        pushl $int_format
        call printf
        add $8, %esp    # remove arguments from stack
        popa            # restore saved registers
    
        ret
    

    Two things to note:

    • You need to save and restore registers, because they get clobbered by the call; and
    • When you call a function, the arguments are pushed in right-to-left order.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Linux program that currently compiles and works fine on x86 and
I understand that writing anything in assembly, or adding assembly to any program harms
I'm writing an assembly program that calculates Fibonacci numbers, but I need to find
I'm thinking of writing a program that involves including super fast Assembly or as
I'm in the process of writing an assembly program that takes two strings as
In my MIPs Assembly Programming class I've been tasked with writing a program that
Im writing a program that should read input via stdin, so I have the
I'm writing a program that sends an email out at a client's specific local
If you are writing a program that is executable from the command line, you
I'm writing a program that uses SetWindowRgn to make transparent holes in a window

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.