Bit masking words

Beta Testing discussion on mikroBasic PRO for PIC.
Author
Message
MAN
Posts: 437
Joined: 11 Jan 2006 18:32
Location: Brasil

#16 Post by MAN » 28 Mar 2009 22:48

janni wrote:Maybe you've found another hole in the new rule application? If yes, then post some code.
Hi Janny;

Is not easy.
look to this,

Code: Select all

dim var_1_16 as word
dim var_2_8  as byte
dim var_3_8  as byte
dim var_temp as word

main:
'Based on the post of Chris
var_1_16 = %0000110011001100

'simple evaluated expression result as byte
var_2_8  = var_1_16 and %00111111

'it's work to me i only changed the constant to show it
var_3_8  = word((var_1_16 and %0000101111000000) >> 6)
'                                   x

'and the correct is as you wrote the compiler make the converssion
var_3_8  = word(var_1_16 >> 6)


'To the new rule work how the old we can write.
'1-> if the var_1_16 need to hold the value:
var_temp = (var_1_16 and %0000111111000000) >> 6
var_3_8 = var_temp   'and we get the same as old

'2-> if the var_1_16 don't need to hold the value:
var_1_16 = (var_1_16 and %0000111111000000) >> 6
var_3_8  = var_1_16 'and we get the same as old

'maybe another form can be found.
nop


end.
when I was writing this post I found some discrepancies but I will check with more calm and then I comment on it.
Working with you, for you!
MAN

Chris Yeager
Posts: 73
Joined: 21 Sep 2005 04:23

#17 Post by Chris Yeager » 30 Mar 2009 03:00

What you have done using a temp 16 bit variable is the only answer I could come up with too.
It seems that cast should work.
Thank you for all your work on this.
And MikroE. I appreciate all the work you put into these products too. I in no way wish to appear ungrateful for the new FREE upgrades, and all the support.
It will be great!!!!

Chris

Post Reply

Return to “mikroBasic PRO for PIC Beta Testing”