summaryrefslogtreecommitdiff
path: root/tests/micropython/viper_ptr16_load.py
blob: 06ce7db159dbbc9c460a8f86810217d6cb8ecf77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# test loading from ptr16 type
# only works on little endian machines

@micropython.viper
def get(src:ptr16) -> int:
    return src[0]

@micropython.viper
def memadd(src:ptr16, n:int) -> int:
    sum = 0
    for i in range(n):
        sum += src[i]
    return sum

b = bytearray(b'1234')
print(b)
print(get(b))
print(memadd(b, 2))