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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:23:15+00:00 2026-06-12T21:23:15+00:00

I am writing a program to get an integer from the user, and then

  • 0

I am writing a program to get an integer from the user, and then print out all the numbers from 0 up to the number. My code gets the input fine, but when printing it out, it prints continuously in what seems to be an endless loop. Here is my code:

SECTION .data           ; Constant variable declaration
len   EQU 32        ; Constant length
msg db "Enter a number: ", 0 ; Input message
msglen EQU $-msg             ; Input message length

SECTION .bss            ; Uninitialised data declaration
other resd len      ; Output counter that is incremented
data  resd len      ; Input data buffer 

SECTION .text           ; Main program initialiser

GLOBAL _start           ; Linker entry point declaration
_start:                 ; Entry point
nop                 ; This keeps the debugger happy :)

Msg:                    ; This section prints out the message
mov eax, 4          ; }
mov ebx, 1          ; }
mov ecx, msg        ; } System_write call
mov edx, msglen     ; }
int 80h             ; }

input:                  ; This section gets the integer from the user
mov eax, 3          ; }
mov ebx, 0          ; }
mov ecx, data       ; } System_read call
mov edx, len        ; }
int 80h             ; }

ASCIIAdj:   
mov ebp, 48         ; This line sets the counter to '0' ASCII

setup:                  ; This section adjusts the counter
mov [other], ebp    ; Increment counter 

loop:                   ; This section loops, printing out from zero to the number given
mov eax, 4          ; }
mov ebx, 1          ; }
mov ecx, other      ; } System_write call
mov edx, len        ; }
int 80h             ; }
mov eax, 1          ; Move 1 to eax
add ebp, eax        ; Add eax to ebp (essentially increment ebp)
    mov eax, other      ; move other to eax
    mov ebx, data       ; move data to ebx
    cmp eax, ebx        ; compare them
jne setup           ; If they are not the same, go back to the setup to increment other

exit:                   ; Exits the program
mov eax, 1          ; }
mov ebx, 0          ; } System_exit call
int 80h             ; }

Why does it loop continuously? I have incremented the counter, and compared the input and the counter, so why doesn’t it break?

Thanks in advance

EDIT:
Expected Output:

Enter a number: 6
0123456

General Semantics of the program:

Display "Enter a number: "
Read in an integer less than 32 bytes in size.
Set a counter variable to the ASCII value of zero
Loop:
Display the character, adding 1 to it, and checking to see if it is equal to the value    inputted.
If it is equal, goto the exit section and exit
Else loop.
  • 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-12T21:23:17+00:00Added an answer on June 12, 2026 at 9:23 pm

    This is digging waaaay back into the deep dark recesses of my memory, but I think you want

    mov eax, [other]      ; move other to eax
    mov ebx, [data]       ; move data to ebx
    

    Note the brackets, which are missing in your code. You are loading the addresses of other and data into eax and ebx, not the values contained there.

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

Sidebar

Related Questions

I'm writing a very simple program where I want to get user input from
I'm writing a program where I get information from a page and put it
I am writing a program where a user inputs a number in base 10
I'm writing a program that list the digits of integer input. example: Please enter
I'm writing a program and I multiply numbers by 5... For example: var i:integer;
I am writing a simple shell program that must take input from a file
I am writing a program where the input will be taken from stdin. The
I am writing a program that read string and integers from file, then copy
Hey guys I'm writing a simple web program to get my feet wet in
Im writing a program that should read input via stdin, so I have the

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.