EmbeddedRelated.com
Forums

syntax for asm in sdcc

Started by john111w June 8, 2012
I need to use the sdcc compiler in an IDE. I have about 16K of ASM51 code
that I need to compile with sdcc so that I can use the source in the debug
pane. The IDE only shows dissambly (with label numbers) unless you use C.

So I fugured I'd create a C "shell" and import my asm51 file

Where can I go to learn how to embed the asm?

The IDE has a C example which compiles with sdcc. I tried 2 hours of web
searches last night to find the syntax to add 2 trial lines.

__asm
mov a,b
mov b,a
__ endasm

I tried single underscore, double underscore, quotes, slashes, parens, as
shown in many web search examples 
I even tried without the mov's just 
__asm/
__endasm   as shown in an SDCC forum example.

I can't see how to create a thread in the SourceForge.net to ask this
question
Help is greatly appreciated.
	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On Jun 8, 5:50=A0pm, "john111w" <greenwick@n_o_s_p_a_m.nni.com> wrote:
> I need to use the sdcc compiler in an IDE. I have about 16K of ASM51 code > that I need to compile with sdcc so that I can use the source in the debu=
g
> pane. The IDE only shows dissambly (with label numbers) unless you use C. > > So I fugured I'd create a C "shell" and import my asm51 file > > Where can I go to learn how to embed the asm? > > The IDE has a C example which compiles with sdcc. I tried 2 hours of web > searches last night to find the syntax to add 2 trial lines. > > __asm > mov a,b > mov b,a > __ endasm > > I tried single underscore, double underscore, quotes, slashes, parens, as > shown in many web search examples > I even tried without the mov's just > __asm/ > __endasm =A0 as shown in an SDCC forum example. > > I can't see how to create a thread in the SourceForge.net to ask this > question > Help is greatly appreciated. > > --------------------------------------- > Posted throughhttp://www.EmbeddedRelated.com
Mmmm, I'm not sure about the '/' after asm. This is what I used a while ago to do some footling with interupts. __asm push psw push acc push dpl push dph push b mov a,#(.+9) push acc mov a,#((.+5) >> 8) push acc reti nop __endasm;
>On Jun 8, 5:50=A0pm, "john111w" <greenwick@n_o_s_p_a_m.nni.com> wrote: >> I need to use the sdcc compiler in an IDE. I have about 16K of ASM51
code
>> that I need to compile with sdcc so that I can use the source in the
debu=
>g >> pane. The IDE only shows dissambly (with label numbers) unless you use
C.
>> >> So I fugured I'd create a C "shell" and import my asm51 file >> >> Where can I go to learn how to embed the asm? >> >> The IDE has a C example which compiles with sdcc. I tried 2 hours of
web
>> searches last night to find the syntax to add 2 trial lines. >> >> __asm >> mov a,b >> mov b,a >> __ endasm >> >> I tried single underscore, double underscore, quotes, slashes, parens,
as
>> shown in many web search examples >> I even tried without the mov's just >> __asm/ >> __endasm =A0 as shown in an SDCC forum example. >> >> I can't see how to create a thread in the SourceForge.net to ask this >> question >> Help is greatly appreciated. >> >> --------------------------------------- >> Posted throughhttp://www.EmbeddedRelated.com > >Mmmm, I'm not sure about the '/' after asm. This is what I used a >while ago to do some footling with interupts. > > > __asm > push psw > push acc > push dpl > push dph > push b > mov a,#(.+9) > push acc > mov a,#((.+5) >> 8) > push acc > reti > > nop > > __endasm; >
--------------------------------------- Posted through http://www.EmbeddedRelated.com
>On Jun 8, 5:50=A0pm, "john111w" <greenwick@n_o_s_p_a_m.nni.com> wrote: >> I need to use the sdcc compiler in an IDE. I have about 16K of ASM51
code
>> that I need to compile with sdcc so that I can use the source in the
debu=
>g >> pane. The IDE only shows dissambly (with label numbers) unless you use
C.
>> >> So I fugured I'd create a C "shell" and import my asm51 file >> >> Where can I go to learn how to embed the asm? >> >> The IDE has a C example which compiles with sdcc. I tried 2 hours of
web
>> searches last night to find the syntax to add 2 trial lines. >> >> __asm >> mov a,b >> mov b,a >> __ endasm >> >> I tried single underscore, double underscore, quotes, slashes, parens,
as
>> shown in many web search examples >> I even tried without the mov's just >> __asm/ >> __endasm =A0 as shown in an SDCC forum example. >> >> I can't see how to create a thread in the SourceForge.net to ask this >> question >> Help is greatly appreciated. >> >> --------------------------------------- >> Posted throughhttp://www.EmbeddedRelated.com > >Mmmm, I'm not sure about the '/' after asm. This is what I used a >while ago to do some footling with interupts. > > > __asm > push psw > push acc > push dpl > push dph > push b > mov a,#(.+9) > push acc > mov a,#((.+5) >> 8) > push acc > reti > > nop > > __endasm; >
I just tried: __asm __endasm; received syntax error token-> '__endasm' column 8 (the letter m) --------------------------------------- Posted through http://www.EmbeddedRelated.com
On Fri, 08 Jun 2012 11:27:58 -0500, john111w wrote:

