Very strange bug hard to understand (.b types related ? )

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Very strange bug hard to understand (.b types related ? )

Post 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 :shock:
Explanation would be welcomed :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post 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!?)
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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 :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

I didn't have this problem :-?
the only thing is that it crashed without the "if"

Dri
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
manu
User
User
Posts: 32
Joined: Tue May 13, 2003 12:40 pm
Location: Germany
Contact:

It's not a bug in PB

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: It's not a bug in PB

Post 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 :oops:
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?

:oops: :oops: :oops: :oops:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply