forked from schreibfaul1/ESP32-audioI2S
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstack.s
67 lines (54 loc) · 1.27 KB
/
stack.s
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
/* ULP Example: Read temperautre in deep sleep
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
This file contains assembly code which runs on the ULP.
*/
/* ULP assembly files are passed through C preprocessor first, so include directives
and C macros may be used in these files
*/
.macro push rx
st \rx,r3,0
sub r3,r3,1
.endm
.macro pop rx
add r3,r3,1
ld \rx,r3,0
.endm
// Subroutine jump
.macro call target
.set addr,(.+16)
move r0,addr
push r0
jump \target
.endm
// Return from subroutine
.macro ret
pop r0
jump r0
.endm
// Assign value to variable
.macro assign variable, value
move r1, \value
move r0, \variable
st r1, r0, 0
.endm
// Fetch variable directly into register rx
.macro fetch rx, variable
move r0, \variable
ld \rx, r0, 0
.endm
// Fetch variable[ry] directly into register rx,
.macro fetch_array rx, variable, ry
move r0, \variable
add r0, r0, \ry
ld \rx, r0, 0
.endm
// Increment variable
.macro increment variable amount
move r0, \variable
ld r1, r0, 0
add r1, r1, \amount
st r1, r0, 0
.endm