Skip to content

Instantly share code, notes, and snippets.

@kmcallister
Created April 11, 2013 15:37
Show Gist options
  • Select an option

  • Save kmcallister/5364432 to your computer and use it in GitHub Desktop.

Select an option

Save kmcallister/5364432 to your computer and use it in GitHub Desktop.
maze
# gcc -nostdlib -o maze maze.s && ./maze
.globl _start
_start:
xor %edi, %edi
inc %edi
mov %rsp, %rsi
go:
movl $0xb195e2, (%rsi)
rdtsc
## We use the lowest bit of the cycle counter
## as a coin flip. Shift here first to get
## different patterns, e.g.
# shr $17, %eax
and $1, %al
add %al, 2(%rsi)
mov %edi, %eax
xor %edx, %edx
mov $3, %dl
syscall
jmp go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment