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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:37:24+00:00 2026-05-29T15:37:24+00:00

I was always interested in assembler, however so far I didn’t have a true

  • 0

I was always interested in assembler, however so far I didn’t have a true chance to confront it in a best way. Now, when I do have some time, I began coding some small programs using assembler in a c++, but that’s just small ones, i.e. define x, store it somewhere and so on, so forth. I wanted to implement foor loop in assembler, but I couldn’t make it, so I would like to ask if anyone here has ever done with it, would be nice to share here. Example of some function would be

for(i=0;i<10;i++) { std::cout<< "A"; }

Anyone has some idea how to implement this in a assembler?

edit2: ISA x86

  • 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-29T15:37:31+00:00Added an answer on May 29, 2026 at 3:37 pm

    Here’s the unoptimized output1 of GCC for this code:

    void some_function(void);
    
    int main()
    {
      for (int i = 0; i < 137; ++i) { some_function(); }
    }
    

        movl    $0, 12(%esp)            // i = 0; i is stored at %esp + 12
        jmp .L2
    .L3:
        call    some_function           // some_function()
        addl    $1, 12(%esp)            // ++i
    .L2:
        cmpl    $136, 12(%esp)          // compare i to 136 ...
        jle .L3                         //   ... and repeat loop less-or-equal
    
        movl    $0, %eax                // return 0
        leave                           //  --"--
    

    With optimization -O3, the addition+comparison is turned into subtraction:

        pushl   %ebx          // save %ebx
        movl    $137, %ebx    // set %ebx to 137
    
        // some unrelated parts
    
    .L2:
        call    some_function // some_function()
        subl    $1, %ebx      // subtract 1 from %ebx
        jne .L2               // if not equal to 0, repeat loop
    

    1The generated assembly can be examined by invoking GCC with the -S flag.

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

Sidebar

Related Questions

Something I have always been interested in out of curiosity, is there a tool
I have always been interested in algorithms, sort, crypto, binary trees, data compression, memory
I've always been interested in how you can throw some SQL at database, and
I'm always interested in more efficient ways and learning new things. Right now, I
I have always been interested in how should I implement a multilingual applications and
I have been looking into benchmarking lately, I have always been interested in logging
Always was interested why are Array.Sort() and Array.IndexOf() methods made static and similar ArrayList.Sort()
I always believe they did, but seeing some answers here make me doubt... Can
I always seem to have a hard time starting a new Firefox extension. Can
I'm new to OpenGL and graphics programming in general, though I've always been interested

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.