>>On Jun 8, 5:50=A0pm, "john111w" <greenwick@n_o_s_p_a_m.nni.com> wrote: >>> I need to use the sdcc compiler in an IDE. I have about 16K of ASM51 > code >>> that I need to compile with sdcc so that I can use the source in the > debu= >>g >>> pane. The IDE only shows dissambly (with label numbers) unless you use > C. >>> >>> So I fugured I'd create a C "shell" and import my asm51 file >>> >>> Where can I go to learn how to embed the asm? >>> >>> The IDE has a C example which compiles with sdcc. I tried 2 hours of > web >>> searches last night to find the syntax to add 2 trial lines. >>> >>> __asm >>> mov a,b >>> mov b,a >>> __ endasm >>> >>> I tried single underscore, double underscore, quotes, slashes, parens, > as >>> shown in many web search examples >>> I even tried without the mov's just >>> __asm/ >>> __endasm =A0 as shown in an SDCC forum example. >>> >>> I can't see how to create a thread in the SourceForge.net to ask this >>> question >>> Help is greatly appreciated. >>> >>> --------------------------------------- Posted >>> throughhttp://www.EmbeddedRelated.com >> >>Mmmm, I'm not sure about the '/' after asm. This is what I used a while >>ago to do some footling with interupts. >> >> >> __asm >> push psw >> push acc >> push dpl >> push dph >> push b >> mov a,#(.+9) >> push acc >> mov a,#((.+5) >> 8) >> push acc >> reti >> >> nop >> >> __endasm; >> > I just tried: > __asm > __endasm; received syntax error token-> '__endasm' column 8 (the > letter m) > > > > --------------------------------------- Posted through > http://www.EmbeddedRelated.com
Perhaps you need to indent? You shouldn't -- but the compiler is obviously being picky on you. (I really like the Gnu "asm" syntax by the way -- in my opinion it's the best thought-out, and complete, way to implement assembly that I've seen). As a work-around, can you implement those critical functions entirely in assembly? You'll have call overhead, but you'll have less totally non- portable structures scattered around your code. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On Jun 8, 6:27=A0pm, "john111w" <greenwick@n_o_s_p_a_m.nni.com> wrote:
> >On Jun 8, 5:50=3DA0pm, "john111w" <greenwick@n_o_s_p_a_m.nni.com> wrote: > >> I need to use the sdcc compiler in an IDE. I have about 16K of ASM51 > code > >> that I need to compile with sdcc so that I can use the source in the > debu=3D > >g > >> pane. The IDE only shows dissambly (with label numbers) unless you use > C. > > >> So I fugured I'd create a C "shell" and import my asm51 file > > >> Where can I go to learn how to embed the asm? > > >> The IDE has a C example which compiles with sdcc. I tried 2 hours of > web > >> searches last night to find the syntax to add 2 trial lines. > > >> __asm > >> mov a,b > >> mov b,a > >> __ endasm > > >> I tried single underscore, double underscore, quotes, slashes, parens, > as > >> shown in many web search examples > >> I even tried without the mov's just > >> __asm/ > >> __endasm =3DA0 as shown in an SDCC forum example. > > >> I can't see how to create a thread in the SourceForge.net to ask this > >> question > >> Help is greatly appreciated. > > >> --------------------------------------- > >> Posted throughhttp://www.EmbeddedRelated.com > > >Mmmm, =A0I'm not sure about the '/' after asm. This is what I used a > >while ago to do some footling with interupts. > > > =A0 =A0__asm > > =A0 =A0push psw > > =A0 =A0push acc > > =A0 =A0push dpl > > =A0 =A0push dph > > =A0 =A0push b > > =A0 =A0mov a,#(.+9) > > =A0 =A0push =A0 =A0acc > > =A0 =A0mov a,#((.+5) >> 8) > > =A0 =A0push =A0 =A0acc > > =A0 =A0reti > > > =A0 =A0nop > > > =A0 =A0__endasm; > > I just tried: > __asm > __endasm; =A0received syntax error token-> '__endasm' column 8 =A0(the le=
tter
> m) > > --------------------------------------- > Posted throughhttp://www.EmbeddedRelated.com- Hide quoted text - > > - Show quoted text -
I tried downloading the latest version and the code compiled - didn't check if it worked :( too much hassle right now. Version: C:\SDCC\bin>sdcc -v SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ ds400/hc08/s08 3.1.5 #7874 (Jun 7 2012) (MINGW32) C:\SDCC\bin>
On 08.06.2012 23:02, Rocky wrote:

> I tried downloading the latest version and the code compiled - didn't > check if it worked :( too much hassle right now. > Version: > C:\SDCC\bin>sdcc -v > SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ > ds400/hc08/s08 > 3.1.5 #7874 (Jun 7 2012) (MINGW32)
Historically sdcc used _asm and _endasm. Some time ago this was changed to also allow __asm and __endasm. Recently the old _asm and _endasm has been removed, and sdcc now only supports the standard-compliant __asm and __endasm. So depending on how old the sdcc version used is, it will support _asm, __asm or both. Philipp