aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/words/reg-b.asm
blob: 4b77e99683947088c9e347aa039e6c50c7096979 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
; ( -- n2 ) 
; Extended VM
; Read memory pointed to by register B (Extended VM)
VE_BFETCH:
    .dw $ff02
    .db "b@"
    .dw VE_HEAD
    .set VE_HEAD = VE_BFETCH
XT_BFETCH:
    .dw PFA_BFETCH
PFA_BFETCH:
    savetos
    movw zl, bl
    ld tosl, Z+
    ld tosh, Z+
    jmp_ DO_NEXT

; ( n1 -- n2 )
; Extended VM
; Read memory pointed to by register B plus offset (Extended VM)
VE_NBFETCH:
    .dw $ff03
    .db "nb@",0
    .dw VE_HEAD
    .set VE_HEAD = VE_NBFETCH
XT_NBFETCH:
    .dw PFA_NBFETCH
PFA_NBFETCH:
    movw zl, bl
    add zl, tosl
    adc zh, tosh
    ld tosl, Z+
    ld tosh, Z+
    jmp_ DO_NEXT

; ( -- n )
; Extended VM
; Read memory pointed to by register B, increment B by 1 cell (Extended VM)
VE_BFETCHPLUS:
    .dw $ff03
    .db "b@+",0
    .dw VE_HEAD
    .set VE_HEAD = VE_BFETCHPLUS
XT_BFETCHPLUS:
    .dw PFA_BFETCHPLUS
PFA_BFETCHPLUS:
    savetos
    movw zl, bl
    ld tosl, Z+
    ld tosh, Z+
    movw bl, zl
    jmp_ DO_NEXT

; ( -- n )
; Extended VM
; Read memory pointed to by register B, decrement B by 1 cell (Extended VM)
VE_BFETCHMINUS:
    .dw $ff03
    .db "b@-",0
    .dw VE_HEAD
    .set VE_HEAD = VE_BFETCHMINUS
XT_BFETCHMINUS:
    .dw PFA_BFETCHMINUS
PFA_BFETCHMINUS:
    savetos
    movw zl, bl
    ld tosh, -Z
    ld tosl, -Z
    movw bl, zl
    jmp_ DO_NEXT

; ( n -- )
; Extended VM
; Write memory pointed to by register B (Extended VM)
VE_BSTORE:
    .dw $ff02
    .db "b!"
    .dw VE_HEAD
    .set VE_HEAD = VE_BSTORE
XT_BSTORE:
    .dw PFA_BSTORE
PFA_BSTORE:
    movw zl, bl
    st Z+, tosl
    st Z+, tosh
    loadtos
    jmp_ DO_NEXT

; ( n offs -- )
; Extended VM
; Write memory pointed to by register B plus offset (Extended VM)
VE_NBSTORE:
    .dw $ff03
    .db "nb!",0
    .dw VE_HEAD
    .set VE_HEAD = VE_NBSTORE
XT_NBSTORE:
    .dw PFA_NBSTORE
PFA_NBSTORE:
    movw zl, bl
    add zl, tosl
    adc zh, tosh
    loadtos
    st Z+, tosl
    st Z+, tosh
    loadtos
    jmp_ DO_NEXT

; ( -- n2 )
; Extended VM
; Write memory pointed to by register B, increment B by 1 cell (Extended VM)
VE_BSTOREPLUS:
    .dw $ff03
    .db  "b!+",0
    .dw VE_HEAD
    .set VE_HEAD = VE_BSTOREPLUS
XT_BSTOREPLUS:
    .dw PFA_BSTOREPLUS
PFA_BSTOREPLUS:
    movw zl, bl
    st Z+, tosl
    st Z+, tosh
    loadtos
    movw bl, zl
    jmp_ DO_NEXT

; ( -- n2 )
; Extended VM
; Write memory pointed to by register B, decrement B by 1 cell (Extended VM)
VE_BSTOREMINUS:
    .dw $ff03
    .db "b!-",0
    .dw VE_HEAD
    .set VE_HEAD = VE_BSTOREMINUS
XT_BSTOREMINUS:
    .dw PFA_BSTOREMINUS
PFA_BSTOREMINUS:
    movw zl, bl
    st -Z, tosh
    st -Z, tosl
    loadtos
    movw bl, zl
    jmp_ DO_NEXT



; ( n -- )
; Extended VM
; Write to B register (Extended VM)
VE_TO_B:
    .dw $ff02
    .db ">b"
    .dw VE_HEAD
    .set VE_HEAD = VE_TO_B
XT_TO_B:
    .dw PFA_TO_B
PFA_TO_B:
    movw bl, tosl
    loadtos
    jmp_ DO_NEXT

; ( n1 -- n2 )
; Extended VM
; read the B register (Extended VM)
VE_B_FROM:
    .dw $ff02
    .db "b>"
    .dw VE_HEAD
    .set VE_HEAD = VE_B_FROM
XT_B_FROM:
    .dw PFA_B_FROM
PFA_B_FROM:
    savetos
    movw tosl, bl
    jmp_ DO_NEXT

; for more information read
; http://www.complang.tuwien.ac.at/anton/euroforth/ef08/papers/pelc.pdf
;  adapted index based access from X/Y registers
;    note: offset is byte address, not cell!