Hi, All ! I found a very strange GCC output. As I know msp430 does not have "jlo r15" command (binutils do not know about this command too :), but GCC tries to use it 8-).
I have attached an extract from the file and the assembler output (GCC was invoked by "msp430-gcc -std=gnu99 -mmcu=msp430x149 -S -O -c tst.c" command). I use a mingw version of GCC which I have built 2 or 3 weeks ago, the release version produces the correct code. All the best, Oleg.
void Start(void); void Stop(void); int BusRq(void); void BusFree(void); int BusWrite(uint16_t a,uint16_t w); int BusRead(uint16_t a,uint16_t* r); uint8_t ScanBanks(void); #define BusReadF(a) ({uint16_t r; \ asm volatile("bic.b #0x40,&0x29 ;Enable buffer \n\t"\ "mov %1,r12 \n\t"\ "inv r12 \n\t"\ "mov.b r12,&0x1D ;Address low \n\t"\ "swpb r12 \n\t"\ "mov.b r12,&0x31 ;Address high \n\t"\ "bic.b #0x02,&0x29 ;Ê ÑÈÀ Í \n\t"\ "clr.b &0x1E \n\t" \ "clr.b &0x32 \n\t" \ "bic.b #0x08,&0x29 ;Ê ÂÂÎÄ Í \n"\ "WaitFall%=: bit.b #0x08,&0x20 ;Ê ÑÈÏ Í \n\t"\ "jnz WaitFall%= \n\t"\ "mov.b &0x30,r12 \n\t"\ "swpb r12 \n\t"\ "mov.b &0x1C,%0 \n\t"\ "bis r12,%0 \n\t"\ "bis.b #0x08,&0x29 ;Ê ÂÂÎÄ Í \n\t"\ "mov.b #0xFF,&0x1E \n\t"\ "mov.b #0xFF,&0x32 \n\t"\ "WaitRise%=: bit.b #0x08,&0x20 ;Ê ÑÈÏ Í \n"\ "jz WaitRise%= \n\t"\ "bis.b #0x42,&0x29 ;Ê ÑÈÀ Í,disable buffer \n\t" : "=r"(r) : "rmI"(a) : "r12");\ r;})
#include "io.h" #include "HAL.h" void LongTest(uint8_t b) { uint8_t b1; LCDClean(); WriteString("¤a¾¸cÄ e㸽¸å..."); b1=b; for(uint16_t a=0;a<0160000;b1>>=1) { if(!(b1 & 0x01)){ a+=020000; continue; } for(int i=010000;i;i--,a+=2) { BusWrite(a,0xFFFF); } } LCDClean(); WriteString("Tec¿¸po³a½¸e O¤©..."); b1=b; for(uint16_t a=0;a<0160000;b1>>=1) { if(!(b1 & 0x01)){ a+=020000; continue; } for(int i=010000;i;i--,a+=2) { At(0,1); WriteWord(a); BusWrite(a,0x0000); uint8_t b2=b; for(uint16_t a2=0;a2<0160000;b2>>=1) { if(!(b2 & 0x01)){ a2+=020000; continue; } for(int i=010000;i;i--,a2+=2) { uint16_t r; r=BusReadF(a2); if(a2<=a) { if(r!=0xFFFF) { if(Error(a,0x0000,a2,~r,0x0000))return; Recovery(b,a); } } else { if(r!=0x0000) { if(Error(a,0x0000,a2,~r,0xFFFF))return; Recovery(b,a); } } } } } } }
.file "tst.c" .arch msp430x149 /* Hardware multiplier registers: */ __MPY=0x130 __MPYS=0x132 __MAC=0x134 __MACS=0x136 __OP2=0x138 __RESLO=0x13a __RESHI=0x13c __SUMEXT=0x13e .text .LC0: .string "\244a\276\270c\304 e\343\270\275\270\345..." .LC1: .string "Tec\277\270po\263a\275\270e O\244\251..." .p2align 1,0 .global LongTest .type LongTest,@function /*********************** * Function `LongTest' ***********************/ LongTest: /* prologue: frame size = 0 */ .L__FrameSize_LongTest=0x0 .L__FrameOffset_LongTest=0xe push r11 push r10 push r9 push r8 push r7 push r6 push r5 /* prologue end (size=7) */ mov.b r15, r6 call #LCDClean mov #.LC0, r15 call #WriteString mov.b r6, r7 mov #llo(0), r10 .L12: mov.b r7, r15 and.b #llo(1), r15 jne .L6 add #llo(8192), r10 jmp .L4 .L6: mov #llo(4096), r11 .L11: mov #llo(-1), r14 mov r10, r15 call #BusWrite add #llo(-1), r11 add #llo(2), r10 cmp #llo(0), r11 jne .L11 .L4: clrc rrc.b r7 cmp #llo(-8192), r10 jlo .L12 call #LCDClean mov #.LC1, r15 call #WriteString mov.b r6, r7 mov #llo(0), r9 .L40: mov.b r7, r15 and.b #llo(1), r15 jne .L17 add #llo(8192), r9 jmp .L15 .L17: mov #llo(4096), r5 .L39: mov #llo(1), r14 mov #llo(0), r15 call #At mov r9, r15 call #WriteWord mov #llo(0), r14 mov r9, r15 call #BusWrite mov.b r6, r8 mov #llo(0), r11 .L38: mov.b r8, r15 and.b #llo(1), r15 jne .L26 add #llo(8192), r11 jmp .L24 .L26: mov #llo(4096), r10 .L37: /* #APP */ bic.b #0x40,&0x29 ;Enable buffer mov r11,r12 inv r12 mov.b r12,&0x1D ;Address low swpb r12 mov.b r12,&0x31 ;Address high bic.b #0x02,&0x29 ;Ê ÑÈÀ Í clr.b &0x1E clr.b &0x32 bic.b #0x08,&0x29 ;Ê ÂÂÎÄ Í WaitFall103: bit.b #0x08,&0x20 ;Ê ÑÈÏ Í jnz WaitFall103 mov.b &0x30,r12 swpb r12 mov.b &0x1C,r15 bis r12,r15 bis.b #0x08,&0x29 ;Ê ÂÂÎÄ Í mov.b #0xFF,&0x1E mov.b #0xFF,&0x32 WaitRise103: bit.b #0x08,&0x20 ;Ê ÑÈÏ Í jz WaitRise103 bis.b #0x42,&0x29 ;Ê ÑÈÀ Í,disable buffer /* #NOAPP */ cmp r11, r9 jlo r15 cmp #llo(-1), r15 jeq .L29 inv r15 push #llo(0) mov r15, r12 mov r11, r13 mov #llo(0), r14 mov r9, r15 call #Error add #llo(2), r1 cmp #llo(0), r15 jne .L1 jmp .L49 .L31: cmp #llo(0), r15 jeq .L29 inv r15 push #llo(-1) mov r15, r12 mov r11, r13 mov #llo(0), r14 mov r9, r15 call #Error add #llo(2), r1 cmp #llo(0), r15 jne .L1 .L49: mov r9, r14 mov.b r6, r15 call #Recovery .L29: add #llo(-1), r10 add #llo(2), r11 cmp #llo(0), r10 jne .L37 .L24: clrc rrc.b r8 cmp #llo(-8192), r11 jlo .L38 add #llo(-1), r5 add #llo(2), r9 cmp #llo(0), r5 jne .L39 .L15: clrc rrc.b r7 cmp #llo(-8192), r9 jlo .L40 .L1: /* epilogue: frame size=0 */ pop r5 pop r6 pop r7 pop r8 pop r9 pop r10 pop r11 ret /* epilogue end (size=8) */ /* function LongTest size 184 (169) */ .Lfe1: .size LongTest,.Lfe1-LongTest /********* End of function ******/ /********************************************************************* * File tst.c: code size: 184 words (0xb8) * incl. words in prologues: 7, epilogues: 8 *********************************************************************/