; 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) ; ; buf and src must NOT overlap ; strrev: bzr b[ax1], .z ; save str's location mov rsi, ax1 ; go to str's end, just before ; the null terminator mov rcx, STRLEN_MAX scasb.rep.nz ax1, zero dec ax1, 1 .l: ; copy, going backward though str ; and forward through buf mov b[ax0], b[ax1] beq ax1, rsi, .r inc ax0, 1 dec ax1, 1 jmp .l .r: mov b[ax0+1], zero ret .z: mov b[ax0], zero ret ; ; void strrev2(char *str) ; ; Inverses str ; strrev2: bzr b[ax0], .r mov ax1, ax0 ; go to str's end, just before ; the null terminator mov rcx, STRLEN_MAX scasb.rep.nz ax1, zero dec ax1, 1 ; increase ax0 while decreasing ax1, performing exchanges .l: blteu ax1, ax0, .r xchg b[ax0], b[ax1] inc ax0, 1 dec ax1, 1 jmp .l .r: ret