![]() |
Forum Index : Microcontroller and PC projects : The value of Micromite code crunching
Author | Message | ||||
Oldbitcollector![]() Senior Member ![]() Joined: 16/05/2014 Location: United StatesPosts: 172 |
So most of you know about my little Micromite computer project.. (If you don't dig into my signature link) I've been developing demo programs to show the I2C functions and I tend to be rather verbose in my remarks and variable names. One demo I've written for this weekend runs 4k (19%) 148 lines and has nice full variable names with plenty of comments and carriage returns to help folks follow along. Tonight, for fun I wanted to see just how much space could be re-claimed by "crunching" the code. Almost every line (except IF statements) was reduced to multiple entries, separated by colons. Carriage returns, and comments removed, and variable names reduced to two characters. The end result was a 2 page program that is painful to read, but... Final result: 2k (10%) 45 lines. In the old 8bit days we had code compilers which would reduce the code and make it smaller. I'm thinking we may replicate something like this for our project as well. So this is more "Food for thought" for Micromite users. Jeff My Propeller/Micromite mini-computer project. |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
http://www.thebackshed.com/forum/forum_posts.asp?TID=5736&KW =crunch Microblocks. Build with logic. |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4004 |
MMEdit can do something similar as it downloads, I think (haven't needed it myself). John |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6223 |
MMEdit can remove comments and blank lines. It can also report on any unused functions and variables. I have deliberately avoided changing layouts and changing variable names but you can now use Hugh's Crunch program to do that before sending to the 'mite. Jim VK7JH MMedit |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
Would it help if there was either a DEFINT statement as in QBasic ? i.e. DEFINT a,z declares all variables a to z single byte integral OR (as in some Basics) Use of % to declare the same thing ... i.e. FOR x% = 0 to 7 y% = x% ^ z% |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1533 |
Generally the use of 16-bit "integers" would make the code shorter and faster. It seems Geoff is already working on this topic? Michael causality ≠ correlation ≠ coincidence |
||||
G8JCF![]() Guru ![]() Joined: 15/05/2014 Location: United KingdomPosts: 676 |
For pre-production code, I would completely recommend using MMEdit and set ON Auto=-Crunch and Delete-Blank-Lines. That way when you get an error you can find the original source code line easily whilst minimising the memory footprint. My various libraries/projects rely on using MMEdit to the extent that I comment/document as freely as I need to knowing that at download time to the uMite, MMEdit will strip out the comment/blanklines/indents/trailing spaces reducing the runtime foot print by usually over 50-60%. For Production code, it may be worthwhile doing the full Buckle Crunch since (hopefully) the bugs will have all but been eliminated, and since there will not probably be a console attached, the error reported will be unseen by the end user so there's not a lot of point in keeping the code readable etc. After all if the uMite was running C/Compiled MMBasic there wouldn't be a lot to see in the Production device either when it error'ed out As for Integer variable, I hope we get true 32 bit integers in the future and/or even better 64 bit integers. 73 Peter The only Konstant is Change |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4004 |
I expect they'd be 32-bit integers. It'll make MMBasic's size in flash quite a bit bigger, and substantially more complex, so be careful what you wish for! There will have to be some documentation for when a number is "widened" (from integer to float) and how to force narrowing (float to int), as well as what happens with mixtures of floats & ints. Except for benchmarks I suspect you'll see little speed change, but it hardly matters since MMBasic is fast enough now for most things. (I think it would make Peter's life rather better.) John |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1533 |
@John, I think too, this could Peter make happy. Please remember: GW Basic has 16-bit integers used. There is an advantage in speed and space. That's a point! I think Geoff will decide wisely. ![]() Michael causality ≠ correlation ≠ coincidence |
||||
G8JCF![]() Guru ![]() Joined: 15/05/2014 Location: United KingdomPosts: 676 |
Thanks for worrying about my mental state ![]() ![]() Indeed 32 bit integers would be very usewful. Thank you Peter The only Konstant is Change |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |