User Tools

Site Tools


home:software:picasm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

home:software:picasm [2009/01/21 01:41] – created thishome:software:picasm [2009/01/21 02:20] (current) this
Line 18: Line 18:
   VAR2 RES 1   VAR2 RES 1
  
-This will put _VAR1 / VAR1 at the same memory position. Never put the _VAR1 RES 0 *after* VAR1 RES 1! This would cause the assembler to give _VAR1 an address, but would not reserve any memory for it! +This will put _VAR1 / VAR1 at the same memory position. Never put the _VAR1 RES 0 **after** VAR1 RES 1! This would cause the assembler to give _VAR1 an address, but would not reserve any memory for it! 
  
 Also refer this discussion in the forum: http://www.midibox.org/forum/index.php/topic,12846.0.html Also refer this discussion in the forum: http://www.midibox.org/forum/index.php/topic,12846.0.html
  
  
 +===== How does the SDCC compiler push function parameters to the stack? =====
 +  unsigned char FRAM_WriteBuf(unsigned char device_addr,unsigned int address,unsigned char byte_count, unsigned char * buffer) __wparam;
  
 +  * If the function is defined with the __WPARAM directive, the first byte of the first parameter will be moved to WREG. 
 +  * All the other paramteres will be pushed to the stack in reverse direction (last parameter first).
 +  * If a parameter is more than one byte long, always the most significant byte will be pushed first.
 +  * Pointer types can have different sizes (depends on the target device, maybe also configuarble). When I compiled the code with the above function call for a PIC18F452, the pointer parameter was 3 bytes long. (**Update this info if you know more**)
 +  * If the first parameter is more than one byte long, the MSB goes to WREG, the other bytes will be pushed to the stack **last** (also MSB to LSB).
 +
 +The reverse direction makes sense when popping the parameters from the stack. The first byte popped will be the first parameter's LSB, the last byte popped is the last parameters MSB. So if the pointer parameter is the last parameter, you will not have to care if it is a 2 or 3 byte-type. You just read LSB / MSB, if there's a byte more (and you don't need it for the target's device address-range), you just forget about it.
home/software/picasm.1232502089.txt.gz · Last modified: 2009/01/21 01:41 by this