A bug in the simulation engine.
The engine seems to use a 'longer than 8 bit' value in calculations and 8 bit values don't seem to be extended correctly..
Demonstrates this.
This may be by design - byte is described as 0..255 so my treating it as as signed 8 bit number might be wrong here?
Martin
Simulation - extension of byte to 32 bit.
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Simulation - extension of byte to 32 bit.
Hi Martin,
Thanks that;s an interesting one. Does this work as expected on hardware?
Thanks that;s an interesting one. Does this work as expected on hardware?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 1189
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 439 times
- Contact:
Re: Simulation - extension of byte to 32 bit.
I'll try it - I assumed it would since it would do an 8 bit comparison for a byte,,, But it might not?
Martin
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 439 times
- Contact:
Re: Simulation - extension of byte to 32 bit.
No - doesn't work on hardware (indeed the code is optimised out to for the =-1 side of the conditonal)
I see it is defined as an unsigned char (MX_UINT8) - so I suppose this is the correct behaviour (as it should = 255 here)
Strangely if I define a variable x as (initial value) -1 then is generated (some spare fs!)
I see there is a MX_SINT8 defined in the header files - but a signed byte variable isn't offered as a choice in the 'create a variable'
I think my 'cheating' and using -1 as a shorthand for 255 has led me astray here - the compiler is doing the correct thing....
Martin
I see it is defined as an unsigned char (MX_UINT8) - so I suppose this is the correct behaviour (as it should = 255 here)
Strangely if I define a variable x as (initial value) -1 then
Code: Select all
MX_UINT8 FCL_X = (0xffffffff);
I see there is a MX_SINT8 defined in the header files - but a signed byte variable isn't offered as a choice in the 'create a variable'
I think my 'cheating' and using -1 as a shorthand for 255 has led me astray here - the compiler is doing the correct thing....
Martin