Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Macro "rept" inside sdcc

2007-09-05
2013-03-12
  • franciscojar
    franciscojar
    2007-09-05

    Hi all,

    I do not know how implement a "rept" command in order to repeat some instructions:

    code.c

    #include<pic/pic16f819.h>

    #define repeat_nops(x) { _asm rept x nop _endasm; }

    void main(void)
    {
    PORTA = 0xF0; //do something
    repeat_nops(5); // place 5 nop instructions
    PORTA = 0x0F; //do something
    repeat_nops(10); // place 10 nop instructions
    }

    compile using:
    sdcc --debug -mpic14 -p16f819 --lib-path /usr/share/sdcc/lib/pic -c repeat_nop.c

    repeat_nop.asm:171:Warning [230] directive ignored when debug info is disabled
    repeat_nop.asm:182:Error [103] syntax error
    repeat_nop.asm:191:Warning [230] directive ignored when debug info is disabled
    repeat_nop.asm:200:Error [103] syntax error

    The code is:

    ;--------------------------------------------------------
    ; code
    ;--------------------------------------------------------
    code_repeat_nop    code
    ;***
    ;  pBlock Stats: dbName = M
    ;***
    ;entry:  _main    ;Function start
    ; 2 exit points
    ;has an exit
    ;; Starting pCode block
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:3266:genLabel *{*
    ;; ***    genLabel  3269
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:2888:genFunction *{*
    ;; ***    genFunction  2890 curr label offset=0previous max_key=0
    _main    ;Function start
    ; 2 exit points
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:9988:genAssign *{*
    ;; ***    genAssign  9989
    ;; ***    aopForSym 512
    ;;    600 sym->rname = _PORTA, size = 1
    ;;     line = 9998 result AOP_DIR=_PORTA, size=1, left -=-, size=0, right AOP_LIT=0xf0, size=1
    ;; ***    genAssign  10090
    ; >>> gen.c:10095:genAssign
        .line    7; "repeat_nop.c"    PORTA = 0xF0; //do something
        MOVLW    0xf0
    ; >>> gen.c:10097:genAssign
    ;;    1384
    ;;    1400  _PORTA   offset=0
        BCF    STATUS,5
        BCF    STATUS,6
        MOVWF    _PORTA
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:6333:genInline *{*
    ;; ***    genInline  6334
        rept 5 nop   <----------------------- HERE IS THE ERROR
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:9988:genAssign *{*
    ;; ***    genAssign  9989
    ;; ***    aopForSym 512
    ;;    600 sym->rname = _PORTA, size = 1
    ;;     line = 9998 result AOP_DIR=_PORTA, size=1, left -=-, size=0, right AOP_LIT=0x0f, size=1
    ;; ***    genAssign  10090
    ; >>> gen.c:10095:genAssign
        .line    9; "repeat_nop.c"    PORTA = 0x0F; //do something
        MOVLW    0x0f
    ; >>> gen.c:10097:genAssign
    ;;    1384
    ;;    1400  _PORTA   offset=0
        MOVWF    _PORTA
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:6333:genInline *{*
    ;; ***    genInline  6334
        rept 10 nop   <----------------------- HERE IS THE ERROR
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:3266:genLabel *{*
    ;; ***    genLabel  3269
    ;; gen.c:2837:resultRemat *{*
    ;; gen.c:3081:genEndFunction *{*
    ;; ***    genEndFunction  3083
        RETURN   
    ; exit point of _main

    Would you please tell me how use the repeat command?

    Thanks in advance.

    franciscojar