# Copyright (c) 2021-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # a & ~b .function i32 andv_not_i32(i32 a0, i32 a1) { lda a1 not and2v v0, a0 lda v0 return } # a & ~b .function i64 andv_not_i64(i64 a0, i64 a1) { lda.64 a1 not.64 and2v.64 v0, a0 lda.64 v0 return.64 } # a | ~b .function i32 orv_not_i32(i32 a0, i32 a1) { lda a1 not or2v v0, a0 lda v0 return } # a | ~b .function i64 orv_not_i64(i64 a0, i64 a1) { lda.64 a1 not.64 or2v.64 v0, a0 lda.64 v0 return.64 } # a ^ ~b .function i32 xorv_not_i32(i32 a0, i32 a1) { lda a1 not xor2v v0, a0 lda v0 return } # a ^ ~b .function i64 xorv_not_i64(i64 a0, i64 a1) { lda.64 a1 not.64 xor2v.64 v0, a0 lda.64 v0 return.64 } .record IO .function void IO.printI64(i64 a0) .function i32 main() { movi v0, 0x0000ffff movi v1, 0x0 call.short orv_not_i32, v0, v1 movi v0, 0xffffffff jne v0, exit_error_0 movi.64 v0, 0x0000ffff0000ffff movi.64 v1, 0x00ffffffff000000 call.short orv_not_i64, v0, v1 movi.64 v0, 0xff00ffff00ffffff cmp.64 v0 jnez exit_error_1 movi v0, 0x0f0f0f0f movi v1, 0 call.short andv_not_i32, v0, v1 movi v0, 0x0f0f0f0f jne v0, exit_error_2 movi.64 v0, 0x00ff00ff00ff00ff movi.64 v1, 0xff0ffff0ff0ffff0 call.short andv_not_i64, v0, v1 movi.64 v0, 0x00f0000f00f0000f cmp.64 v0 jnez exit_error_3 movi v0, 0x01234567 movi v1, 0x76543210 call.short xorv_not_i32, v0, v1 movi v0, 0x88888888 jne v0, exit_error_4 movi.64 v0, 0x0123456789abcdef movi.64 v1, 0xfedcba9876543210 call.short xorv_not_i64, v0, v1 movi.64 v0, 0 cmp.64 v0 jnez exit_error_5 ldai 0 return exit_error_0: ldai 1 return exit_error_1: ldai 2 return exit_error_2: ldai 3 return exit_error_3: ldai 4 return exit_error_4: ldai 5 return exit_error_5: ldai 6 return }