diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-06-23 15:14:16 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-06-23 15:14:16 -0400 |
commit | 52391afe486821e97ec50b3a3db076aa0e94c3c6 (patch) | |
tree | ecb7fac66044d4f8577f6b0f749fbbedc47f33db | |
parent | 7a97d930936527865cd215f1df5f931e26530d96 (diff) | |
download | minos-52391afe486821e97ec50b3a3db076aa0e94c3c6.tar.gz |
Fix up strtok
-rw-r--r-- | string.asm | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -164,21 +164,23 @@ strncmp: ret strtok: + %define .token_count [bp - 2] push bp mov bp, sp + sub sp, 2 ; use: .token_count + push bx ; save GPRs - push cx push dx push di push si - xor ax, ax ; use: for delimter (LSB) - xor bx, bx ; use: base address for effective address calculations + xor ax, ax ; use: hold delimiter (LSB of AX) + xor bx, bx ; use: effective address calculations xor cx, cx ; use: input string length counter xor dx, dx ; use: temp for string comparison - xor si, si ; use: token array - xor di, di ; use: input string + xor si, si ; use: token array address + xor di, di ; use: input string address mov di, [bp + 4] ; arg1 - input string (null terminated) mov si, [bp + 6] ; arg2 - address of token array @@ -213,6 +215,7 @@ strtok: ; points to our new token address .strtok_record_no_adjust: + inc word .token_count mov [si], bx ; store address in results array add si, 2 ; increment results array by one WORD inc di ; increment input string @@ -236,13 +239,14 @@ strtok: .strtok_return: mov ax, [bp + 6] ; return token array + mov cx, .token_count ; return token count pop si ; restore GPRs pop di pop dx - pop cx pop bx + add sp, 2 mov sp, bp pop bp ret |