Skip to content

Instantly share code, notes, and snippets.

@badcc
Created July 6, 2015 04:47
Show Gist options
  • Save badcc/cd2dc809bdc88f1ccb76 to your computer and use it in GitHub Desktop.
Save badcc/cd2dc809bdc88f1ccb76 to your computer and use it in GitHub Desktop.
Multiply Passed Arguments Together (x86, GAS)
.intel_syntax noprefix
.global main
.format:
.asciz "%d\n"
main:
xor rbx, rbx
inc rbx
add rsi, 8
dec rdi
print:
push rdi
push rsi
mov rdi, [rsi]
call atoi
mov rcx, rax
pop rsi
pop rdi
imul rbx, rcx
push rdi
push rsi
sub rsp, 8
mov rdi, OFFSET FLAT: .format
mov rsi, rbx
call printf
add rsp, 8
pop rsi
pop rdi
add rsi, 8
dec rdi
jnz print
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment