2015-10-12 19:50:17 -04:00
|
|
|
# test store to ptr32 type
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-10-12 19:50:17 -04:00
|
|
|
@micropython.viper
|
2021-03-15 09:57:36 -04:00
|
|
|
def set(dest: ptr32, val: int):
|
2015-10-12 19:50:17 -04:00
|
|
|
dest[0] = val
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-10-12 19:50:17 -04:00
|
|
|
@micropython.viper
|
2021-03-15 09:57:36 -04:00
|
|
|
def set1(dest: ptr32, val: int):
|
2015-10-12 19:50:17 -04:00
|
|
|
dest[1] = val
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-10-12 19:50:17 -04:00
|
|
|
@micropython.viper
|
2021-03-15 09:57:36 -04:00
|
|
|
def memset(dest: ptr32, val: int, n: int):
|
2015-10-12 19:50:17 -04:00
|
|
|
for i in range(n):
|
|
|
|
dest[i] = val
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-10-13 13:24:36 -04:00
|
|
|
@micropython.viper
|
2021-03-15 09:57:36 -04:00
|
|
|
def memset2(dest_in, val: int):
|
2015-10-13 13:24:36 -04:00
|
|
|
dest = ptr32(dest_in)
|
|
|
|
n = int(len(dest_in)) >> 2
|
|
|
|
for i in range(n):
|
|
|
|
dest[i] = val
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-10-12 19:50:17 -04:00
|
|
|
b = bytearray(8)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
set(b, 0x42424242)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
set1(b, 0x43434343)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
memset(b, 0x44444444, len(b) // 4)
|
|
|
|
print(b)
|
2015-10-13 13:24:36 -04:00
|
|
|
|
|
|
|
memset2(b, 0x45454545)
|
|
|
|
print(b)
|