汇编程序x86代码不起作用

时间:2017-10-16 13:18:14

标签: assembly x86 x87

我是x86汇编程序的新手,无法识别给定代码中的问题。它应画一个圆圈,但我得到单点。这是FASM语法中的代码:

org 100h
mov ax, 0x0013 
int 10h          ;setting gtx mode

mov cx,200       ;number of iterations
mov ax,0xa000    ;beggining of gfx memory segment
mov es,ax

lp:
call calculate   ;calculating the X and Y 
mov ax,320       ;Y value multiplied by 320
mov bx,Yresult
add bx,100       ;adding the radius so the circle is drawn in center
mul bx           ;computing the memory byte where the point will be placed
add ax,Xresult   ;adding X 
mov di,ax        ;sending value to DI
mov byte [es:di],6 ;drawing the point
dec cx             ;decreasing the loop variable
jnz lp             ;jump if not 0

ret  

calculate:
fninit              ;resetting registers
fld dword[kat]      ;loading the angle
fadd dword[addition] ;changing the angle each time the procedure is called
fst dword[kat]        ;saving the angle
fidiv word[angle]      ;radians to angles: ang/180*pi

fldpi               ;loading PI
fmul st0,st1        ;multiplying angle/180*PI
fsincos             ;cos & sin in st0&st1

fimul word[radius]  ;multiplying cos and sine by radius of circle
fincstp
fimul word[radius]
fdecstp

fistp word[Xresult] ;storing integers for X and Y
fistp word[Yresult]

ret


angle dw 180        
addition DD 1.0     ;how much the angle will be changed
kat DD 1.0          ;current angle, this is changed every call
radius dw 100       ;radius of the circle
Xresult dw 0        ;X var
Yresult dw 0        ;Y var

我检查了所有说明,似乎它们使用得当。也许问题是x86 / x87的时间问题?

0 个答案:

没有答案