On the Cortex M0, does the multiply set the flags. That way, if one is writing a 32x32=64 bit multiply, a fast exit can be added. I'm just looking at this code I found and wondered if it were worth inserting.
+ /* Slow version for both THUMB and older ARMs lacking umull. */
+ mul xxh, yyl /* xxh := AH*BL */
+ push {r4, r5, r6, r7}
+ mul yyh, xxl /* yyh := AL*BH */
+ ldr r4, .L_mask
+ lsr r5, xxl, #16 /* r5 := (AL>>16) */
+ lsr r6, yyl, #16 /* r6 := (BL>>16) */
+ lsr r7, xxl, #16 /* r7 := (AL>>16) */
+ mul r5, r6 /* r5 = (AL>>16) * (BL>>16) */
+ and xxl, r4 /* xxl = AL & 0xffff */
+ and yyl, r4 /* yyl = BL & 0xffff */
+ add xxh, yyh /* xxh = AH*BL+AL*BH */
+ mul r6, xxl /* r6 = (AL&0xffff) * (BL>>16) */
+ mul r7, yyl /* r7 = (AL>>16) * (BL&0xffff) */
+ add xxh, r5
+ mul xxl, yyl /* xxl = (AL&0xffff) * (BL&0xffff) */
+ mov r4, #0
+ adds r6, r7 /* partial sum to result[47:16]. */
+ adc r4, r4 /* carry to result[48]. */
+ lsr yyh, r6, #16
+ lsl r4, r4, #16
+ lsl yyl, r6, #16
+ add xxh, r4
+ adds xxl, yyl
+ adc xxh, yyh
+ pop {r4, r5, r6, r7}
+ RET
+ .align 2
+.L_mask:
+ .word 65535
Hi Sean.
muffin wrote: I'm still looking to see if code can run from RAM allowing for self-modifying code. Things like huffman trees can be hand-coded so that they are as efficient as possible.
muffin wrote:
I'm still looking to see if code can run from RAM allowing for self-modifying code. Things like huffman trees can be hand-coded so that they are as efficient as possible.
There are a lot of questions I cannot answer, but I can definitely confirm that you can run code from the internal SRAM.
Also, I've once converted some decompression routine from 6502 to Cortex-M0 - I forgot where I put it, though - but it wasn't hard to do the conversion and it was fairly small (smaller than the original 6502 routine, but I never tested the routine).
bzip2 compresses very well and decompresses fast, but I believe the size of the decompression routine might be too large for most Cortex-M0.
I believe you will probably also want to know that it's fairly easy to interface with a SD/MMC card using the SPI protocol.
Almost all Cortex-M microcontrollers have built-in SPI interface. The 3 basic interfaces are: SPI, UART/USART and I2C; most Cortex-M microcontrollers implement all three.
In case you run out of GPIO pins, you can add I/O-expanders; this can be done via I2C or SPI. I/O-expanders typically give you 8 or 16 extra (slow) GPIO pins - these can be useful for reading buttons and controlling LEDs, but normally it shouldn't be necessary, as you can easily connect 2 LEDs or 2 switches to a single GPIO pin (if you need details, let me know).
Something else you will probably want to play with, is that you can extend the Flash memory by adding an external SPI-based Flash memory, I tend to recommend Spansion's 8Mbit (1MB) S25FL208K0RMFI041, which cost less than $1! -The only extra component required is a 100nF capacitor at the VCC pin (from VCC to GND).
For memory card support (eg. SD/MMC), you need slightly more components, including resistors (mainly 33K) and a couple of capacitors (again a 100nF capacitor and - say - a 4.7uF capacitor).