From nico at nctdev.nl Wed May 27 20:04:16 2009 From: nico at nctdev.nl (N. Coesel) Date: Wed, 27 May 2009 22:04:16 +0200 Subject: Problem with SuperH inline assembly Message-ID: <3.0.5.32.20090527220416.012e76e0@192.168.2.20> I'm evaluating the SuperH package and I ran into a problem when using inline assembly. I'm trying to compile the attached test.c (a small dummy program to reproduce the problem) but I get the an unknown opcode error on the inline assembly. I tried changing the isa and architecture but this has no effect. C:\software\H8 gcc>sh-linux-gnu-gcc -Wa,-ahld -m2 test.c >test.lst C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s: Assembler messages: C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s:14: Error: unknown opcode C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s:17: Error: unknown opcode I also attached the assembler listing. I also have some assembler files which have been assembled using an older version of as. These won't assemble either. The .h8300s directive as described in the manual is also not recognized. I guess the assembler is not complete. Nico Coesel -------------- next part -------------- //#include //#include unsigned char get_ccr() { /* * haal het ccr irq bit op */ unsigned char temp; asm(" sub.l r0,r0 "); asm(" stc.b ccr,r0l "); return temp; } int main() { unsigned char a=0; a=get_ccr(); return a; } -------------- next part -------------- Renesas / SuperH SH GAS Little Endian C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s page 1 1 .file "test.c" 2 .text 3 .little 4 .text 5 .align 1 6 .global get_ccr 8 get_ccr: 9 ???? E62F mov.l r14, at -r15 10 ???? 007F add #-4,r15 11 ???? F36E mov r15,r14 12 #APP 13 ! 11 "test.c" 1 14 sub.l r0,r0 15 ! 0 "" 2 16 ! 12 "test.c" 1 17 stc.b ccr,r0l 18 ! 0 "" 2 19 #NO_APP 20 ???? E361 mov r14,r1 21 ???? 0071 add #3,r1 22 ???? 1061 mov.b @r1,r1 23 ???? 1C61 extu.b r1,r1 24 ???? 1360 mov r1,r0 25 ???? 007E add #4,r14 26 ???? E36F mov r14,r15 27 ???? F66E mov.l @r15+,r14 28 ???? 0B00 rts 29 ???? 0900 nop 31 .align 1 32 .global main 34 main: 35 ???? E62F mov.l r14, at -r15 36 ???? 224F sts.l pr, at -r15 37 ???? 007F add #-4,r15 38 ???? F36E mov r15,r14 39 ???? E362 mov r14,r2 40 ???? 0072 add #3,r2 41 ???? 00E1 mov #0,r1 42 ???? 1022 mov.b r1, at r2 43 ???? 00D1 mov.l .L5,r1 44 ???? 0B41 jsr @r1 45 ???? 0900 nop 46 ???? 0361 mov r0,r1 47 ???? 1362 mov r1,r2 48 ???? E361 mov r14,r1 49 ???? 0071 add #3,r1 50 ???? 2021 mov.b r2, at r1 51 ???? E361 mov r14,r1 52 ???? 0071 add #3,r1 53 ???? 1061 mov.b @r1,r1 54 ???? 1C61 extu.b r1,r1 55 ???? 1360 mov r1,r0 56 ???? 007E add #4,r14 57 ???? E36F mov r14,r15 58 ???? 264F lds.l @r15+,pr 59 ???? F66E mov.l @r15+,r14 60 ???? 0B00 rts Renesas / SuperH SH GAS Little Endian C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s page 2 61 ???? 0900 nop 62 .L6: 63 .align 2 64 .L5: 65 ???? 00000000 .long get_ccr 67 .ident "GCC: (Sourcery G++ Lite 4.3-143) 4.3.3" 68 .section .note.GNU-stack,"", at progbits From lethal at linux-sh.org Thu May 28 03:37:55 2009 From: lethal at linux-sh.org (Paul Mundt) Date: Thu, 28 May 2009 12:37:55 +0900 Subject: [superh-gnu-discuss] Problem with SuperH inline assembly In-Reply-To: <3.0.5.32.20090527220416.012e76e0@192.168.2.20> References: <3.0.5.32.20090527220416.012e76e0@192.168.2.20> Message-ID: <20090528033755.GA5628@linux-sh.org> On Wed, May 27, 2009 at 10:04:16PM +0200, N. Coesel wrote: > I'm evaluating the SuperH package and I ran into a problem when using > inline assembly. > > I'm trying to compile the attached test.c (a small dummy program to > reproduce the problem) but I get the an unknown opcode error on the inline > assembly. I tried changing the isa and architecture but this has no effect. > > C:\software\H8 gcc>sh-linux-gnu-gcc -Wa,-ahld -m2 test.c >test.lst > C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s: Assembler messages: > C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s:14: Error: unknown opcode > C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s:17: Error: unknown opcode > > I also attached the assembler listing. I also have some assembler files > which have been assembled using an older version of as. These won't > assemble either. The .h8300s directive as described in the manual is also > not recognized. I guess the assembler is not complete. > You are attempting to use H8300 assembly on SuperH, of course this will not work, they are completely different architectures. Try your test case with an H8 toolchain. From nico at nctdev.nl Thu May 28 17:23:07 2009 From: nico at nctdev.nl (N. Coesel) Date: Thu, 28 May 2009 19:23:07 +0200 Subject: [superh-gnu-discuss] Problem with SuperH inline assembly In-Reply-To: <20090528033755.GA5628@linux-sh.org> References: <3.0.5.32.20090527220416.012e76e0@192.168.2.20> <3.0.5.32.20090527220416.012e76e0@192.168.2.20> Message-ID: <3.0.5.32.20090528192307.01235d38@192.168.2.20> At 12:37 28-5-2009 +0900, Paul Mundt wrote: >On Wed, May 27, 2009 at 10:04:16PM +0200, N. Coesel wrote: >> I'm evaluating the SuperH package and I ran into a problem when using >> inline assembly. >> >> I'm trying to compile the attached test.c (a small dummy program to >> reproduce the problem) but I get the an unknown opcode error on the inline >> assembly. I tried changing the isa and architecture but this has no effect. >> >> C:\software\H8 gcc>sh-linux-gnu-gcc -Wa,-ahld -m2 test.c >test.lst >> C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s: Assembler messages: >> C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s:14: Error: unknown opcode >> C:\DOCUME~1\nctnico\LOCALS~1\Temp\ccohSo3P.s:17: Error: unknown opcode >> >> I also attached the assembler listing. I also have some assembler files >> which have been assembled using an older version of as. These won't >> assemble either. The .h8300s directive as described in the manual is also >> not recognized. I guess the assembler is not complete. >> >You are attempting to use H8300 assembly on SuperH, of course this will >not work, they are completely different architectures. Try your test case >with an H8 toolchain. Thanks for looking into it. The target I use has an H8S cpu. I realize now that the 'S' doesn't stand for SuperH. Sorry for the confusion. It has been several years since I have been using the Renesas chips. Nico Coesel