Page 1 of 1

compiler/linker error

Posted: Mon Jan 10, 2011 9:43 am
by keesp
I and one of my students are facing a compiler linker error when trying to use an Assembler macro in Flowcode 4 for PIC. Both of us are running Windows 7,`and using a 16F88a PIC.
The block that we are trying to run is the following:

asm
{
BSF _status, RP0 ;
MOVLW 0x0 ;
MOVWF _trisa ;
BCF _status, RP0 ;
MOVLW 0x30 ;
MOVWF 0x20 ;

SWAPF 0x20,1 ;
MOVF 0x20,0 ;
MOVWF _porta ;
}

When we try to run this, we get the following error:

D:\Archief\projects\Dirksen\pmc\koldewijn\ASM Les 4.c(91): error: error in built-in assembly
D:\Archief\projects\Dirksen\pmc\koldewijn\ASM Les 4.c(93): error: error in built-in assembly
D:\Archief\projects\Dirksen\pmc\koldewijn\ASM Les 4.c(94): error: error in built-in assembly
ASM Les 4.c success

failure

Return code = 1

Flowcode kan de C-code niet vertalen vanwege de volgende fout:

Als de flowchart C-code bevat, controleer die dan zorgvuldig. Als de flowchart geen C-code bevat of als die gegarandeerd vrij is van fouten, neem dan contact op met de technische ondersteuning.

FINISHED

Translated to English, I would get the idea that compiler works ok (this is confirmed when only C-code is generated), but that something goes wrong afterwards.

The tow messages trnaslate to:

Flowcode cannot translate the c-Code due to the following error:

If the flowchart contains C-code, then please check this carefully. If the flowchart does not contain C-Code, or is guaranteed error free, please contact the helpdesk.


Any ideas?

Thanks

Kees

Re: compiler/linker error

Posted: Mon Jan 10, 2011 10:18 am
by Benj
Hello,

The compiler is giving an error because it doesn't seem to like the way you were referencing the memory address.

I have changed the code to dynamically provide a memory address and this is working correctly.

Code: Select all

char temp;

asm
{
BSF _status, RP0 ;
MOVLW 0x0 ;
MOVWF _trisa ;
BCF _status, RP0 ;
MOVLW 0x30 ;
MOVWF _temp ;

SWAPF _temp,1 ;
MOVF _temp,0 ;
MOVWF _porta ;
}

Re: compiler/linker error

Posted: Mon Jan 10, 2011 10:24 am
by keesp
Thanks Ben!

Is this a workaround, or was the code wrong in the first place?

Thanks

Kees

Re: compiler/linker error

Posted: Mon Jan 10, 2011 10:53 am
by Benj
Hello,

The code looked ok and all I did was to replace your fixed memory address of 0x20 and swap it with the reference to the char C variable. You should be able to use fixed memory locations with the standard MPASM assembler but maybe BoostC does not like this as you could very easily start corrupting C variables.