-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing
Shift
instructions (#41)
* Init shift opcodes * Test shl * Test shr * Rename file name declaration * Test shl using stack * Test shr using stack * Test shl and shr with eq flag * Format zasm * Fix rol and test it * Fix ror and test it * Test rol and ror with stack * Test rol and ror with conditional flag * Add eq flag testing * Format zasm * Use TaggedValue * Remove unnecessary register setup * Fix stack usage * Use unreacheable * Remove redundant cast * Relocate shift match * Remove 4 bytes redundancy * Test shift for number greater than 256 * Add more test for values greater than 256
- Loading branch information
Showing
24 changed files
with
552 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.text | ||
.file "rol.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 1, r0, r1 | ||
add 4, r0, r2 | ||
rol r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "rol_conditional_eq.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 1, r0, r1 | ||
add 4, r0, r2 | ||
rol.eq r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,12 @@ | ||
.text | ||
.file "rol_greater_than_256.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; test sets r1 = 1, r2 = 258 | ||
rol r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,16 @@ | ||
.text | ||
.file "rol_sets_eq_flag.zasm" | ||
.globl __entry | ||
__entry: | ||
|
||
.func_begin0: | ||
; EQ is set if the result is zero | ||
add 0, r0, r1 | ||
add 0, r0, r2 | ||
rol! r1, r2, r1 | ||
sstore r0, r1 | ||
ret | ||
|
||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,17 @@ | ||
.text | ||
.file "rol_stack.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; grow stack | ||
add 1, r0, stack+=[2] | ||
; set stack value | ||
add 1, r0, stack[0] | ||
add 4, r0, r2 | ||
; left rotation | ||
rol stack[0], r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "ror.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 16, r0, r1 | ||
add 4, r0, r2 | ||
ror r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "ror_conditional_eq.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 16, r0, r1 | ||
add 4, r0, r2 | ||
ror.eq r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,12 @@ | ||
.text | ||
.file "ror_greater_than_256.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; test sets r1 = 16, r2 = 258 | ||
ror r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,16 @@ | ||
.text | ||
.file "ror_sets_eq_flag.zasm" | ||
.globl __entry | ||
__entry: | ||
|
||
.func_begin0: | ||
; EQ is set if the result is zero | ||
add 0, r0, r1 | ||
add 0, r0, r2 | ||
ror! r1, r2, r1 | ||
sstore r0, r1 | ||
ret | ||
|
||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,17 @@ | ||
.text | ||
.file "ror_stack.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; grow stack | ||
add 1, r0, stack+=[2] | ||
; set stack value | ||
add 16, r0, stack[0] | ||
add 4, r0, r2 | ||
; right rotation | ||
ror stack[0], r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "shl.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 1, r0, r1 | ||
add 2, r0, r2 | ||
shl r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "shl_conditional_eq.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 4, r0, r1 | ||
add 1, r0, r2 | ||
shl.eq r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,12 @@ | ||
.text | ||
.file "shl_greater_than_256.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; test sets r1 = 1, r2 = 258 | ||
shl r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,16 @@ | ||
.text | ||
.file "shl_sets_eq_flag.zasm" | ||
.globl __entry | ||
__entry: | ||
|
||
.func_begin0: | ||
; EQ is set if the result is zero | ||
add 0, r0, r1 | ||
add 0, r0, r2 | ||
shl! r1, r2, r1 | ||
sstore r0, r1 | ||
ret | ||
|
||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,17 @@ | ||
.text | ||
.file "shl_stack.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; grow stack | ||
add 1, r0, stack+=[2] | ||
; set stack value | ||
add 4, r0, stack[0] | ||
add 2, r0, r2 | ||
; shift left | ||
shl stack[0], r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "shr.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 8, r0, r1 | ||
add 2, r0, r2 | ||
shr r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,13 @@ | ||
.text | ||
.file "shr_conditional_eq.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
add 8, r0, r1 | ||
add 2, r0, r2 | ||
shr.eq r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,12 @@ | ||
.text | ||
.file "shr_greater_than_256.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; test sets r1 = 16, r2 = 258 | ||
shr r1, r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,16 @@ | ||
.text | ||
.file "shr_sets_eq_flag.zasm" | ||
.globl __entry | ||
__entry: | ||
|
||
.func_begin0: | ||
; EQ is set if the result is zero | ||
add 0, r0, r1 | ||
add 0, r0, r2 | ||
shr! r1, r2, r1 | ||
sstore r0, r1 | ||
ret | ||
|
||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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,17 @@ | ||
.text | ||
.file "shr_stack.zasm" | ||
.globl __entry | ||
__entry: | ||
.func_begin0: | ||
; grow stack | ||
add 1, r0, stack+=[2] | ||
; set stack value | ||
add 4, r0, stack[0] | ||
add 2, r0, r2 | ||
; shift right | ||
shr stack[0], r2, r3 | ||
sstore r0, r3 | ||
ret | ||
.func_end0: | ||
.note.GNU-stack | ||
.rodata |
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
Oops, something went wrong.