KevKelley #1 Posted April 26, 2020 I was looking at possibly freeing up variables if necessary and was curious if you could use part of a variable for a counter and the rest for bit operations? So based of my understanding, say I have a counter and it only ever used up to 4 bits (%00000000 - %00001010). Can I use the 4 bits that are never used or when a variable is used does it check all of the bits? So if I were to check for x{7} while having the counter at 10 (%10001010), would it read both or by turning on x{7} would it be read as 138? Quote Share this post Link to post Share on other sites
Lillapojkenpåön #2 Posted April 26, 2020 There's only one bit 7, but the counter would be 138, you can turn the first half into a four bit variable aka nibble, it can only count to 15. macro _Set_Lo_Nibble {1}=(({2}^{1})&$0F)^{1} end def PEEK_Counter = x&$0F def POKE_Counter = callmacro _Set_Lo_Nibble x To set it to 0 POKE_Counter 0 ;notice no equal sign To check if it's 15 if PEEK_Counter = 15 then... To add 1 temp5 = (PEEK_Counter) + 1 POKE_Counter temp5 Then you can use bits 4-7 for other things, it won't affect peeking at the counter since it only checks the first four bits 1 Quote Share this post Link to post Share on other sites
KevKelley #3 Posted April 26, 2020 Ah. Okay. Thanks! I remember reading about nybble variables early on but never knew what for but now it makes sense. I will definitely play around with this. So then if I have it count up and need to change back to 0 then I would do: If PEEK_Counter = 15 then POKE_Counter 0 And then add to it using a temp variable. I'm sure I'll get the hang of this. Thanks very much! 1 Quote Share this post Link to post Share on other sites