How can I convert "s" seconds in the format (string) "mm:ss"?
I did wrote this code (seconds in eax):

DurationFormat db "%02d:%02d",0

Duration db 6 dup (?)




mov seconds, eax
push ebx
mov bl, 60
div bl
mov ah, 0
mov minutes, eax
mul bl
sub seconds, eax
pop ebx
invoke wsprintf, ADDR Duration, ADDR DurationFormat, minutes, seconds

It works perfectly, but if I use this procedure (in which the code above is) several times (in my program I have to use it several times), an error ocurrs and my program is closed. I know the error is in this code because I commented those lines and the program worked fine even using the procedure several times.

Can anyone help me figure out what is the problem?
Does anyone have any code to do this?
Thanks in advance.
Posted on 2001-12-11 14:12:29 by dilau
I've had similar problems when using one of the forbidden registers (even pushing and poping it). Put your code into a dll and see what happens.
Posted on 2001-12-11 14:58:03 by eet_1024
I just though of something, try pushing and poping bl instead of ebx.
Posted on 2001-12-11 14:59:04 by eet_1024
Afternoon, dilau.

I've, also, have problems using ebx like you.

I use edx when the code fails(infrequently) using ebx.

Posted on 2001-12-11 15:10:34 by Scronty
I would act this way: debug your procedure just to see which registers are modified by the wsprintf call. If any of the registers needed by windows (I always forget which ones they are) is modified, than just push and pop them too.

I hope this helps.

Posted on 2001-12-11 15:14:36 by dguzz
i think if you throw
uses ebx esi edi
around all the procedures (blah proc uses ebx esi edi, arg:DWORD,...)
it will work on win2k/xp
Posted on 2001-12-11 22:18:18 by grv575