Skip to content

Instantly share code, notes, and snippets.

@kragen
Created January 10, 2012 03:57
Show Gist options
  • Save kragen/1586826 to your computer and use it in GitHub Desktop.
Save kragen/1586826 to your computer and use it in GitHub Desktop.
### Basic Sierpinski harmony bytebeat t & t >> 8 in as few bytes as possible:
.globl _start
_start: inc %ebx # output fd 1 in %ebx for write()
inc %edx # byte count of 1 in %edx for write()
loop: inc %eax # increment t each time through the loop
push %eax # save it on the stack
and %ah, %al # compute t & t >> 8, our output sample
push %eax # store it on the stack for write()
lea 3(%ebx), %eax # a three-byte way to set %eax to 4 (__NR_write)
mov %esp, %ecx # pass sample pointer to write() (little-endian!)
int $0x80 # invoke system call
pop %eax # discard sample
pop %eax # restore t into %eax
jmp loop # and repeat
### Kragen Javier Sitaker
@kragen
Copy link
Author

kragen commented Jan 10, 2012

I guess I should mention that if you run this, don't print the output out on your screen. Redirect it ./a.out > /dev/dsp or pipe it ./a.out | aplay or | padsp.

@kragen
Copy link
Author

kragen commented Jan 10, 2012

FreeFull wrote an MS-DOS version at http://paste2.org/p/1860182. 11 bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment