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