.globl main main: push %rbp # keep stack aligned mov $0, %r12 #r12 is sum; initialize loop: # Print the prompt mov $0, %rax # clear AL (zero FP args in XMM registers) leaq prmpt(%rip), %rdi # load format string to proper register call printf # print it # Read int leaq f(%rip), %rdi # load format string leaq val(%rip), %rsi # set storage to address of x call scanf # update the sum mov val(%rip), %rsi # load value from memory add %rsi, %r12 # Add value to the sum # Not efficient as we may add 0 to sum - See sumList2 cmp $0, %rsi # Did they enter 0? jne loop # if not, back to get next value # Report result leaq res(%rip), %rdi # load format string mov %r12, %rsi # must load value from memory!! xor %rax, %rax # Another way to 0 out %rax; wish I knew why call printf #print it pop %rbp ret .data prmpt: .string "Enter an int. 0 Quits >" # Prompt f: .string "%d" # Format for input has only specifiers res: .string "Total:%d\n" val: .long 0 # Variable (global) holding value read