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

35 lines
589 B
Plaintext
Raw Normal View History

2019-05-30 18:31:50 +02:00
; 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
2019-05-30 20:23:27 +02:00
cretz
2019-05-30 18:31:50 +02:00
2019-05-30 18:36:06 +02:00
; save str's location
2019-05-30 19:33:22 +02:00
mov rdx, ax1
2019-05-30 18:36:06 +02:00
2019-05-30 19:07:04 +02:00
; go to str's end, just before
; the null terminator
2019-05-30 18:31:50 +02:00
.1:
test b[ax1+1], b[ax1+1]
2019-05-30 20:23:27 +02:00
cincnz ax1
cjmpnz .1
2019-05-30 18:31:50 +02:00
2019-05-30 20:23:27 +02:00
.2:
2019-05-30 19:07:04 +02:00
; copy, going backward though str
2019-05-30 19:33:22 +02:00
; and forward through buf
2019-05-30 18:31:50 +02:00
mov b[ax0], b[ax1]
2019-05-30 18:36:06 +02:00
cmp ax1, rdx
2019-05-30 20:23:27 +02:00
cmovz b[ax0+1], 0
cretz
2019-05-30 18:31:50 +02:00
inc ax0
dec ax1
jmp .2