That is some very simple code so what you want to do can be done entirely in assembly language. Inline if you have to. The basic flow is to allocate space on the stack (which will be in RAM) for your code, copy it, call it as a subroutine, when it returns, clean up the stack and exit. Something like: ;; Note that registers r12-r15 can be used at will without saving ;; their previous contents. #include .equ length,ramend-ramstart .text .func ramexe ramexe: sub #length,r1 ; reserve stack space mov r1,r13 ; setup to copy mov #ramstart,r14 mov #length,r15 loop: mov @r14+,@r13 ; copy code add #2,r13 sub #2,r15 jnz loop call r1 ; call function on stack add #length,r1 ; restore stack ret ramstart: mov #FRCTLPW,&FRCTL0 and #~(FRPWR|FRLPMPWR),&GCCTL0 bis #(LPM3_bits|GIE),r2 ret ramend: .endfunc .end
↧