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 Convert <external> 16.function i64 Convert.stringToI64(panda.String a0) <external> 17 18.function i32 main(){ 19 # Convert.stringToI64("-1") == -1 20 lda.str "-1" 21 sta.obj v0 22 call Convert.stringToI64, v0 23 movi.64 v1, -1 24 cmp.64 v1 25 jnez exit_failure 26 27 # Convert.stringToI64("1") == 1 28 lda.str "1" 29 sta.obj v0 30 call Convert.stringToI64, v0 31 movi.64 v1, 1 32 cmp.64 v1 33 jnez exit_failure 34 35 # Convert.stringToI64("-9223372036854775808") == -9223372036854775808 36 lda.str "-9223372036854775808" 37 sta.obj v0 38 call Convert.stringToI64, v0 39 movi.64 v1, -9223372036854775808 40 cmp.64 v1 41 jnez exit_failure 42 43 # Convert.stringToI64("9223372036854775807") == 9223372036854775807 44 lda.str "9223372036854775807" 45 sta.obj v0 46 call Convert.stringToI64, v0 47 movi.64 v1, 9223372036854775807 48 cmp.64 v1 49 jnez exit_failure 50 51 ldai 0 52 return 53 54exit_failure: 55 ldai 1 56 return 57} 58