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# The following comment until the empty line must be a valid YAML document 15# containing exact copy of ISA specification assertions relevant to this test. 16#--- 17# - title: Store to array 18# description: > 19# Store accumulator content into array slot pointed by index. 20# instructions: 21# - sig: starr vs1, vs2 22# format: [op_vs1_4_vs2_4] 23# type: i32 24# dtype: none 25# etype: i32 26# - title: Load from array 27# description: > 28# Load an element from array using accumulator as an index and puts it into accumulator. 29# instructions: 30# - sig: ldarr vs 31# format: [op_vs_8] 32# type: obj 33# dtype: i32 34# etype: i32 35 36#assert that operations with array of i32 works fine 37#i32 i; 38#for(i=0; i<5; i++) array[i]=i; 39#for(i=4; i>=0; i--) assert_eq(i, array[i]); 40 41.function i32 main(){ 42 movi v0, 5 43 newarr v1, v0, i32[] 44 movi v2, 0 45 ldai 0 46loop: 47 jeq v0, loop_exit 48 starr v1, v2 49 inci v2, 1 50 lda v2 51 jmp loop 52loop_exit: 53 subi 1 54 sta v2 55loop2: 56 jltz loop2_exit 57 ldarr v1 58 jne v2, exit_failure 59 inci v2, -1 60 lda v2 61 jmp loop2 62loop2_exit: 63 ldai 0 64 return 65exit_failure: 66 ldai 1 67 return 68} 69 70