From: Ralph Ronnquist Date: Sat, 22 May 2021 11:35:11 +0000 (+1000) Subject: fix * and amdd /MOD X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=e41af95c9a45e52a18a363d173456870e505db5f;p=rrq%2Frrqforth.git fix * and amdd /MOD --- diff --git a/math.asm b/math.asm index 5547b57..c678d11 100644 --- a/math.asm +++ b/math.asm @@ -16,26 +16,10 @@ WORD p_mult, '*',fasm ;; ( n1 n2 -- n3 ) - ;; Multiply n1 by n2 giving the product n3. - ;; [rsp{8}] * [rsp+8{8}] - ;; dd00 = [rsp+4{4}]*[rsp+12{4}] ignored - ;; needs checking !! - ;; - ;; 0cc0 = [rsp{4}]*[rsp+12{4}] - mov eax, dword [rsp] - imul dword [rsp+12] - mov ebx,eax - ;; 0bb0 = [rsp+4{4}]*[rsp+8{4}] - mov eax, dword [rsp+4] - imul dword [rsp+8] - add ebx, eax - ;; 00aa = [rsp{4}]*[rsp+8{4}] - mov eax, dword [rsp] - imul dword [rsp+8] - add ebx, edx - shl rbx,32 - mov eax,eax ; ensure zero-extending eax - add rax, rbx + ;; multiply n1 * n2 to n3 ignoring overflow + pop rax + pop rbx + imul rax,rbx push rax next @@ -56,4 +40,14 @@ p_abs_end: mov qword [rsp],rax next - + WORD p_divmod,'/MOD',fasm + ;; ( x y -- q r ) + ;; divide signed x/y giving quotient q and reminder r + pop rbx + pop rax + xor rdx,rdx + idiv rbx + push rax + push rdx + next +