Editing
Bytebeat
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== bytebeat in x86 assembler === <nowiki> ; noise.asm -- just fooling around :-) ; mct and leif, ; Sun Feb 19 19:08:13 PST 2012 ; ; Build with: ; ; nasm -felf32 noise.asm ; ld -melf_i386 -o noise noise.o ; ; Run with: ; ; ./noise | aplay ; ; Equivalent to: ; python -c'import sys;[sys.stdout.write(chr((t>>10^t>>(t>>13)%4)%256)) for t in xrange(2**20)]' |aplay global _start section .data section .bss var: resb 1 ; one bye variable section .text ; f(x) = (x >> 10 ^ x>>((x>>13)%4)) % 256 _start: mov esi, 0 ;int 3 .loop: mov edi, esi shr edi, 13 ; edi := x >> 13 mov eax, edi cwd mov bx, 4 div bx ; dx := (x >> 13) % 4 mov eax, esi mov cx, dx shr eax, cl ; eax := x >> ((x >> 13) % 4) mov edi, esi shr edi, 10 ; edi := x >> 10 xor eax, edi mov [var], al mov eax, 4 ; sys_write mov ebx, 1 ; stdout mov ecx, var ; buffer mov edx, 1 ; length int 80h ; syscall inc esi jmp .loop </nowiki> <nowiki> ### 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 ### 2012-01-10 </nowiki> Compile with gcc -m32 -nostdlib and pipe the output to aplay. After stripping, the ELF is 240 bytes; size(1) says it has 18 bytes of code.
Summary:
Please note that all contributions to Noisebridge are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Noisebridge:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Request account
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Dig in!
Noisebridge
- Status: MOVED
- Donate
- ABOUT
- Accessibility
- Vision
- Blog
Manual
MANUAL
Visitors
Participation
Community Standards
Channels
Operations
Events
EVENTS
Guilds
GUILDS
- Meta
- Electronics
- Fabrication
- Games
- Music
- Library
- Neuro
- Philosophy
- Funding
- Art
- Crypto
- Documentation/Wiki
Wiki
Recent Changes
Random Page
Help
Categories
(Edit)
Tools
What links here
Related changes
Special pages
Page information