aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/words/cold.asm
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/avr8/words/cold.asm')
-rw-r--r--amforth-6.5/avr8/words/cold.asm52
1 files changed, 52 insertions, 0 deletions
diff --git a/amforth-6.5/avr8/words/cold.asm b/amforth-6.5/avr8/words/cold.asm
new file mode 100644
index 0000000..4547f55
--- /dev/null
+++ b/amforth-6.5/avr8/words/cold.asm
@@ -0,0 +1,52 @@
+; ( i*x -- ) (R: j*y -- )
+; System
+; start up amforth.
+VE_COLD:
+ .dw $ff04
+ .db "cold"
+ .dw VE_HEAD
+ .set VE_HEAD = VE_COLD
+XT_COLD:
+ .dw PFA_COLD
+PFA_COLD:
+ in_ mcu_boot, MCUSR
+ clr zerol
+ clr zeroh
+ clr isrflag
+ out_ MCUSR, zerol
+ ; clear RAM
+ ldi zl, low(ramstart)
+ ldi zh, high(ramstart)
+clearloop:
+ st Z+, zerol
+ cpi zl, low(sram_size+ramstart)
+ brne clearloop
+ cpi zh, high(sram_size+ramstart)
+ brne clearloop
+ ; init first user data area
+ ; allocate space for User Area
+.dseg
+ram_user1: .byte SYSUSERSIZE + APPUSERSIZE
+.cseg
+ ldi zl, low(ram_user1)
+ ldi zh, high(ram_user1)
+ movw upl, zl
+ ; init return stack pointer
+ ldi temp0,low(rstackstart)
+ out_ SPL,temp0
+ std Z+4, temp0
+ ldi temp1,high(rstackstart)
+ out_ SPH,temp1
+ std Z+5, temp1
+
+ ; init parameter stack pointer
+ ldi yl,low(stackstart)
+ std Z+6, yl
+ ldi yh,high(stackstart)
+ std Z+7, yh
+
+ ; load Forth IP with starting word
+ ldi XL, low(PFA_WARM)
+ ldi XH, high(PFA_WARM)
+ ; its a far jump...
+ jmp_ DO_NEXT