; TinySine : 9-byte sine approximation (fasm 1.70.03/WinXP 5.1.2600) ; credit : olivier.poudade.free.fr 2013 aka baudsurfer org 100h mov al, 13h int 10h push 0a000h pop es plot:mov al,byte [x] ; al=angle call _sin mov byte [y],al call pix inc byte [x] cmp byte [x],90 jnz plot hold:in ax,60h dec ax jnz hold ret pix: pusha xor cx,cx xor dx,dx mov cl,byte [x] mov dl,byte [y] add dl,100 mov ax,0c0fh int 10h ; VIDEO - WRITE GRAPHICS PIXEL cf. http://www.ctyme.com/intr/rb-0104.htm popa ret ; 9-byte sine approximation through parabola for 0=0 from from http://www.coranac.com/2009/07/sines/ in deg : sin(x)=(10*x-x*x)/6000*scale ; sin(x)=(x*4/pi)+x*x*(4/pi*pi) if x=<0 mov bx,ax ; al=bl=x mul al ; ax=x*x xchg ax,bx ; ax=x bx=x*x aad ; ax=10*x (2 bytes smaller than mov dl,10 + mul dl) sub ax,bx ; ax=10*x-x*x if x>0 else branch/replace by add ax,bx or use absolute value trick mov al,ah ret ; ah=6000*scale, using scale=23,4375 ah=256*al x db 0 y db 0