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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:40:24+00:00 2026-06-03T05:40:24+00:00

I need to increment a number so that the code will increment forever, but

  • 0

I need to increment a number so that the code will increment forever, but it stays zero.

Here is my code:

section .data
FORMAT: db '%c', 0
FORMATDBG: db '%d', 10, 0
EQUAL: db "is equal", 10, 0
repeat:
    push  ecx  ; just to print
    push  FORMATDBG ; just to print
    call  printf ; just to print
    add esp, 8 ; add the spaces
    inc ecx ; increment ecx
    cmp ecx, 0 ; compare ecx to zero
    ja repeat ; if not equal to zero loop again
  • 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-03T05:40:26+00:00Added an answer on June 3, 2026 at 5:40 am
    repeat:
        xor ecx, ecx
        push  ecx  ; just to print
        push  FORMATDBG ; just to print
        call  printf ; just to print
        add esp, 8 ; add the spaces
        inc ecx ; increment ecx
        cmp ecx, 0 ; compare ecx to zero
        ja repeat ; if not equal to zero loop again
    

    xor ecx, ecx sets ecx to zero. I’m not sure if you know this. You probably do not want it to happen on each iteration. Furthermore your loop condition ja repeat currently causes a loop only if ecx > 0 which is probably not what you wanted (or is it?).

    One last thing, printf probably trashes ecx (I am assuming cdecl or stdcall). Read up on call conventions (not sure what compiler/OS you are on) and see which registers are guaranteed to be preserved in function calls.

    In terms of your code, you probably wanted something closer to this:

        xor ebx, ebx
    
    repeat:
        push  ebx  ; just to print
        push  FORMATDBG ; just to print
        call  printf ; just to print
        add esp, 8 ; add the spaces
        inc ebx ; increment ecx
        cmp ebx, 0 ; compare ecx to zero
        ja repeat ; if not equal to zero loop again
    

    This will not cause an infinite loop though. When ebx reaches its maximum value, its value will wrap around back to 0 which will cause the loop condition (ebx>0) to evaluate to false and your loop to be exited.

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

Sidebar

Related Questions

Basically I need to reset Identity Increment for all tables to its original. Here
I have table with an auto-increment field, but I need to transfer the table
I need to write a query that will generate a sort of sequenced ID
I am new to php and I need help with a code that needs
I have some code that uses the Oracle function add_months to increment a Date
I need to add data to a set of images that increments after each
I'm using Postgres, and I have a large number of rows that need to
I have a field representing an Account Number that is anything but a number
I need to increment a float value atomically. I get its int value by
Is there a integer element for a cookie? I need the cookie to increment

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.