syntax for asm in sdcc

Jun 08, 2012 8 Replies

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

formatting link


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

formatting link

I still have a project that's still using sdcc, although it's an older rev (2.6) and I haven't been following possible syntax shifts in later releases. That said, it looks like you need _asm _endasm; as in this example from the 2.6 manual:

void to_buffer( unsigned char c ) { c; // to avoid warning: unreferenced function argument _asm ; save used registers here. ; If we were still using r2,r3 we would have to push them here. ; if( head != (unsigned char)(tail-1) ) mov a,_tail dec a xrl a,_head ; we could do an ANL a,#0x0f here to use a smaller buffer (see below) jz t_b_end$ ; ; buf[ head++ ] = c; mov a,dpl ; dpl holds lower byte of function argument mov dpl,_head ; buf is 0x100 byte aligned so head can be used directly mov dph,#(_buf> >8) movx @dptr,a inc _head ; we could do an ANL _head,#0x0f here to use a smaller buffer (see above) t_b_end$: ; restore used registers here _endasm; }

Rich Webb Norfolk, VA

g

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;

code

debu=

C.

web

as

--------------------------------------- Posted through

formatting link

code

debu=

C.

web

as

I just tried: __asm __endasm; received syntax error token-> '__endasm' column 8 (the letter m)

--------------------------------------- Posted through

formatting link

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

tter

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>

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

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required