![]() |
Forum Index : Microcontroller and PC projects : CM2: DIM bit
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
As said above: For speed reasons it was important to find the most compressed data structure. A thinkable use case would be eg data logging. And as Joe already wrote, it seems a bit crazy to waste 64 bits when we only need 1 bit. In my days, 32-64KB was enough for really good programs. causality ≠correlation ≠coincidence |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
I think it has been kicked to death about you not really needing to save memory on a few variables-as-flags on a half-meg system, but... setting a flag with those subs will be slower than X=1... you aren't short of RAM so in your place I would probably use individual variables in the name of speed. That said, the CMM2 is crazy fast so the trade off of slower flags versus nice readable code might not be as severe as it first seems. Those routines were developed on and for the smaller memory MicroMites - where the preponderance of my work is and I use them all the time. When you only have 60K free for everything, they make quite a saving - a full rank of the maximum 64 flags would use 4KB as individual variables. Out of 60K that's a hell of a lump. Still, due to the wonders of MMBasic, they will work precisely as planned for you regardless. Edited 2020-09-19 06:28 by CaptainBoing |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
BTW. CaptainBoings functions are not the optimum. Faster than (bit set) a=a or (2^63) is this a=a or (1<<63) Faster than (bit reset) a=(a OR (2^63)) XOR (2^63) is this a=a AND inv (1<<63) Maybe CaptainBoing can update the Wiki? Regards Michael or you could - it is a wiki after all ![]() Err, what is "inv"? p.s. love the <<1 instead of 2^ - thanks... now why didn't I think of that? ![]() Edited 2020-09-19 06:45 by CaptainBoing |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Not so quick! ![]() Eg if you want to save a lot of flags (eg 20-30) in an interrupt routine then can it be an advantage to save only one integer instead of 30. Just a idea ... causality ≠correlation ≠coincidence |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
![]() I am not familiar with it. ![]() Thanks a lot! bitwise inversion (s. manual p22) Kind regards Michael EDIT(my test code) dim integer a=0,b=0 timer=0 for i = 1 to 100000 next t0=timer ? t0"us" ? bin$(a,64) timer=0 for i = 1 to 100000 a=a or (2^63) next t=timer ? t-t0"us" ? bin$(a,64) a=0 timer=0 for i = 1 to 100000 a=a or (1<<63) next t=timer ? t-t0"us" ? bin$(a,64) b=a timer=0 for i = 1 to 100000 a=(a OR (2^63)) XOR (2^63) next t=timer ? t-t0"us" ? bin$(a,64) a=b timer=0 for i = 1 to 100000 a=a AND inv (1<<63) next t=timer ? t-t0"us" ? bin$(a,64) Result: 113.534us 0000000000000000000000000000000000000000000000000000000000000000 799.22us 1000000000000000000000000000000000000000000000000000000000000000 682.185us 1000000000000000000000000000000000000000000000000000000000000000 1317.382us 0000000000000000000000000000000000000000000000000000000000000000 711.982us 0000000000000000000000000000000000000000000000000000000000000000 Edited 2020-09-19 06:48 by twofingers causality ≠correlation ≠coincidence |
||||
bar1010 Senior Member ![]() Joined: 10/08/2020 Location: United StatesPosts: 197 |
Best wishes, Tom Oracle PL/SQL has a BOOLEAN datatype. The CM2 should as well. |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
bitwise inversion (s. manual p22) ah right! Is that specific to the CMM2 version of MMBasic? Michael, could you write me an equivalent function and I'll put it in the wiki as an alternative for CMM2 (don't have) Edited 2020-09-19 06:53 by CaptainBoing |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
Lots of languages have addressable bits (and there are advantages). The question for the CMM2 is why it +should+. But I'd say it's an idle question, because it seems unlikely that anyone will ever make it happen. If they did, I'd use them. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
I cannot agree. The CMM2 is a home computer kind of. I would prefer other features eg ANSI (ISO 8859-1) keyboard design. However, I fear that we will have to wait until the CMM3000. ![]() Can you say something about the internal design? causality ≠correlation ≠coincidence |
||||
bar1010 Senior Member ![]() Joined: 10/08/2020 Location: United StatesPosts: 197 |
Best wishes, Tom Oracle PL/SQL has a BOOLEAN datatype. The CM2 should as well. Right now we have the situation that is like going to a hotel needing only one room, but instead are given eight rooms thereby wasting rooms that other people could have used. What if one million people across the world need only one hotel room each? They are given a total of eight million hotel rooms when only one million are needed. Therefore seven million people could have occupied the empty rooms if they had been available. How long would the hotel managers be around if this was happening? What would be done to fix the situation? What if the airline industry left lots of empty seats on planes and made those seats unavailable to customers? Their idea being that why are we concerned about having these empty seats when there are many seats available? Edited 2020-09-19 07:39 by bar1010 |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
It is entirely unlike that, because no one is looking to occupy those unused bits (unless that CMM2 use case is presented). Yes, when I first came to the Micromite, I looked for bit variables, and felt some pangs to learn that all those bits were being wasted--first in 32-bit words and then in 64-bit words. But that was about my own internal state based on what I had experienced before as a programmer sometimes needing to conserve space, not about any actual constraints which the Maximite/Micromite had on my ability to achieve what I wanted (conceding CaptainBoing's occasional need on the 170). PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
bar1010 Senior Member ![]() Joined: 10/08/2020 Location: United StatesPosts: 197 |
It is entirely unlike that, because no one is looking to occupy those unused bits (unless that CMM2 use case is presented). Yes, when I first came to the Micromite, I looked for bit variables, and felt some pangs to learn that all those bits were being wasted--first in 32-bit words and then in 64-bit words. But that was about my own internal state based on what I had experienced before as a programmer sometimes needing to conserve space, not about any actual constraints which the Maximite/Micromite had on my ability to achieve what I wanted (conceding CaptainBoing's occasional need on the 170). If the Color Maximite 2 is used for business, this inefficiency is causing us to lose money that we could have had if we were more efficient. How would it be if trucks made deliveries to grocery stores, but could only use one eighth of the storage capacity in their trailers? Maybe it does not seem bad for one case, but it is certainly bad when we are talking about all truck trailers throughout all time. In the current situation in the case we have an array of strings that uses the entire 5 megabytes of variable storage storing ON or OFF information, we could have stored eight times as much ON/OFF information had we just been allocating one bit each. Edited 2020-09-19 07:53 by bar1010 |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
You'd have to explain how that is the case. Seems a stretch. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
What an irrelevant statement! Fact is, it would be a PAIN to add (look at the source) and ALSO slow everything down. The gain? Nothing worthwhile. If you really want it, YOU can change the source code. John |
||||
bar1010 Senior Member ![]() Joined: 10/08/2020 Location: United StatesPosts: 197 |
You'd have to explain how that is the case. Seems a stretch. Is it a stretch when Walmart could have been making 80,000 dollars profit in one day at one location, but instead settled for making 10,000 dollars profit? Edited 2020-09-19 07:58 by bar1010 |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
No, it isn't. That is just plain wrong. John |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
You'd have to explain how that is the case. Seems a stretch. Is it a stretch when Walmart could have been making 80,000 dollars profit in one day at one location, but instead settled for making 10,000 dollars profit? What? Are you a troll? John |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
[rant] MMBasic has three datatypes: strings, 64-bit integers, and double precision floats - end of discussion. It is extremely frustrating when people who know nothing of the history of MMBasic and how long it took Geoff to integrate integers and how many bugs and difficulties that caused blithely suggest, bytes, booleans or whatever. If MMBasic as-is doesn't work for you feel free to use something else. The core basic interpreter isn't going to change. Please also understand the licencing of the source. You can do what you like with it for your own personal use but you may not incorporate any of my or Geoff's code in anything to be released in any way without our permission which in my case will not be forthcoming. I haven't got the time or energy to answer every new forum user who wants to modify the concept in his or her own image so please lets stop these endless requests for changes or a different version. I will always try and help new users who have problems with understanding and my greatest pleasure is to see new users like epsilon today whose first posts have been to contribute great new code using the firmware as-is rather than immediately wanting changes [/rant] |
||||
bar1010 Senior Member ![]() Joined: 10/08/2020 Location: United StatesPosts: 197 |
No, it isn't. That is just plain wrong. John If we are talking about a few Boolean variables, then it is likely not worth the trouble of adding the functionality, but if we are talking about huge bit arrays then it is certainly worth it. That is what I have in mind - huge bit arrays. |
||||
bar1010 Senior Member ![]() Joined: 10/08/2020 Location: United StatesPosts: 197 |
No, it isn't. That is just plain wrong. John If we are talking about a few Boolean variables, then it is likely not worth the trouble of adding the functionality, but if we are talking about huge bit arrays then it is certainly worth it. That is what I have in mind - huge bit arrays. |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |