Skip to content

Instantly share code, notes, and snippets.

@cedriczirtacic
Last active June 13, 2017 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedriczirtacic/77c1ff6267d66abc781042d1d3761dda to your computer and use it in GitHub Desktop.
Save cedriczirtacic/77c1ff6267d66abc781042d1d3761dda to your computer and use it in GitHub Desktop.
yes command in GAS
// gcc -c yes.S -o yes.o && gcc yes.o -o yes
.file "yes.S"
.data
y: .string "y"
.text
.globl main
main:
cmpq $2, %rdi
jl .L1
addq $8, %rsi
movq (%rsi), %rbx
jmp .L2
.L1:
movl $y, %edi // print $y
call puts
jmp .L1
.L2:
movq %rbx, %rdi
call puts
jmp .L2
out:
//going out
xorq %rax, %rax
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment