Difference between revisions of "BoostC Explaining Dot H Files"

From OpenCircuits
Jump to navigation Jump to search
(New page: Draft Not Ready This is my russ_hensel explanation of BoostC.h. Others are welcome to contribute. It is a work in progress, and may or may not be correct. I believe that boostc.h...)
 
Line 8: Line 8:
  
  
//Helper macros
+
== Helper macros ==
  
 
ex:
 
ex:
#define clear_bit( reg, bitNumb ) ((reg) &= ~(1 << (bitNumb)))
+
    #define clear_bit( reg, bitNumb ) ((reg) &= ~(1 << (bitNumb)))
  
These are inline functions using #defines with arguments. ( see [[]] ) many C programmes use these expressions directly in there code, but using clear_bit instead of equivalent is bothe easier to read and write.  It make the intent of the program cleared, and may make the code easier to port.
+
These are inline functions using #defines with arguments. ( see [[]] ) many C programmers use these expressions directly in there code, but using clear_bit instead of equivalent is bothe easier to read and write.  It make the intent of the program cleared, and may make the code easier to port.
 +
 
 +
 
 +
=== MAKESHORT ===
 +
 
 +
    #define MAKESHORT( dst, lobyte, hibyte ) asm movf _##lobyte, W \
 +
    asm movwf _##dst \
 +
  asm movf _##hibyte, W \
 +
      asm movwf _##dst##+1
 +
 
 +
 
 +
Again an inline functions using #define with arguments.  There are few other things going on here:
 +
 
 +
* using the asm keyword to directly code assembler code
 +
* using \ to make the multiline macro be read as a single line
 +
* using ## for I do not know what, but I am working on it.
 +
 
 +
From reading this macro we can see that BoostC store the low byte in low memory and the high byte in higher memory.  This is called bigendien or the reverse, I need to look it up.  Useful to know if you want to do byte manipulations on multibyte data.
 +
 
 +
== Delay functions generated by linker ==
 +
Not quite sure how the linker generates these, but I do understand that the linker needs to know the clock speed to do it.  This makes it hard to use precompiled libary functions unless a different one was used for clock speed.  Including this allows the compiler to compile what ever call is needed in your C code.

Revision as of 20:07, 9 March 2009

Draft Not Ready


This is my russ_hensel explanation of BoostC.h. Others are welcome to contribute. It is a work in progress, and may or may not be correct.


I believe that boostc.h get included in almost all BoostC compilitations, think this may be via system.h, but I have not figured this out yet.


Helper macros

ex:

    #define clear_bit( reg, bitNumb )	((reg) &= ~(1 << (bitNumb)))

These are inline functions using #defines with arguments. ( see [[]] ) many C programmers use these expressions directly in there code, but using clear_bit instead of equivalent is bothe easier to read and write. It make the intent of the program cleared, and may make the code easier to port.


MAKESHORT

    #define MAKESHORT( dst, lobyte, hibyte )	asm movf _##lobyte, W \
   						asm movwf _##dst \
  						asm movf _##hibyte, W \
      						asm movwf _##dst##+1


Again an inline functions using #define with arguments. There are few other things going on here:

  • using the asm keyword to directly code assembler code
  • using \ to make the multiline macro be read as a single line
  • using ## for I do not know what, but I am working on it.

From reading this macro we can see that BoostC store the low byte in low memory and the high byte in higher memory. This is called bigendien or the reverse, I need to look it up. Useful to know if you want to do byte manipulations on multibyte data.

Delay functions generated by linker

Not quite sure how the linker generates these, but I do understand that the linker needs to know the clock speed to do it. This makes it hard to use precompiled libary functions unless a different one was used for clock speed. Including this allows the compiler to compile what ever call is needed in your C code.