circuitpython/tests/micropython/viper_ptr8_store.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
543 B
Python
Raw Permalink Normal View History

# test ptr8 type
2021-03-15 09:57:36 -04:00
@micropython.viper
2021-03-15 09:57:36 -04:00
def set(dest: ptr8, val: int):
dest[0] = val
2021-03-15 09:57:36 -04:00
@micropython.viper
2021-03-15 09:57:36 -04:00
def set1(dest: ptr8, val: int):
dest[1] = val
2021-03-15 09:57:36 -04:00
@micropython.viper
2021-03-15 09:57:36 -04:00
def memset(dest: ptr8, val: int, n: int):
for i in range(n):
dest[i] = val
2021-03-15 09:57:36 -04:00
@micropython.viper
2021-03-15 09:57:36 -04:00
def memset2(dest_in, val: int):
dest = ptr8(dest_in)
n = int(len(dest_in))
for i in range(n):
dest[i] = val
2021-03-15 09:57:36 -04:00
b = bytearray(4)
print(b)
set(b, 41)
print(b)
set1(b, 42)
print(b)
memset(b, 43, len(b))
print(b)
memset2(b, 44)
print(b)