Assembler Errors

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Assembler Errors

Post by viki2000 »

I downloaded and tested “Embedding C and Assembler code.fcfx” from here:
https://www.matrixtsl.com/flowcode/support/
During compilation in HEX I have errors. I have tried other assembly code too and I have similar errors mostly related with expected ")" and ";"
Target folder: C:\FC7
Source name: C:\FC7\Embedding C and Assembler code.fcfx
Title:
Description:
Device: PIC.16F.16F88
Generated by: Flowcode v7.2.1.4
Date: Monday, July 17, 2017 15:44:42
Users: 1
Registered to:
Licence key:
http://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe --chip=16F88 "Embedding C and Assembler code.c" --MSGDISABLE=359,1273,1388
Microchip MPLAB XC8 C Compiler (PRO Mode) V1.41
Build date: Jan 24 2017
Part Support Version: 1.41
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

Embedding C and Assembler code.c: main()
691: FCD_LED7Seg40_ShowDigit(2, FCV_COUNT2, 1);
^ (361) function declared implicit int (warning)
704: {
^ (317) "(" expected
^ (318) string expected
^ (194) ")" expected
^ (312) ";" expected
Embedding C and Assembler code.c:
728: mainendloop: goto mainendloop;
^ (374) missing basic type; int assumed (warning)
^ (314) ";" expected
729: }
^ (285) no identifier in declaration
^ (374) missing basic type; int assumed (warning)
^ (314) ";" expected
(908) exit status = 1
(908) exit status = 1

C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe reported error code 1



FINISHED

User avatar
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: Assembler Errors

Post by Benj »

Hello,

Thanks for letting us know that will be a v6 example. I'll get it changed and updated for v7 for you.

User avatar
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: Assembler Errors

Post by Benj »

Right this now works for me, the components have a bit of random code generation so may not fully match up on your machine.

If you still get compile errors then look at the C code, specifically the main to get the 7-seg macro call syntax correct.
Embedding C and Assembler code.fcfx
(13.85 KiB) Downloaded 299 times

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Assembler Errors

Post by viki2000 »

The example modified above is compiled without any problems.
It seems a syntax problem due to the fact that Flowcode 7 uses Microchip XC compilers and Flowcode 6 uses BoostC compilers.
Is that right?
The example that was provided uses one asm inline instruction:

Code: Select all

asm ("INCF _FCV_COUNT2, F");
But, what if I have many instructions?
Then what are the options with Flowcode 7?
Dou I have to write a list of such instructions as below?

Code: Select all

asm (" ASM Instruction 1");
asm (" ASM Instruction 2");
asm (" ASM Instruction 3");
asm (" ASM Instruction 4");
Or maybe as was suggested here? viewtopic.php?f=63&t=18487&p=79416&hili ... bly#p79416

Code: Select all

asm(
" ASM Instruction 1 \n"
" ASM Instruction 2 \n"
" ASM Instruction 3 \n"
" ASM Instruction 4 \n"
);
Is any other way?
Normally XC compilers let you embed between #asm and #endasm the assembly instructions.
What I find annoying to the solutions above is the usage of “” and/or ; and \n
The best way it would the simpler way, meaning just #asm and #endasm with or without # or { } or ( ) and then in between only ASM instructions without any additional “” and/or ; or \n
That’s why I asked if it is any other way or if can be changed/simplified in future.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Assembler Errors

Post by LeighM »

Normally XC compilers let you embed between #asm and #endasm the assembly instructions.
Yes, with Flowcode V7 you can do that

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Assembler Errors

Post by viki2000 »

Could you please provide an example for multiple ASM instructions to prove that?

For example, what works for me is this:

Code: Select all

asm
(
        //multiply x*x
        "MOV _FCV_X,W0, \n"
        "MOV _FCV_X,W1, \n"
        "MUL.UU W0,W1,W2, \n"

        //get the result from W3 in y
        "MOV W3,_FCV_Y"
);
But next code does not work:

Code: Select all

#asm
     //multiply x*x
     MOV _FCV_X,W0
     MOV _FCV_X,W1
     MUL.UU W0,W1,W2

     //get the result from W3 in y
     MOV W3,_FCV_Y
#endasm

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Assembler Errors

Post by LeighM »

What did your first example work with?
And what target device was used?
I don't think your ASM is valid PIC code.

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Assembler Errors

Post by viki2000 »

If you can provide any example with #asm and #endasm with or without # or { } or ( ) and then in between only ASM instruction without any additional “” and/or ; or \n, then I think it should work.
Did you test one?
My case is PIC24 family, particular PIC24HJ64GP202.
I have tested the ASM code also with other IDE and C compilers as: MPLABX + XC16 and CCS C compiler and there is no error.
Here is the code used with Flowcode 7.
The code that works:
PIC24HJ64GP202_ASM_GOOD.fcfx
PIC24HJ64GP202_ASM_GOOD
(7.09 KiB) Downloaded 260 times
The code that does not work:
PIC24HJ64GP202_ASM_BAD.fcfx
PIC24HJ64GP202_ASM_BAD
(7.04 KiB) Downloaded 249 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Assembler Errors

Post by LeighM »

OK, I see, you were on xc8 earlier, and PIC16 family, which does accept #asm/#endasm
Looks like xc16 does not.
I'll have to have a closer look at that.
In the meantime, at least you do have a working solution :)

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Assembler Errors

Post by viki2000 »

XC16 C Compiler - User’s Guide

Page 42
2.5.16.2 DIFFERENCES
The 8-bit compilers have used either the asm() or #asm ... #endasm constructs to insert in-line assembly code.
This is the same syntax used by the 16- and 32-bit compilers.
Then page 227 onwards.
http://ww1.microchip.com/downloads/en/D ... 02071F.pdf

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Assembler Errors

Post by LeighM »

Yes, thanks for that.
I have just been reading a section on CCI, Common C Interface, looks like #asm #endasm blocks have been dropped in favor of asm()
(odd change? :? , but you learn something new every day :D )

Post Reply