From: Kalus M. <mic...@on...> - 2011-04-13 08:59:06
|
Hi. Recently someone asked how otherwise imported subroutines (c-code) can be used by amforth. You may use icall of AVR instruction set to do so. Include icall.asm example in your application to test it. Add more stack to register moves if necessary for a given subroutine. Michael ; ( adr -- ) ; R( -- ) ; use icall to execute a code subroutine ; operation: PC <-- Z and push PC+1 to returnstack. VE_ICALL: .dw $ff05 .db "icall",0 .dw VE_HEAD .set VE_HEAD = VE_ICALL XT_ICALL: .dw PFA_ICALL PFA_ICALL: movw zl,tosl loadtos icall jmp DO_NEXT ; to test icall make a subroutine: subdup: savetos ret subdrop: loadtos ret |