Skip to content

Commit d82978d

Browse files
committed
qemu-arm: Add tests for freezing viper and asm_thumb code.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 89e6267 commit d82978d

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Test freezing inline-asm code.
2+
3+
import micropython
4+
5+
6+
@micropython.asm_thumb
7+
def asm_add(r0, r1):
8+
add(r0, r0, r1)
9+
10+
11+
@micropython.asm_thumb
12+
def asm_add1(r0) -> object:
13+
lsl(r0, r0, 1)
14+
add(r0, r0, 3)
15+
16+
17+
@micropython.asm_thumb
18+
def asm_cast_bool(r0) -> bool:
19+
pass
20+
21+
22+
@micropython.asm_thumb
23+
def asm_shift_int(r0) -> int:
24+
lsl(r0, r0, 29)
25+
26+
27+
@micropython.asm_thumb
28+
def asm_shift_uint(r0) -> uint:
29+
lsl(r0, r0, 29)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Test freezing viper code.
2+
3+
import micropython
4+
5+
6+
@micropython.viper
7+
def viper_add(x, y):
8+
print(x + y)

tests/qemu-arm/asm_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import frozen_asm
2+
3+
print(frozen_asm.asm_add(1, 2))
4+
print(frozen_asm.asm_add1(3))
5+
print(frozen_asm.asm_cast_bool(0), frozen_asm.asm_cast_bool(3))
6+
print(frozen_asm.asm_shift_int(4))
7+
print(frozen_asm.asm_shift_uint(4))

tests/qemu-arm/asm_test.py.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
3
2+
4
3+
False True
4+
-2147483648
5+
2147483648

tests/qemu-arm/viper_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import frozen_viper
2+
3+
frozen_viper.viper_add(1, 2)

tests/qemu-arm/viper_test.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy