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