added max and min
[rrq/rrqforth.git] / math.asm
index 3b82bd49ccef3e290bc65a6e324ab17fc576e4a1..6248da98ab9bdf7b872337ac195d33974f6a670e 100644 (file)
--- a/math.asm
+++ b/math.asm
 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.