Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <msp430.h>
- #include <stdint.h>
- void spewSPI(uint8_t n) {
- const char *spiStrTBL[] = {
- "parm1",
- "parm2",
- "...",
- "parm99"
- };
- uint8_t indx; // 0-255 so we get mov.b
- if ( n > sizeof(spiStrTBL) / sizeof(spiStrTBL[0]) ) {
- return; // ignore out of bounds request
- }
- for ( indx = 0; spiStrTBL[n][indx] != 0; ++indx ) {
- UCA0TXBUF = spiStrTBL[n][indx];
- }
- }
- void callIt() {
- spewSPI(0); // send parm1
- spewSPI(1); // send parm2
- }
- // generates this with msp430-gcc -mmcu=msp430g2553 -Os -S testme.c
- .file "tblexample.c"
- .arch msp430g2553
- .cpu 430
- .mpy none
- .text
- .p2align 1,0
- .global spewSPI
- .type spewSPI,@function
- /***********************
- * Function `spewSPI'
- ***********************/
- spewSPI:
- sub #8, r1
- mov &C.0.2204, @r1
- mov &C.0.2204+2, 2(r1)
- mov &C.0.2204+4, 4(r1)
- mov &C.0.2204+6, 6(r1)
- cmp.b #5, r15
- jhs .L1
- mov.b r15, r15
- rla r15
- add r1, r15
- mov @r15, r13
- mov.b #0, r14
- jmp .L3
- .L4:
- mov.b r15, &__UCA0TXBUF
- add.b #1, r14
- .L3:
- mov.b r14, r15
- add r13, r15
- mov.b @r15, r15
- cmp.b #0, r15
- jne .L4
- .L1:
- add #8, r1
- ret
- .Lfe1:
- .size spewSPI,.Lfe1-spewSPI
- ;; End of function
- .p2align 1,0
- .global callIt
- .type callIt,@function
- /***********************
- * Function `callIt'
- ***********************/
- callIt:
- mov.b #0, r15
- call #spewSPI
- mov.b #1, r15
- call #spewSPI
- ret
- .Lfe2:
- .size callIt,.Lfe2-callIt
- ;; End of function
- .LC0:
- .string "parm1"
- .LC1:
- .string "parm2"
- .LC2:
- .string "..."
- .LC3:
- .string "parm99"
- .p2align 1,0
- .type C.0.2204,@object
- .size C.0.2204,8
- C.0.2204:
- .word .LC0
- .word .LC1
- .word .LC2
- .word .LC3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement