1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/ka/str/strrev.k
2019-06-05 12:53:09 +02:00

35 lines
589 B
Plaintext

; The OS/K Team licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
;
; void strrev(char *buf, const char *str)
;
strrev:
test b[ax1], b[ax1]
cmovz b[ax0], 0
cretz
; save str's location
mov rdx, ax1
; go to str's end, just before
; the null terminator
.1:
test b[ax1+1], b[ax1+1]
cincnz ax1
cjmpnz .1
.2:
; copy, going backward though str
; and forward through buf
mov b[ax0], b[ax1]
cmp ax1, rdx
cmovz b[ax0+1], 0
cretz
inc ax0
dec ax1
jmp .2