summaryrefslogtreecommitdiff
path: root/tests/micropython/viper_ptr8_store.py
blob: fc24290c99d96c1e79119302f6e0f4bf3e5675ba (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
# test ptr8 type

@micropython.viper
def set(dest:ptr8, val:int):
    dest[0] = val

@micropython.viper
def memset(dest:ptr8, val:int, n:int):
    for i in range(n):
        dest[i] = val

@micropython.viper
def memset2(dest_in, val:int):
    dest = ptr8(dest_in)
    n = int(len(dest_in))
    for i in range(n):
        dest[i] = val

b = bytearray(4)
print(b)

set(b, 42)
print(b)

memset(b, 43, len(b))
print(b)

memset2(b, 44)
print(b)