Author Topic: Microchip PIC assembly  (Read 3039 times)

0 Members and 1 Guest are viewing this topic.

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Microchip PIC assembly
« on: June 20, 2015, 12:17:30 pm »
Hi,

I used assembly to program PIC MCUs long time ago. I switched to C because it's faster to develop. However from time to time I need to write some assembly code - especially for interrupts. Sometimes I want to write the whole firmware in assembler. The problem is that since microchip migrated to XC there is lamost no documentation for assembly language. I remember there were 2 ways to define variables in ram:
Code: [Select]
CBLOCK - absolute addressingand
Code: [Select]
.delay udata_acs
variable_name     res    1 ; number of bytes

That's not compatible with XC. Also I used to return from high priority interrupt like this:
Code: [Select]
RETFIE fastnow it's:
Code: [Select]
RETFIE f
What is the define for "access" and "banked"?

And most things are not well documented, or not documented at all. Where can I find assembly documentation and code examples. The whole "Microchip Libraries for Applications" is written in C. I can't easily search for application notes written in XC assembly which I can use as examples. I don't know how to reserve space for a variable in RAM ...

And the reason to write in assembly? It's really nice that they made high priority interrupts in PIC18 with automatic storage of most important registry. You can do really low latency interrupts. But not in C - it stores 10-20 more registers with 2 cycle MOVFF instructions and these registers are not even used.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Microchip PIC assembly
« Reply #1 on: June 20, 2015, 03:20:17 pm »
Just got to a show stopper. How do you call function that's defined in one assembly file from another assembly file. Before with C18 and assembler I had to declare the function with "extern":
Code: [Select]
extern functionA

call functionA

How do you do that in xc?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Microchip PIC assembly
« Reply #2 on: June 20, 2015, 03:32:53 pm »
XC8 assembler is based on Hi-Tech ASPIC assembler.  Its worth having a look around the old (archived) Hi-Tech forums for examples and explanations.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Microchip PIC assembly
« Reply #3 on: June 20, 2015, 04:13:01 pm »
I'm having second thoughts. It's been too many times when I tried to write in assembler or mixed C/Assembler with XC. It's not going to work. I would prefer to go with unsupported MPASM + C18. Can anyone tell me where can I get latest versions of these?

Edit - Found it:
http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=SW006011

I'm sick of software that's being rewritten only to remove features.
« Last Edit: June 20, 2015, 04:18:41 pm by npelov »
 

Offline Dinsdale

  • Regular Contributor
  • *
  • Posts: 77
  • Country: us
    • pretzelogic
Re: Microchip PIC assembly
« Reply #4 on: June 21, 2015, 02:56:12 am »
It has been a while, but I'm pretty sure that any .asm files in an MPLABX project will automatically be handled by the linker. You might check the linker options in the configuration section. I know that there is no other way to issue linker instructions, but a linker does run.
This can't be happening.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf