mirror of
https://github.com/openharmony/ark_runtime_core.git
synced 2026-07-19 13:17:49 -04:00
1aa56bf224
Signed-off-by: Ilya Trubachev <trubachev.ilya@huawei.com>
38 lines
998 B
Plaintext
38 lines
998 B
Plaintext
# Copyright (c) 2021-2022 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.
|
|
|
|
.function i32 factorial (i32 a0) <> { #Calculation of factorial from a value in register a0
|
|
ldai.64 1
|
|
sta.64 v8
|
|
while_1:
|
|
lda.64 a0
|
|
movi.64 v0, 1
|
|
jle v0, endwhile_3
|
|
body_2:
|
|
mul v8, a0
|
|
sta.64 v8
|
|
lda.64 a0
|
|
subi 1
|
|
sta.64 a0
|
|
jmp while_1
|
|
endwhile_3:
|
|
lda.64 v8
|
|
return
|
|
}
|
|
|
|
.function i32 entry () <> {
|
|
movi.64 v0, 7
|
|
call.short factorial, v0
|
|
return
|
|
}
|