X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=wordlists.asm;h=7daa4289c964b501314d40dbb21f4609d92fc480;hb=f2b2acd5d5c79e2d65854eef7e23f7323bc6c4f2;hp=44656e85fb81a22003e175b0019875cedd971cbc;hpb=76f3fb73eedebb34c932d40f61b7578d9f5177c9;p=rrq%2Frrqforth.git diff --git a/wordlists.asm b/wordlists.asm index 44656e8..7daa428 100644 --- a/wordlists.asm +++ b/wordlists.asm @@ -38,27 +38,67 @@ p_words_END: popr rsi next + WORD p_strlen,'STRLEN',fasm + ;; ( chars -- n ) + ;; Determine length of NUL terminated byte sequence + pushr rsi + mov rsi,qword [rsp] + xor rcx,rcx + dec rcx + cld +p_strlen_LOOP: + inc rcx + lodsb + cmp al,0 + jne p_strlen_LOOP + mov qword [rsp],rcx + popr rsi + next + + WORD p_strncpy,'STRNCPY',fasm + ;; ( chars1 chars2 n -- ) + ;; Copy n bytes from chars1 to chars2. + pushr rsi + pop rcx + pop rdi + pop rsi + cmp rcx,0 + jle p_strncpy_END + cld +p_strncpy_LOOP: + movsb + dec rcx + jg p_strncpy_LOOP +p_strncpy_END: + popr rsi + next + WORD p_strncmp,'STRNCMP',fasm ;; ( chars1 chars2 n -- flag ) ;; Compare bytes until one is NUL, return <0, =0 or >0 to ;; indicate that chars1 is lesser, they are equal, or chars2 ;; is lesser in ascii ordering respectively. - pop rdx ; count - pop rbx ; chars2 - pop rax ; chars1 - xor rcx,rcx + pushr rsi + pop rcx ; count + pop rsi ; chars2 + pop rdi ; chars1 + xor rax,rax + cmp rcx,0 + jle p_strncmp_end ;; rax = chars1, rbx = chars2, cl = byte acc, rdx = length + cld p_strncmp_loop: - dec rdx - jl p_strncmp_end - mov cl,[rax] - inc rax - inc rbx - sub cl,[rbx-1] - je p_strncmp_loop - jmp p_strncmp_end + cmpsb + jne p_strncmp_diff + dec rcx + jg p_strncmp_loop +p_strncmp_diff: + xor rax,rax + mov al,[rsi-1] + sub al,[rdi-1] p_strncmp_end: - push rcx + push rax + popr rsi next WORD p_find,'FIND',fasm