-
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.
Added support for p-registers to allow register access in calling fun…
…ction's stack
- Loading branch information
1 parent
3ea9a2e
commit 8a508b2
Showing
6 changed files
with
63 additions
and
9 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
29 changes: 29 additions & 0 deletions
29
src/test/resources/myworld/hummingbird/test/programs/fibonacci30Call0.hasm
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,29 @@ | ||
.symbols | ||
fibonacci function $fibonacci | ||
long | ||
parameters 3 | ||
registers 7 | ||
|
||
.code | ||
# fib(30) | ||
CONST r1, 30 | ||
CALL0 r2, $fibonacci#, r1, 1 | ||
RETURN r2 | ||
fibonacci: # int fibonacci(n) | ||
CONST r2, 2 | ||
IFGE p0, r2, $recurse | ||
RETURN p0 | ||
recurse: | ||
#fib(n - 1) | ||
CONST r1, 1 | ||
SUB r3, p0, r1 # r0 = n - 1 | ||
#COPY r3, r0 | ||
CALL0 r4, $fibonacci #, r0, 1 | ||
|
||
#fib(n - 2) | ||
SUB r5, r3, r1 # r0 = n - 2 | ||
#COPY r5, r0 | ||
CALL0 r6, $fibonacci #, r0, 1 | ||
|
||
ADD r0, r4, r6 | ||
RETURN r0 |
14 changes: 14 additions & 0 deletions
14
src/test/resources/myworld/hummingbird/test/programs/recursiveAdd.hasm
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,14 @@ | ||
.code | ||
CONST r0, 1 | ||
CONST r1, 10 | ||
CALL0 r2, $add | ||
RETURN r2 | ||
add: | ||
IFEQ p0, p1, $done | ||
CONST r1, 1 | ||
ADD r0, p1, r1 | ||
COPY r1, p0 | ||
CALL0 r2, $add | ||
RETURN r2 | ||
done: | ||
RETURN p1 |