C code/asm
- psf
- Posts: 45
- Joined: Mon Jun 25, 2007 9:44 pm
- Location: Italia
- Has thanked: 6 times
- Been thanked: 2 times
C code/asm
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?
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?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello
Here is your code. I have reorganised it a little but i think the main problem was this line.
which needed to be changed to
Here is a complete listing of your code which should compile without any errors.
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
Code: Select all
decfsz _FCV_VAR1, F
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
}
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
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:
Then you would need to create a 'C' function in the Supplementary Code's "implementations" window like this:
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:
Then, anytime you want to call this routine, use a 'C' icon with either a straight 'C' function call:
Or from within your own embedded assembly:
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
Code: Select all
void bit_delay()
{
asm
{
MOVLW 0x18
MOVWF _FCV_DELAY_COUNT
BIT_WAIT:
NOP
DECFSZ _FCV_DELAY_COUNT, F
GOTO BIT_WAIT
}
}
Code: Select all
void bit_delay()
{
char cDelayCount;
asm
{
MOVLW 0x18
MOVWF _cDelayCount
BIT_WAIT:
NOP
DECFSZ _cDelayCount, F
GOTO BIT_WAIT
}
}
Code: Select all
bit_delay();
Code: Select all
asm
{
.
.
.
CALL bit_delay
.
.
.
}
Re: C code/asm
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:
}
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:
}
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: C code/asm
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: C code/asm
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 ~)
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 ~)
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: C code/asm
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.
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: C code/asm
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
Kees
Re: C code/asm
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
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
- Attachments
-
- asm in.fcf
- asm & C code on flowcode programme
- (5.5 KiB) Downloaded 573 times
Re: C code/asm
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