I am trying to write a slow C function in assembly.
To do this I want to embed assembly into my C code. The compiler is MPLAB C30. The manual explains how to do this, so that is great. What is bugging me, is how to avoid clobbering the W regs and memory space the compiler allocates. Say I have code like this, which processes each byte in 6 cycles (addr to be replaced with an address.)
As can be clearly seen W0, W1 and W2 would be clobbered by this and the processor would probably get confused or the program wouldn't work properly...
So how do I avoid this?
Any help appreicated!!
To do this I want to embed assembly into my C code. The compiler is MPLAB C30. The manual explains how to do this, so that is great. What is bugging me, is how to avoid clobbering the W regs and memory space the compiler allocates. Say I have code like this, which processes each byte in 6 cycles (addr to be replaced with an address.)
Rich (BB code):
; first code
mov #5, W0
mov #31, W1
; subsequent bytes
mov _TRISB, W2
rlc addr
bsw.c W2, W0
mov W2, _TRISB
nop
mov W1, _PORTB
So how do I avoid this?
Any help appreicated!!