# Copyright (c) 2021-2022 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. # a * b + c .function i32 madd_i32(i32 a0, i32 a1, i32 a2) { mov v0, a0 mov v1, a1 mul a0, a1 sta v0 add v0, a2 return } # a * b + c .function i64 madd_i64(i64 a0, i64 a1, i64 a2) { lda.64 a1 mul2.64 a0 add2.64 a2 return.64 } .function i32 main() { movi v0, 10 movi v1, 1000 movi v2, -56 call madd_i32, v0, v1, v2 sta v0 ldai 9944 jne v0, exit_error_0 movi.64 v0, -1 movi.64 v1, 123 movi.64 v2, 19 call madd_i64, v0, v1, v2 sta.64 v0 ldai.64 -104 cmp.64 v0 jnez exit_error_1 ldai 0 return exit_error_0: ldai 1 return exit_error_1: ldai 2 return }