Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MMBasic, Stacks, Queues and Lists
Author | Message | ||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1101 |
Hi Folks, Been playing around with the idea of using sub-strings embedded in a single string to create a stack or queue or list of strings. Currently, I have limited it to a minimum sub-string width of 99 and the number of sub-strings being 250 with the added limit of width by depth =< 250. Eg. 5 wide x 20 entries, 1 wide x 250 entries etc. It is only for strings at the moment. As an example, the test code at the end of my code uses 3kB of storage and 13 variables. If I had used normal strings to do the same thing, I would have used over 40kB of storage and 750 variables. The routines will have specialised usage but may prove usefull in some circumstances. The code is well commented and should be reasonably self explanatory. My thanks to Tassie Jim for the idea of sub-strings from his Short Strings code - if a larger stack or queue is required, his short strings may be able to be integrated to the code here. I make no claim to elegance in code nor space saving - just like having fun. Hope it is of use to someone, Cheers, Doug. ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1101 |
Sorry folks - somehow missed the .zip upload. 2013-02-04_093110_STKUTILS.zip ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
That is amazing Doug. As you say, specialised... but also a sophisticated set of routines. Geoff Geoff Graham - http://geoffg.net |
||||
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139 |
Hi, For Version 4.3 of Maxifont, I utilize the Character in each string variable. Each Character has 8 bits, with 255 characters to a string, that is 2040 bits of info I can use for the font design. That is 31 font characters of 8x8 in one string variable. Luckily, Geoffg added the chain command which helped me shave 3000 bytes from the beginning of the Maxifont program.. So even more memory, to play with.. I hope to have the Monochrome and colour versions finished soon, and upload to the library.. my horizontal flip routine has three lines( four if you count the declaration) x= &b10101010 x=(((x and &HAA)\2) or ((x and &H55)*2)) x=(((x and &HCC)\4) or ((x and &H33)*4)) x=(((x and &HF0)\16) or ((x and &H0F)*16)) then Print bin$(x) gives us (0)1010101 Regards Dennis Keep plugging away, it is fun learning But can be expensive (if you keep blowing things up). Maximite, ColourMaximite, MM+ |
||||
ajkw Senior Member Joined: 29/06/2011 Location: AustraliaPosts: 290 |
Nice work on the bit flip Dennis! It would be nice if you could format bin$ to show appropriate leading zeros hint GG: print bin$(value,8) and/or print bin$(value,auto) |
||||
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139 |
Can't take credit for the bit flip, got it from the bithacking website... Dennis PS: just use crackerjacks bin8$(byte_in) funtion from the bin8.bas library program.. Keep plugging away, it is fun learning But can be expensive (if you keep blowing things up). Maximite, ColourMaximite, MM+ |
||||
ajkw Senior Member Joined: 29/06/2011 Location: AustraliaPosts: 290 |
I have,in the past, always looped through a byte testing each bit and then rebuilding a new variable to flip the bits in the past before I came across crackerjack's test (byte_in And (2 ^ bit)) > 0 in his routines that is a way neater test than I had come up with in the past. I always figured there must be a 'mathematical' way. Nice find! edit. and Right$(String$(8,"0")+Bin$(byte_in),8)] will do me. Anthony. |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1101 |
Hi Guys, A bit of an update. Tidied the code a little and added numeric stack routines, create, push, pop and average. Also added a text file with a more in depth explanation of each routine or function. In real use, I would strip all comments, blank lines and the test code at the bottom with Jim's beaut MMEdit then merge the result onto the end of a program as callable subroutines and functions. Hope this is usefull. For Hugh, happy to have it added to the library if you think worthwhile. Cheers, Doug. 2013-02-05_095128_Stack-Queue-List-Utilities.zip ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
shoebuckle Senior Member Joined: 21/01/2012 Location: AustraliaPosts: 189 |
Looks great. I will add it. Hugh |
||||
TinkersALot Regular Member Joined: 20/11/2012 Location: United StatesPosts: 72 |
Nice. Thank you for posting this. |
||||
Print this page |