|
From: Scott D. <sc...@da...> - 2003-05-20 18:01:09
|
On Tue, 20 May 2003, Greg Hill wrote:
> I'm trying to get some inline assembly into a C file (it's a semi-precise
> time delay loop). Here's my sdcc version:
> SDCC : mcs51/gbz80/z80/avr/ds390/pic14/pic16/TININative/xa51/ds400 2.3.5
> (May 18 2003) (UNIX)
>
> It seems that the '$' character I've used in my label in the inline asm is
> confusing the peephole optimizer. (I used the numeric label with $ at the
> end because it's suggested in the current sdccman.pdf). Here's the output
> I get:
> gregh: ~/projects> sdcc -mpic14 -pp16f628 second.c
> Processor: p16f628
> Error while parsing peep rules (check peeph.def)
> Line: goto 00001$
> Token: '$'
>
> and here's the code for the function with the inline asm:
> void delay500us(unsigned char count) {
> for(; count > 0; count--) {
> _asm
> movlw 0xA6
> movwf _delay
> 00001$:
> decfsz _delay,f
> goto 00001$
> _endasm;
> }
> }
What happens if you do this:
_asm
movlw 0xA6
movwf _delay
L1: decfsz _delay,f
goto L1
_endasm;
The "assembler" for the inline assembly is a really simple 1-line
assembler. The label must occur on the same line of the instruction to
which it refers. The '$' is not a supported character. In fact in gpasm,
'$' is the "current address" operator. E.g. one can write goto $+2 to
branch 2 instructions beyond the address at which the goto is located.
Scott
|