Page 1 of 1
Simulation - extension of byte to 32 bit.
Posted: Fri Apr 17, 2020 7:12 pm
by mnf
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
Re: Simulation - extension of byte to 32 bit.
Posted: Fri Apr 17, 2020 11:31 pm
by Benj
Hi Martin,
Thanks that;s an interesting one. Does this work as expected on hardware?
Re: Simulation - extension of byte to 32 bit.
Posted: Sat Apr 18, 2020 9:52 am
by mnf
I'll try it - I assumed it would since it would do an 8 bit comparison for a byte,,, But it might not?
Martin
Re: Simulation - extension of byte to 32 bit.
Posted: Sat Apr 18, 2020 5:15 pm
by mnf
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