# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. .function i64 main(){ movi v1, 10 newarr v0, v1, i64[] ldai 0 main_loop: jge v1, main_ret sta v2 call.short fibonacci, v2, v2 starr.64 v0, v2 lda v2 addi 1 jmp main_loop main_ret: lda v1 subi 1 ldarr.64 v0 return.64 } .function i64 fibonacci(i64 a0){ lda a0 jnez non_zero return.64 non_zero: ldai 1 jne a0, non_one return.64 non_one: lda a0 subi 1 sta a0 subi 1 sta v1 call.short fibonacci, a0, a0 sta a0 call.short fibonacci, v1, a0 add2.64 a0 return.64 }