From 67d25d837ac55f28a366c0a3b262e439a6e75fc3 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 19 Aug 2017 12:15:28 +0200 Subject: Add AmForth --- amforth-6.5/avr8/words/store-i_nrww.asm | 123 ++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 amforth-6.5/avr8/words/store-i_nrww.asm (limited to 'amforth-6.5/avr8/words/store-i_nrww.asm') diff --git a/amforth-6.5/avr8/words/store-i_nrww.asm b/amforth-6.5/avr8/words/store-i_nrww.asm new file mode 100644 index 0000000..85be220 --- /dev/null +++ b/amforth-6.5/avr8/words/store-i_nrww.asm @@ -0,0 +1,123 @@ +; ( n f-addr -- ) +; Memory +; writes n to flash memory using assembly code (code to be placed in boot loader section) +VE_DO_STOREI_NRWW: + .dw $ff09 + .db "(!i-nrww)",0 + .dw VE_HEAD + .set VE_HEAD = VE_DO_STOREI_NRWW +XT_DO_STOREI: + .dw PFA_DO_STOREI_NRWW +PFA_DO_STOREI_NRWW: + ; store status register + in temp1,SREG + push temp1 + cli + + movw temp2, tosl ; save the (word) address + loadtos ; get the new value for the flash cell + push xl + push xh + push yl + push yh + rcall DO_STOREI_atmega + pop yh + pop yl + pop xh + pop xl + ; finally clear the stack + loadtos + pop temp1 + ; restore status register (and interrupt enable flag) + out SREG,temp1 + + jmp_ DO_NEXT + +; +DO_STOREI_atmega: + ; write data to temp page buffer + ; use the values in tosl/tosh at the + ; appropiate place + rcall pageload + + ; erase page if needed + ; it is needed if a bit goes from 0 to 1 + com temp4 + com temp5 + and tosl, temp4 + and tosh, temp5 + or tosh, tosl + breq DO_STOREI_writepage + movw zl, temp2 + ldi temp0,(1<