.data fmt: .string "%s " .text .extern printf .extern putchar .globl main main: pushl %ebp # save caller's stack frame pointer movl %esp, %ebp # make ebp our stack frame pointer (where esp points) subl $4, %esp # allocate 4 bytes on the stack for our loop counter movl $0, -4(%ebp) # initialize the counter to 0 .L1: movl 12(%ebp), %edx # get second argument (argv) into edx incl -4(%ebp) # increment counter movl -4(%ebp), %ecx cmp 8(%ebp), %ecx # compare against argc jz .L2 # if they are equal bail out movl %ecx, %eax # shl $2, %eax # eax = ecx << 2 addl %eax, %edx # now edx points to argv[i] pushl (%edx) # push argv[i] pushl $fmt # push format string call printf # call printf addl $8, %esp # discard printf's arguments from the stack jmp .L1 # loop to .L1 .L2: pushl $10 # push a newline (ascii 10) call putchar # call putchar to write it addl $4, %esp # discard putchar's arguments from the stack movl %ebp, %esp # deallocate stack variables by reseting esp popl %ebp # restore caller's stack frame xorl %eax, %eax # return 0 ret