Created
January 10, 2012 03:57
-
-
Save kragen/1586826 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 |
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
.
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
Compile with
gcc -nostdlib sierpinski-harmony.s
and, sadly, you have a 485-byte executable that strips down to 240 bytes, even though it only contains 18 bytes of executable code. FreeFull tells me fasm generates smaller executables, but the Whirlwind Tutorial tells me an ELF executable can be as small as 45 bytes. I'm pretty sure you could use its techniques to get this into an executable under 64 bytes.