Why Mecrisp-Across is AWESOME!

Years ago, the creator of Mecrisp, Matthias Koch and I had a little contest to see who could code the smallest ‘Blinky’ for MSP430 in assembly language.

The Tiny Blinky Challenge

Challenge: Blinky, binary as small as possible, no strange electrical states on other pins.
  • My minimal blinky was 80 Bytes

  • Matthias minimal blinky was 14 Bytes….

Matthias used his Assembly Wizard skills, coupled with a intimate hardware knowledge of MSP430 tricks to get that binary down to 14 bytes in size. I could never achieve that level of hacking.

This Is Why Mecrisp-Across Is Awesome

My boring, uninspired, Mecross-Across standard blinky example here used the same kind of technique I used in the original Tiny Blinky Challenge, but instead of three days of Assembly Language Programming/debugging, this time it was 5 minutes of Forth programming.

The size of my Forth Blinky after being compiled by Mecrisp-Across is ONLY 20 BYTES when you subtract the mandatory microprocessor initilisation code that is added at the start of the user code.

The simple fact is that Mecrisp-Across is far, far better at Assembly Language than I will ever be, and at age 64, I don’t see my Assembly Coding skills improving all that much.

Another bonus

What’s the difference in the Mecrisp-Across generated binaries of these two blinkies ?

Blinky1

: delay ( -- )
    65535 0 do loop
 ;

 : minblink ( -- )
   1 p1dir c!
   begin
     1 p1out cxor!
   again
 ;

Blinky2

: minblink ( -- )
   1 p1dir c!
   begin
     1 p1out cxor!
     65535 0 do loop
   again
 ;

Answer: none, they are both 36 bytes because of the Mecrisp-Across automatic inlining!

Note

Normally Blinky1 would be bigger as the assembler added extra jumps to the delay function.

Why is Saving a Few Bytes So Important Anyway ?

Because in the embedded microcontroller world, memory size adds to the per chip price.

Take the latest MSP430FR2000IPW16R chip from https://au.mouser.com, (who are fairly expensive) this chip is only $0.777 in 100 quantity and it’s perfect for lots of small cheap very low power products, but it has only 500 Bytes of FRAM non-volatile storage and 512 Bytes of Ram.

Every Byte counts in embedded electronics!