|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
Possible gcc bugHi everyone!
Compiling the following C code, that reproduces the problem encountered, with no optimizations (-O0) produces bad output file: typedef unsigned long u32; u32 var; int main() { var = 12345678; var >>= 16; return var; } The listing file is as follows: shift_noopt_orig.elf: file format elf32-msp430 Disassembly of section .text: 00003100 <__low_level_init>: 3100: b2 40 80 5a mov #23168, &0x0120 ;#0x5a80 3104: 20 01 00003106 <__do_copy_data>: 3106: 3f 40 00 00 mov #0, r15 ;#0x0000 310a: 0f 93 cmp #0, r15 ;r3 As==00 310c: 05 24 jz $+12 ;abs 0x3118 310e: 2f 83 decd r15 ; 3110: 9f 4f 5c 31 mov 12636(r15),4352(r15); 3114: 00 11 3116: fb 23 jnz $-8 ;abs 0x310e 00003118 <__do_clear_bss>: 3118: 3f 40 04 00 mov #4, r15 ;#0x0004 311c: 0f 93 cmp #0, r15 ;r3 As==00 311e: 04 24 jz $+10 ;abs 0x3128 3120: 1f 83 dec r15 ; 3122: cf 43 00 11 mov.b #0, 4352(r15);r3 As==00 3126: fc 23 jnz $-6 ;abs 0x3120 00003128 <__jump_to_main>: 3128: 30 40 32 31 br #0x3132 ; 0000312c <__ctors_end>: 312c: 30 40 30 31 br #0x3130 ; 00003130 <_unexpected_>: 3130: 00 13 reti 00003132 <main>: 3132: 31 40 00 31 mov #12544, r1 ;#0x3100 3136: 04 41 mov r1, r4 ; 3138: b2 40 4e 61 mov #24910, &0x1100 ;#0x614e 313c: 00 11 313e: b2 40 bc 00 mov #188, &0x1102 ;#0x00bc 3142: 02 11 3144: 82 43 02 11 mov #0, &0x1102 ;r3 As==00 3148: 92 42 02 11 mov &0x1102,&0x1100 ;0x1102 314c: 00 11 314e: 82 43 02 11 mov #0, &0x1102 ;r3 As==00 3152: 1f 42 00 11 mov &0x1100,r15 ;0x1100 3156: 30 40 5a 31 br #0x315a ; 0000315a <__stop_progExec__>: 315a: ff 3f jmp $+0 ;abs 0x315a Disassembly of section .bss: 00001100 <__bss_start>: 1100: 00 00 beq ... It seems that the instruction at address 3144h should not be present, only the one at 314eh. The idea used is to move the HI word to the LO word and then reset the HI word. The problem is that the HI part is reset before the move take place and this way the result will always be 0. It is important that this problem occurs only when compiling with no optimizations. Any suggestions on this matter are welcome. Regards, Alpar ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Mspgcc-users mailing list Mspgcc-users@... https://lists.sourceforge.net/lists/listinfo/mspgcc-users |
| Free Forum Powered by Nabble | Forum Help |