forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from near/zkasm_fibo
Implement Fibonacci in ZK ASM
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
cranelift/zkasm_data/benchmarks/fibonacci/generated/handwritten.zkasm
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,28 @@ | ||
start: | ||
10000 => A | ||
:CALL(fib) | ||
fibEnd: | ||
15574651946073070043n :ASSERT | ||
finalizeExecution: | ||
${beforeLast()} :JMPN(finalizeExecution) | ||
:JMP(start) | ||
|
||
; Computes the fibonacci number for N stored in register A. | ||
; Stores the result in register A. | ||
; Uses registers: C, D. | ||
fib: | ||
A :JMPZ(fibReturn) | ||
; Here A >= 1. | ||
|
||
A => D | ||
0 => A | ||
1 => B | ||
fibLoop: | ||
$ => C :ADD | ||
B => A | ||
C => B | ||
D - 1 => D | ||
D: JMPNZ(fibLoop) | ||
|
||
fibReturn: | ||
:RETURN |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Test,Status,Cycles | ||
from_rust,pass,42024 | ||
handwritten,pass,50008 | ||
handwritten_wat,pass,190024 |
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