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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:57:08+00:00 2026-05-22T17:57:08+00:00

GNU nano 2.2.4 File: argv.s .section .text .globl _start _start: movl %esp, %ebp movl

  • 0
GNU nano 2.2.4               File: argv.s                                     

.section .text

    .globl _start

_start:

    movl    %esp, %ebp

    movl    8(%ebp),%ecx
    movl    $4,%edx
    movl    $1,%ebx
    movl    $4,%eax
    int $0x80

    movl    $1,%eax
    movl    $0,%ebx
    int $0x80

let me preface this question by saying that i’m (obviously) new to asm and any random general advice not related to the topic is welcome…
I meant to simply read in the argv[1] from the bash terminal and print it back out. This was intended to be a test to ensure that I actually knew how to take arguments. If I enter an integer, like 2. The program prints 2O. capital ‘o’, not zero. why?

  • 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-22T17:57:08+00:00Added an answer on May 22, 2026 at 5:57 pm

    You need to understand that argv[1] is not an integer as you would like, but a string terminated null instead! A string is sequence of bytes ending with '\0'.

    This means that when you pass the character 2 through the cmd-line to your app, this string in memory will look like [2][\0], which consists of only 2 bytes. The problem is that you specify the size in %edx as being 4, which is not true, and will make write() print another 2 bytes of memory garbage to your screen.

    The right way to do what you want is implement the strlen() function on your application. This function iterates through the stream of bytes counting how many bytes there are before the character \0 shows up. Only then you’ll be able to print the correct string. Use the number returned by strlen() as %edx when you write().

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

Sidebar

Related Questions

I just started using GNU Emacs as my text editor and I am concerned
GNU sed version 4.1.5 seems to fail with International chars. Here is my input
GNU gcc 4.3 partially supports the upcoming c++0x standard: among the implemented features the
What GNU/Linux command-line tool would I use for performing a search and replace on
The GNU Scientific library has a multi-dimensional function minimization framework. However, its caveats explicitly
Do any C++ GNU standalone classes exist which handle paths cross platform? My applications
What is GNU Screen?
I'm using GNU autotools for the build system on a particular project. I want
I am running GNU Emacs on Windows so entering: M-x shell launches the Windows
We use GNU Make for our system. At the end of our makefiles, we

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.