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.record panda.String <external> 15.record IO <external> 16.function void IO.printString(panda.String a0) <external> 17.function void IO.printI64(i64 a0) <external> 18 19# a0 - index in parameter list 20.function i64 get(i64 a0, i64 a1, i64 a2, i64 a3) { 21 lda.str "\n" 22 sta.obj v0 23 call.short IO.printString, v0, v0 24 call.short IO.printI64, a0, a0 25 call.short IO.printString, v0, v0 26 call.short IO.printI64, a1, a1 27 call.short IO.printString, v0, v0 28 call.short IO.printI64, a2, a2 29 call.short IO.printString, v0, v0 30 call.short IO.printI64, a3, a3 31 call.short IO.printString, v0, v0 32 33 lda.64 a0 34 jeqz zero 35 36 subi 1 37 jeqz first 38 39 lda.64 a3 40 return 41 42 43first: 44 lda.64 a2 45 return 46 47zero: 48 lda.64 a1 49 return 50} 51 52 53.function i32 main() { 54 movi.64 v0, 0 55 56 # 0x 3aaa aaaa aaaa aaa3 57 movi.64 v1, 4227378850225105571 58 # 0x 7333 3333 3333 3337 59 movi.64 v2, 8301034833169298231 60 # 0x 1fff ffff ffff fff1 61 movi.64 v3, 2305843009213693937 62 63 call get, v0, v1, v2, v3 64 sub2.64 v1 65 jnez print_fail_1 66 67 movi.64 v0, 1 68 call get, v0, v1, v2, v3 69 sub2.64 v2 70 jnez print_fail_2 71 72 movi.64 v0, 2 73 call get, v0, v1, v2, v3 74 75 sub2.64 v3 76 jnez print_fail_3 77 return 78 79print_fail_1: 80 sta.64 v1 81 lda.str "1-st paramer fail!" 82 sta.obj v0 83 call.short IO.printString, v0, v0 84 lda.64 v1 85 return.64 86 87print_fail_2: 88 sta.64 v1 89 lda.str "2-d paramer fail!" 90 sta.obj v0 91 call.short IO.printString, v0, v0 92 lda.64 v1 93 return.64 94 95print_fail_3: 96 sta.64 v1 97 lda.str "3-d paramer fail!" 98 sta.obj v0 99 call.short IO.printString, v0, v0 100 lda.64 v1 101 return.64 102} 103