why i've got exception when i try to dinamicly set timer time-out value:
.if TimerWorking==FALSE
mov TimerWorking, TRUE
mov eax, TimeTemp
mov ecx, HowManyTimes
.if (eax>0) && HowManyTimes>0
div ecx
.endif
.if eax<60
mov eax, 60
.endif
mul SecInMilSec
invoke SetTimer, hWnd, 2, eax, offset AnotherTimerProc
.endif
I use this .if conditional in my first timer procedure. Everything is woking fine if i wrote this procedure without div instruction.
What is wrong?
.if TimerWorking==FALSE
mov TimerWorking, TRUE
mov eax, TimeTemp
mov ecx, HowManyTimes
.if (eax>0) && HowManyTimes>0
div ecx
.endif
.if eax<60
mov eax, 60
.endif
mul SecInMilSec
invoke SetTimer, hWnd, 2, eax, offset AnotherTimerProc
.endif
I use this .if conditional in my first timer procedure. Everything is woking fine if i wrote this procedure without div instruction.
What is wrong?
This is a common problem when you don't clear EDX register.
You have to remember DIV operates on EDX:EAX
You have to remember DIV operates on EDX:EAX
There Has been many disussions regarding the use of the DIV op-code. I encourage you to use the search engine and look up some of them... as well one of them i "preserved" on my web-page, as i thought it got to the point quick and simple :)
http://www.angelfire.com/scifi/win32asm/Disc_4.html
Long story short, dont forget the EDX:EAX pair. This is the equivalent number being divided when the divisor is a 32 bit number.
Good luck..
NaN
(( EDIT: you beat me by a minute BitRake.. :grin: ))
http://www.angelfire.com/scifi/win32asm/Disc_4.html
Long story short, dont forget the EDX:EAX pair. This is the equivalent number being divided when the divisor is a 32 bit number.
Good luck..
NaN
(( EDIT: you beat me by a minute BitRake.. :grin: ))