Bytebeat: Difference between revisions
Jump to navigation
Jump to search
Created page with ' ; 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 …' |
No edit summary |
||
| Line 1: | Line 1: | ||
<nowiki> | |||
; noise.asm -- just fooling around :-) | ; noise.asm -- just fooling around :-) | ||
; mct and leif, ; Sun Feb 19 19:08:13 PST 2012 | ; mct and leif, ; Sun Feb 19 19:08:13 PST 2012 | ||
; | ; | ||
; Build with: | ; Build with: | ||
; | ; | ||
; nasm -felf32 noise.asm | ; nasm -felf32 noise.asm | ||
; ld -melf_i386 -o noise noise.o | ; ld -melf_i386 -o noise noise.o | ||
| Line 10: | Line 11: | ||
; Run with: | ; Run with: | ||
; | ; | ||
; | ; ./noise | aplay | ||
global _start | global _start | ||
| Line 27: | Line 27: | ||
_start: mov esi, 0 | _start: mov esi, 0 | ||
;int 3 | ;int 3 | ||
.loop: | .loop: | ||
| Line 35: | Line 35: | ||
mov eax, edi | mov eax, edi | ||
cwd | cwd | ||
mov bx, 4 | mov bx, 4 | ||
div bx ; dx := (x >> 13) % 4 | div bx ; dx := (x >> 13) % 4 | ||
| Line 57: | Line 57: | ||
inc esi | inc esi | ||
jmp .loop | jmp .loop | ||
</nowiki> | |||
Revision as of 20:20, 19 February 2012
; 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
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