I'm a beginner in programming Assembly. I would like to draw f(x)=x*sin(1/x) curve in graphics mode.
I can draw f(x)=sin(x) curve but I'm unable to draw f(x)=x*sin(1/x). How could I do this?
Below you can see my working f(x)=sin(x) code. It's working and drawing the sine curve perfectly:
org 100h
mov al,13h
int 10h
xor bx,bx
loopage:
inc word [angle]
fld dword [pie]
fimul word [angle]
fsin
fimul word [xradius]
fistp word [x]
fimul word [yradius]
fistp word [y]
mov al,15
mov dx,[x]
add dx,ax
mov cx,[y]
add cx,bx
;xor ax,ax
;int 16h
inc bl
mov ah,0Ch
mov al,bl
int 10h
cmp word [angle],360
je endage
jb loopage
mov ax,0a000h
mov es,ax
xor ax,ax
mov cx,32000
rep stosw
endage:
xor ax,ax
int 16h
ret
y dw 0
x dw 0
angle dw 0
a dw -1
pie dd 0.01756
yradius dw 50
one dw 1
xradius dw 50
float dd 0
I'd like to change this code to draw the f(x)=x*sin(1/x) curve.
I've tried several things to change following section in the code above:
...
fld dword [pie]
fimul word [angle]
fsin
fimul word [xradius]
fistp word [x]
fimul word [yradius]
fistp word [y]
...
However without any results so far.
Could you help me please?
=========== EDITED: ====================
I tried out your code. Now my code looks like this:
...
loopage:
;inc word [angle]
; FP0 <- 1
fld1
; FP0 = FP0 / [pie] / [angle], is equal to FP0 / ([pie] * [angle])
fidiv dword [pie]
fidiv word [angle]
fsin
fimul dword [pie]
fimul word [angle]
fimul word [yradius]
fistp word [y]
mov al,15
mov dx,[angle]
add dx,ax
mov cx,[y]
add cx,bx
...
However this code draws only a single line instead of the expected x*sin(1/x) curve. Could you help me please to figure out what could be the problem?