1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14# a0 * 0 + a1 15.function i64 mza(i64 a0, i64 a1) <static> { 16 movi.64 v0, 0 17 lda.64 a0 18 mul2.64 v0 19 add2.64 a1 20 return.64 21} 22 23# a0 * a1 + 0 24.function i64 maz(i64 a0, i64 a1) <static> { 25 movi.64 v0, 0 26 lda.64 a0 27 mul2.64 a1 28 add2.64 v0 29 return.64 30} 31 32# a0 - a1 * 0 33.function i64 mzs(i64 a0, i64 a1) <static> { 34 movi.64 v0, 0 35 lda.64 a1 36 mul2.64 v0 37 sta.64 v0 38 lda.64 a0 39 sub2.64 v0 40 return.64 41} 42 43# 0 - a0 * a1 44.function i64 msz(i64 a0, i64 a1) <static> { 45 movi.64 v0, 0 46 lda.64 a0 47 mul2.64 a1 48 sta.64 v1 49 lda.64 v0 50 sub2.64 v1 51 return.64 52} 53 54.function i32 main() <static> { 55 movi.64 v0, 21 56 movi.64 v1, 17 57 call.short mza, v0, v1 58 sta.64 v2 59 call.short maz, v0, v1 60 sta.64 v3 61 call.short mzs, v0, v1 62 sta.64 v4 63 call.short msz, v0, v1 64 add2.64 v2 65 add2.64 v3 66 add2.64 v4 67 # (a * 0 + b) + (a * b + 0) + (a - b * 0) + (0 - a * b) => a + b 68 movi.64 v0, 38 69 cmp.64 v0 70 jnez error 71 ldai 0 72 return 73error: 74 ldai 1 75 return 76}