Page 1 of 1
Very strange bug hard to understand (.b types related ? )
Posted: Thu Nov 16, 2006 12:36 pm
by Psychophanta
Well, i have reduced the code to the maximum in order to post here the possible bug. Get it
here
Please refer to the arrowed commented comments in the lines and try to understand, because i can't
Explanation would be welcomed

Posted: Fri Nov 17, 2006 1:30 am
by va!n
i see your problem... atm i am a bit to tired but i think it could be a problem with the macro MyFlipBuffers (modify registers or something!?)
Posted: Fri Nov 17, 2006 8:19 am
by Psychophanta
va!n wrote:...but i think it could be a problem with the macro MyFlipBuffers (modify registers or something!?)
That is what i believed, but ... no possible

Posted: Fri Nov 17, 2006 9:33 am
by Dr. Dri
i don't understand your problem but with these lines the program doesn't crash anymore forme
Code: Select all
If StartDrawing(ScreenOutput())
DrawText(200,300,"md = "+Str(md)+"; PMODE = "+Str(PMODE),$eeeeee,0)
StopDrawing()
EndIf
Dri
Posted: Fri Nov 17, 2006 10:27 am
by Psychophanta
Hi Dr. Dri.
The problem has nothing to do with that.
Those lines can be erased from the snippet, those lines are not significative coz they are just to watch the variable PMODE at real time.
The problem is that the arrow must remain up or down, but the behaviour is wrong because it tend to remain up, even you move the mouse to set it to down.
As the source comment says, if the type of PMODE variable is set to .w instead to .b, then the program behaviour works as expected. Do you see it?
Posted: Fri Nov 17, 2006 11:18 am
by Dr. Dri
I didn't have this problem

the only thing is that it crashed without the "if"
Dri
Posted: Fri Nov 17, 2006 11:53 am
by Psychophanta
Dr. Dri wrote:I didn't have this problem

??? Strange! Here it happens
Dr. Dri wrote:the only thing is that it crashed without the "if"
? Strange again! here it doesn't crash!!
Notice: i use (PB4.01 with betas)
It's not a bug in PB
Posted: Thu Nov 30, 2006 3:23 am
by manu
I had a look at your code.
The problem is that in your inline assembly line
Code: Select all
!fistp dword[v_MustDelay];<- MustDelay=DispPeriod-(checkpoint2-checkpoint1)/SysFreq.
you store 32bits at the address of your variable MustDelay which is only 8bits wide, which is why your variable PCODE (also 8bits) gets overwritten. When you make PCODE larger, it probably gets stored somewhere else so it isn't overwritten and the code
seems to be fine.
Change MustDelay.b to MustDelay.l and everything works as expected.
manu
Re: It's not a bug in PB
Posted: Thu Nov 30, 2006 5:51 pm
by Psychophanta
manu wrote:I had a look at your code.
The problem is that in your inline assembly line
Code: Select all
!fistp dword[v_MustDelay];<- MustDelay=DispPeriod-(checkpoint2-checkpoint1)/SysFreq.
you store 32bits at the address of your variable MustDelay which is only 8bits wide, which is why your variable PCODE (also 8bits) gets overwritten. When you make PCODE larger, it probably gets stored somewhere else so it isn't overwritten and the code
seems to be fine.
Change MustDelay.b to MustDelay.l and everything works as expected.
manu
manu, my hero! big thanks, you have discover a bug in the snippet
And yes, it seems the only bug is made by the programmer in this case.
Please mods, may you delete this thread? or move it to another place?
