forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py: Implement ptr32 load and store in viper emitter.
- Loading branch information
Showing
8 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,7 @@ Q(uint) | |
Q(ptr) | ||
Q(ptr8) | ||
Q(ptr16) | ||
Q(ptr32) | ||
#endif | ||
|
||
#if MICROPY_EMIT_INLINE_THUMB | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# test loading from ptr32 type | ||
|
||
@micropython.viper | ||
def get(src:ptr32) -> int: | ||
return src[0] | ||
|
||
@micropython.viper | ||
def get1(src:ptr32) -> int: | ||
return src[1] | ||
|
||
@micropython.viper | ||
def memadd(src:ptr32, n:int) -> int: | ||
sum = 0 | ||
for i in range(n): | ||
sum += src[i] | ||
return sum | ||
|
||
b = bytearray(b'\x12\x12\x12\x12\x34\x34\x34\x34') | ||
print(b) | ||
print(hex(get(b)), hex(get1(b))) | ||
print(hex(memadd(b, 2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bytearray(b'\x12\x12\x12\x124444') | ||
0x12121212 0x34343434 | ||
0x46464646 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# test store to ptr32 type | ||
|
||
@micropython.viper | ||
def set(dest:ptr32, val:int): | ||
dest[0] = val | ||
|
||
@micropython.viper | ||
def set1(dest:ptr32, val:int): | ||
dest[1] = val | ||
|
||
@micropython.viper | ||
def memset(dest:ptr32, val:int, n:int): | ||
for i in range(n): | ||
dest[i] = val | ||
|
||
b = bytearray(8) | ||
print(b) | ||
|
||
set(b, 0x42424242) | ||
print(b) | ||
|
||
set1(b, 0x43434343) | ||
print(b) | ||
|
||
memset(b, 0x44444444, len(b) // 4) | ||
print(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') | ||
bytearray(b'BBBB\x00\x00\x00\x00') | ||
bytearray(b'BBBBCCCC') | ||
bytearray(b'DDDDDDDD') |