Page 1 of 1

C code/asm

Posted: Sun Jul 01, 2007 10:21 am
by psf
I have to add a macro in asm code.
I follow the help file hints (_FCV etc) but it still give "missing semicolon...error)
They are only 30 line of simple asm, i wont translate in C (i dont' know) and neither in flowchart because Flowcode will build 100 line code for this!!!(so the timing will KO)
This is an example (not real) of what I need:

label1
btfsc portb,7
goto label1
call macro1
bcf status,C
rrf var2,F
return

macro1
nop
decfsz var1
goto macro1
return

Can you write for me the code that I need to insert in this C BLOCK?

Posted: Mon Jul 02, 2007 10:29 am
by Benj
Hello

Here is your code. I have reorganised it a little but i think the main problem was this line.

Code: Select all

decfsz _FCV_VAR1
which needed to be changed to

Code: Select all

decfsz _FCV_VAR1, F
Here is a complete listing of your code which should compile without any errors.

Code: Select all

asm{
label1: 
btfsc _portb,7 
goto label1 
mac1:
nop 
decfsz _FCV_VAR1,F 
goto mac1
bcf _status,C 
rrf _FCV_VAR2,F 
return 
}

Posted: Mon Jul 02, 2007 6:29 pm
by psf
Thanks for your reply, but I invented the code for learn the right method... if I had to call a macro in my asm code I just
CALL MACRO1 I suppose. In the first time I used _label 1 for label and call _ macro 1 for macro.... OK I'll try. thanks.

Posted: Tue Jul 10, 2007 10:04 am
by Steve
If you are using "CALL" in assembly, then the subroutine you are calling should be declared within the "supplementary code" window of Flowcode.

For example, if you had your own assembly subroutine like this:

Code: Select all

BIT_DELAY:
MOVLW 0x18
MOVWF _FCV_DELAY_COUNT
BIT_WAIT:
NOP
DECFSZ _FCV_DELAY_COUNT, F
GOTO BIT_WAIT
Then you would need to create a 'C' function in the Supplementary Code's "implementations" window like this:

Code: Select all

void bit_delay()
{
    asm
    {
        MOVLW 0x18
        MOVWF _FCV_DELAY_COUNT
        BIT_WAIT:
        NOP
        DECFSZ _FCV_DELAY_COUNT, F
        GOTO BIT_WAIT
    }
}
In fact, you do not need to declare a Flowcode "DELAY_COUNT" variable. It would be better to use a local 'C' variable like this:

Code: Select all

void bit_delay()
{
    char cDelayCount;
    asm
    {
        MOVLW 0x18
        MOVWF _cDelayCount
        BIT_WAIT:
        NOP
        DECFSZ _cDelayCount, F
        GOTO BIT_WAIT
    }
}
Then, anytime you want to call this routine, use a 'C' icon with either a straight 'C' function call:

Code: Select all

bit_delay();
Or from within your own embedded assembly:

Code: Select all

asm
{
  .
  .
  .
  CALL bit_delay
  .
  .
  .
}

Re: C code/asm

Posted: Mon Jan 31, 2011 9:09 pm
by keesp
Hi Steve,

In Flowcode 4, what is the correct way to make a subroutine call in a asm block?

I am trying to get the program below to run, but it keeps telling me it doesn't understand 'routine' after the Call.

Kind regards,

Kees

asm
{
BSF _status, RP0 ;
MOVLW 0x0 ;
MOVWF _trisa ;
BCF _status, RP0 ;
CALL Routine ;
GOTO Labelend ;

Routine:
MOVLW 0x03 ;
MOVWF _porta ;
RETURN ;

Labelend:
}

Re: C code/asm

Posted: Tue Feb 01, 2011 10:08 am
by Benj
Hello Kees,

Why not use C code its so much easier to read and use.

trisa = 0x0;
porta = 0x03;

There is a manual on the BoostC compiler available from the "Flowcode v4\BoostC\" directory named boostc.pdf. This should detail what the assembler code is capable of.

Re: C code/asm

Posted: Tue Feb 01, 2011 1:41 pm
by keesp
Hi Ben,

I am aware of this, but because the assignment is part of a course that aims to teach assembly, we want to show how subroutine calls are made. If, however, it is quite complicated in boostc, then maybe I'll skip this altogether ~)

Re: C code/asm

Posted: Tue Feb 01, 2011 2:34 pm
by Benj
Hello,

Here is a forum topic from the sourceboost forum detailing assembler macros in BoostC.
http://www.sourceboost.ipbhost.com/lofi ... t2032.html

Looks like assembler macros/subroutines are not supported by the compiler.

However I then came across this topic which seems to suggest they are supported.
http://forum.sourceboost.com/index.php? ... entry12625

Here is the code. You can give it a go but looking again the forum does not mention BoostC so this could be using their assembler compiler.

Code: Select all

main
call ONIRLED
goto main

ONIRLED
bsf STATUS,RP0
movlw 0x00
movwf TRISA
bcf STATUS,RP0
movlw 0xff
movwf PORTA
call delay
movlw 0x00
movwf PORTA
call delay
return

Re: C code/asm

Posted: Thu Feb 03, 2011 9:59 am
by keesp
It seems that I'll have to accept my losses on this one! Thanks Benj for searching. The example you found has probably been compiled with C2C or similar. BoostC only allows the C-style option.

Kees

Re: C code/asm

Posted: Wed May 23, 2012 12:08 pm
by jeannoor
hello everyone
i try to insert the bit delay(); function in a flowcode programme but it didn't work i don't know
this is my programme
if any one can help

Re: C code/asm

Posted: Wed May 23, 2012 1:35 pm
by jeannoor
this is the err :

Code: Select all

C:\Documents and Settings\Administrateur\Bureau\Nouveau dossier\asm in.c(118): error: general error
C:\Documents and Settings\Administrateur\Bureau\Nouveau dossier\asm in.c(138): error: general error
asm in.c failure

failure

Return code = 1