projects
/
rrq
/
rrqforth.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added max and min
[rrq/rrqforth.git]
/
math.asm
diff --git
a/math.asm
b/math.asm
index c678d116d253a36486274e8f8fb4536eae550837..6248da98ab9bdf7b872337ac195d33974f6a670e 100644
(file)
--- a/
math.asm
+++ b/
math.asm
@@
-32,6
+32,26
@@
p_abs_end:
next
p_abs_end:
next
+ WORD p_max, 'MAX',fasm
+ ;; ( a b -- c )
+ ;; c is the least a and b
+ pop rax
+ cmp rax,qword [rsp]
+ jle p_max_end
+ mov qword [rsp],rax
+p_max_end:
+ next
+
+ WORD p_min, 'MIN',fasm
+ ;; ( a b -- c )
+ ;; c is the least a and b
+ pop rax
+ cmp rax,qword [rsp]
+ jge p_min_end
+ mov qword [rsp],rax
+p_min_end:
+ next
+
WORD p_negate, 'NEGATE',fasm
;; ( n1 -- n2 )
;; Negate n1, giving its arithmetic inverse n2.
WORD p_negate, 'NEGATE',fasm
;; ( n1 -- n2 )
;; Negate n1, giving its arithmetic inverse n2.
@@
-42,7
+62,7
@@
p_abs_end:
WORD p_divmod,'/MOD',fasm
;; ( x y -- q r )
WORD p_divmod,'/MOD',fasm
;; ( x y -- q r )
- ;; divide signed x/y giving quotient q and reminder r
+ ;; divide signed x/y giving quotient q and rem
a
inder r
pop rbx
pop rax
xor rdx,rdx
pop rbx
pop rax
xor rdx,rdx
@@
-51,3
+71,13
@@
p_abs_end:
push rdx
next
push rdx
next
+ WORD p_div,'/',fasm
+ ;; ( x y -- q )
+ ;; divide signed x/y giving quotient q and discard remainder
+ pop rbx
+ pop rax
+ xor rdx,rdx
+ idiv rbx
+ push rax
+ next
+