;;; Words doing arithmetics WORD p_plus, '+',fasm ;; ( n1 n2 -- n3 ) ;; n3 is the sum of n1 and n2 pop rax add qword [rsp],rax next WORD p_minus, '-',fasm ;; ( n1 n2 -- n3 ) ;; n3 is the result of subtracting n2 from n1 pop rax sub qword [rsp], rax next 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 push rax next WORD p_abs, 'ABS',fasm ;; ( n -- u ) ;; u is the absolute value of n. cmp qword [rsp],0 jge p_abs_end neg qword [rsp] p_abs_end: next WORD p_negate, 'NEGATE',fasm ;; ( n1 -- n2 ) ;; Negate n1, giving its arithmetic inverse n2. xor rax,rax sub rax,qword [rsp] mov qword [rsp],rax next