Jump to content
Sign in to follow this  
amohr

bug when using inline assembly in 5.0.4

Recommended Posts

Hobknob made a post in the topic "Default value in EE " in the "C programming with C2C-plus compiler" forum with the following example:

//////////

asm last_addr equ $ ; save current address for assembly

 

asm org 0x2100 ; Eprom address when programming PIC

asm dw 12,34,56,78 ; set our bytes in eprom - only when programmed!

 

asm org last_addr ; restore current address for assembly to contniue as normal

///////////

 

to allow users to write specific data to flash memory when programing your device.  The reason why I want to do this is because I want to be able to overwrite specific portions of memory through a bootloader w/o having to write assembly.

 

so when I added the above code to my program I get the following error:

Warning: Not known opcode 'dw 12,34,56,78'

asm error: Location of '0' already occupied or not valid

asm error: Location of '0' already occupied or not valid

Warning: Timing in '_delay_ms' is wrong because of extra 'page' instructions

Warning: Timing in '_delay_ms' is wrong because of extra 'page' instructions

Warning: Timing in '_delay_ms' is wrong because of extra 'page' instructions

Warning: Timing in '_delay_ms' is wrong because of extra 'page' instructions

Share this post


Link to post
Share on other sites

so originally it worked (by moving the assembly to the end of the file), but now that my code just grew by a little bit I'm getting the error again :(

 

I just thought of a way to get around this.  Let me know if I can make the following assumption:

 

I can declare char[] arrays globally in my C code, and then watch where PicAnt places these arrays by looking at the lst file, and then overwrite these memory locations through a bootloader.  This sounds like it will work as long as PicAnt uses contiguous blocks of memory for the character arrays I create in my C code.

 

Another thing:  the PIC16f877 uses 14bit words right?  Is there any way I can access this size variable through C ?

Share this post


Link to post
Share on other sites
Guest Pavel

The 5.0.5 compiler version has a new pragma that reserves data in code or eeprom memory. Unfortunately this change wasn't added to the compiler help file. Help update is available to download here.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×