News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

program keeps opening new and new windows of itself ??

Started by gelatine1, November 15, 2014, 02:51:03 AM

Previous topic - Next topic

gelatine1

I wrote a program that should in no way open a new window, but still it does open windows and a hell lot of them... anyone knows why ? I believe the error is somewhere in a function I wrote to draw Circles. because if i comment the call to that procedure then it doesn't create all the windows anymore.

This is the code ofr the circle proc:


; proc draws a cirlce with center (x,y) and radius r
Circle proc hDc:HDC, x:UINT, y:UINT ,r:UINT , color:COLORREF
LOCAL d:UINT ;stores the x value computed by st(0)
mov eax,y
add eax,r ; counter

mov edx,y
sub edx,r

fild r ;st(0) = r
fmul st,st ;st(0) = r^2
fild r ;st(0)=r st(1) = r^2
fld half
fsubp st(1),st ;st(0)=r-0.5 st(1) = r^2

circley:
fld st ; st(0) = r-0.5 st(1) = r-0.5 st(2) = r^2
fmul st,st ; st(0) = (r-0.5)^2 st(1) = r-0.5 st(2) = r^2
fsubr st,st(2) ;st(0) = r^2 - (y+r-0.5)^2
fsqrt ;st(0) contains x value

fistp d ;st(0) = r-0.5 st(2) = r^2
fld1
fsub

mov ecx,x
sub ecx,d

mov edi,x
add edi,d

drawLine:
push ecx
push edx
push eax
push edi
invoke SetPixel,hDc,ecx,eax,color
pop edi
pop eax
pop edx
pop ecx

inc ecx
cmp ecx,edi
jnz drawLine

dec eax
cmp edx,eax
jnz circley

ffree st
ffree st(1)
Circle endp


can anyone tell me what's going on here ?

Thanks in advance
Jannes

gelatine1

Whoops  :redface: Nevermind I simply forgot to use the ret instruction  :icon_redface: