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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:50:05+00:00 2026-05-31T08:50:05+00:00

C code: #include <stdio.h> main() { int i; for (i = 0; i <

  • 0

C code:

#include <stdio.h>

main() {
    int i;
    for (i = 0; i < 10; i++) {
        printf("%s\n", "hello");
    }
}

ASM:

    .file   "simple_loop.c"
    .section    .rodata
.LC0:
    .string "hello"
    .text
    .globl  main
    .type   main, @function
main:
.LFB0:
    .cfi_startproc
    pushl   %ebp # push ebp onto stack
    .cfi_def_cfa_offset 8
    .cfi_offset 5, -8
    movl    %esp, %ebp # setup base pointer or stack ?
    .cfi_def_cfa_register 5
    andl    $-16, %esp # ? 
    subl    $32, %esp # ?
    movl    $0, 28(%esp) # i = 0
    jmp .L2
.L3:
    movl    $.LC0, (%esp) # point stack pointer to "hello" ?
    call    puts # print "hello"
    addl    $1, 28(%esp) # i++
.L2:
    cmpl    $9, 28(%esp) # if i < 9
    jle .L3              # goto l3
    leave
    .cfi_restore 5
    .cfi_def_cfa 4, 4
    ret

So I am trying to improve my understanding of x86 assembly code. For the above code, I marked off what I believe I understand. As for the question marked content, could someone share some light? Also, if any of my comments are off, please let me know.

  • 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-31T08:50:06+00:00Added an answer on May 31, 2026 at 8:50 am
    andl    $-16, %esp # ? 
    subl    $32, %esp # ?
    

    This reserves some space on the stack. First, the andl instruction rounds the %esp register down to the next lowest multiple of 16 bytes (exercise: find out what the binary value of -16 is to see why). Then, the subl instruction moves the stack pointer down a bit further (32 bytes), reserving some more space (which it will use next). I suspect this rounding is done so that access through the %esp register is slightly more efficient (but you’d have to inspect your processor data sheets to figure out why).

    movl    $.LC0, (%esp) # point stack pointer to "hello" ?
    

    This places the address of the string "hello" onto the stack (this instruction doesn’t change the value of the %esp register itself). Apparently your compiler considers it more efficient to move data onto the stack directly, rather than to use the push instruction.

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

Sidebar

Related Questions

My C Program Code: #include <stdio.h> int main(void) { printf(Content-Type: text/plain;charset=us-ascii\n\n); printf(Hello world\n\n); return
I have the following code: #include <stdio.h> int main() { printf ("hello world\n"); return
#include<stdio.h> int main() { char a[5]=hello; puts(a); //prints hello } Why does the code
Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i
Here is my code: #include <stdio.h> int main(void) { FILE *fp; unsigned int i;
The following code outputs Illegal seek: #include <stdio.h> #include <errno.h> #include <string.h> int main()
I have written a simple Hello World program. #include <stdio.h> int main() { printf(Hello
Say I have the following c program: #include <stdio.h> int main() { printf(Hello world
When I use this code: #include <stdio.h> #define STR(x) #x int main(void) { printf(__FILE__
I have C code like this: #include<stdio.h> int main() { printf(Hey this is my

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.