From: Jonas Hvid Date: Tue, 10 Dec 2019 14:36:11 +0000 (+0100) Subject: Fix bug in interface of parse_number X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=4d233157714c21c1c15e7b271460a1692da55f52;p=rrq%2Fjonasforth.git Fix bug in interface of parse_number This procedure did not actually do what it claimed to be doing. It just happened to work with the way it was called. --- diff --git a/impl.asm b/impl.asm index 923406f..bb796ab 100644 --- a/impl.asm +++ b/impl.asm @@ -96,8 +96,8 @@ read_word: ;; Parses a string. ;; ;; Parameters: -;; * [.length] = Length of string -;; * [.buffer] = Pointer to string buffer +;; * rcx = Length of string +;; * rdi = Pointer to string buffer ;; ;; Results: ;; * rax = Value @@ -108,7 +108,7 @@ parse_number: ;; Add (10^(rcx-1) * parse_char(rdi[length - rcx])) to the accumulated value ;; for each rcx. - mov rcx, [.length] + mov [.length], rcx .loop: ;; First, calcuate 10^(rcx - 1) mov rax, 1 @@ -155,6 +155,5 @@ read_word.buffer rb read_word.max_size read_word.length db ? read_word.char_buffer db ? -parse_number.buffer dq ? parse_number.length dq ? diff --git a/main.asm b/main.asm index d2cd54d..e6b0ac2 100644 --- a/main.asm +++ b/main.asm @@ -198,8 +198,8 @@ forth_asm READ_WORD, 'READ-WORD' ;; Takes a string on the stack and replaces it with the decimal number that the ;; string represents. forth_asm PARSE_NUMBER, 'PARSE-NUMBER' - pop [parse_number.length] ; Length - pop [parse_number.buffer] ; String pointer + pop rcx ; Length + pop rdi ; String pointer push rsi call parse_number