aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/words/cold.asm
blob: 4547f5552d8a14cd3c50b2fe047054ab4f92cb3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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