I have designed 2 short asm modules for copy data from code or xdata.
My goal is to replace the generic memcpy () and memset() library functions for most cases.
While this is working well I have some doubts if this is interrupt save. I dont plan to use that special
auto inc feature bDPTR_AUTO_INC because i think its not worth the trouble i might get.
;void fastccpy8 (unsigned char xdata *dest, //r6r7 ; unsigned char code *src, //r4r5 ; unsigned char size) //r3 sfr XBUS_AUX = 0xA2; ?PR?_fastccpy8?FASTCCOPY SEGMENT CODE PUBLIC _fastccpy8 $REGUSE _fastccpy8(R7,A,DPTR) RSEG ?PR?_fastccpy8?FASTCCOPY _fastccpy8: MOV XBUS_AUX,#0x01; select DPTR1, no auto inc MOV DPH,R6 MOV DPL,R7 ;destination DEC XBUS_AUX ;select DPTR0 MOV DPH, R4 MOV DPL, R5 ;source mov A,R3 MOV R7,A JZ ?C001 ;nothing todo ?C000: CLR A MOVC A,@A+DPTR ;read source INC DPTR ;no autoinc its not irq save DB 0A5H ;MOVX @DPTR1,A & INC DPTR1 DJNZ R7,?C000 ?C001: RET
I have successfully testet that in interrupt functions as well as in main context, but i still have doubts if it is working correctly in
complex applications with irqs possibly set on different priorities.
There is a simlar function fastxcpy8 for copy from xdata
Any ideas are welcome.