-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:UnsignedByte/bril
- Loading branch information
Showing
28 changed files
with
233 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# ARGS: 12 6 | ||
|
||
@lsb (val : int) : int { | ||
two : int = const 2; | ||
div : int = div val two; | ||
mul : int = mul div two; | ||
lsb : int = sub val mul; | ||
ret lsb; | ||
} | ||
|
||
@hamm_lsb (a : int, b : int) : int { | ||
zero : int = const 0; | ||
one : int = const 1; | ||
a_lsb : int = call @lsb a; | ||
b_lsb : int = call @lsb b; | ||
xor : int = add a_lsb b_lsb; | ||
guard : bool = eq xor one; | ||
br guard .if .else; | ||
.if: | ||
ret one; | ||
.else: | ||
ret zero; | ||
} | ||
|
||
@main (a : int, b : int) { | ||
zero : int = const 0; | ||
two : int = const 2; | ||
dist : int = const 0; | ||
.while: | ||
a_done : bool = eq a zero; | ||
b_done : bool = eq b zero; | ||
done : bool = and a_done b_done; | ||
br done .end .body; | ||
.body: | ||
hamm : int = call @hamm_lsb a b; | ||
dist : int = add dist hamm; | ||
a : int = div a two; | ||
b : int = div b two; | ||
jmp .while; | ||
.end: | ||
print dist; | ||
ret; | ||
} |
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 @@ | ||
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 @@ | ||
total_dyn_inst: 117 |
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 @@ | ||
# ARGS: 10 | ||
# Compute the char shifted forward by 13 (0-indexed) | ||
@main(input: int) { | ||
aed: int = call @rot input; | ||
print aed; | ||
} | ||
@rot(n: int):int{ | ||
thirteen: int = const 13; | ||
twenty_six: int = const 26; | ||
shifted: int = add n thirteen; | ||
over: bool = ge shifted twenty_six; | ||
br over .if .else; | ||
.if: | ||
shifted: int = sub shifted twenty_six; | ||
.else: | ||
ret shifted; | ||
} |
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 @@ | ||
23 |
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 @@ | ||
total_dyn_inst: 8 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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.