File: asmloadstore.py

package info (click to toggle)
micropython 1.26.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 50,196 kB
  • sloc: ansic: 324,551; python: 63,215; xml: 4,241; makefile: 3,618; sh: 1,586; javascript: 754; asm: 723; cpp: 83; exp: 11; pascal: 6
file content (98 lines) | stat: -rw-r--r-- 1,524 bytes parent folder | download
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
import array

# On the 8266 the generated code gets put into the IRAM segment, which is only
# word-addressable.  Therefore, to test byte and halfword load/store opcodes
# some memory must be reserved in the DRAM segment.

BYTE_DATA = array.array("B", (0x11, 0x22, 0x33, 0x44))
WORD_DATA = array.array("h", (100, 200, -100, -200))
DWORD_DATA = array.array("i", (100_000, -200_000, 300_000, -400_000))


@micropython.asm_xtensa
def tl32r() -> int:
    nop()
    j(CODE)
    align(4)
    label(DATA)
    data(1, 1, 2, 3, 4, 5, 6, 7)
    align(4)
    label(CODE)
    nop_n()
    nop_n()
    l32r(a2, DATA)


print(hex(tl32r()))


@micropython.asm_xtensa
def tl32i() -> uint:
    call0(ENTRY)
    label(ENTRY)
    l32i(a2, a0, 0)


print(hex(tl32i()))


@micropython.asm_xtensa
def tl8ui(a2) -> uint:
    mov(a3, a2)
    l8ui(a2, a3, 1)


print(hex(tl8ui(BYTE_DATA)))


@micropython.asm_xtensa
def tl16ui(a2) -> uint:
    mov(a3, a2)
    l16ui(a2, a3, 2)


print(tl16ui(WORD_DATA))


@micropython.asm_xtensa
def tl16si(a2) -> int:
    mov(a3, a2)
    l16si(a2, a3, 6)


print(tl16si(WORD_DATA))


@micropython.asm_xtensa
def ts8i(a2, a3):
    s8i(a3, a2, 1)


ts8i(BYTE_DATA, 0xFF)
print(BYTE_DATA)


@micropython.asm_xtensa
def ts16i(a2, a3):
    s16i(a3, a2, 2)


ts16i(WORD_DATA, -123)
print(WORD_DATA)


@micropython.asm_xtensa
def ts32i(a2, a3) -> uint:
    s32i(a3, a2, 4)


ts32i(DWORD_DATA, -123456)
print(DWORD_DATA)


@micropython.asm_xtensa
def tl32i_n(a2) -> uint:
    l32i_n(a2, a2, 8)


print(tl32i_n(DWORD_DATA))