X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=logic.asm;h=56dd2db88254b8fbf190d3a69ddab35d64d8df28;hb=582c524700342bcdf126d814c380aaba9d0a651b;hp=a3b183dc097d4edffd9d25233cff77310e4a6245;hpb=02ef6e814ef0e6c61348c70bd310ba1f0df2506b;p=rrq%2Frrqforth.git diff --git a/logic.asm b/logic.asm index a3b183d..56dd2db 100644 --- a/logic.asm +++ b/logic.asm @@ -27,16 +27,22 @@ not qword [rsp] next - WORD p_false, 'FALSE',fasm + WORD p_false, 'FALSE',dovalue ;; ( -- 0 ) ;; Push a false flag, 0. - push qword 0 - next + dq 0 - WORD p_true, 'TRUE',fasm + WORD p_true, 'TRUE',dovalue ;; ( -- true ) ;; Return a true flag, -1. (non-zero) - push qword -1 + dq -1 + +pop_false_next: + mov qword [rsp],0 + next + +pop_true_next: + mov qword [rsp],-1 next WORD p_within, 'WITHIN',fasm @@ -46,67 +52,71 @@ pop rax pop rbx cmp qword [rsp],rbx - jl p_within_not + jl pop_false_next cmp qword [rsp],rax - jge p_within_not - not rcx -p_within_not: - next - + jge pop_false_next + jmp pop_true_next + WORD p_0less, '0<',fasm ;; ( n -- flag ) ;; flag is true (non-zero) if and only if n is less than zero. - xor rax,rax cmp qword [rsp],0 - jge p_0less.lt - not rax -p_0less.lt: - next + jl pop_true_next + jmp pop_false_next WORD p_0equal, '0=',fasm ;; ( x -- flag ) ;; flag is true if x is equal to zero otherwise false. - xor rax,rax cmp qword [rsp],0 - jne p_0equal.ne - not rax -p_0equal.ne: - next + je pop_true_next + jmp pop_false_next WORD p_lessthan, '<',fasm ;; ( n1 n2 -- flag ) ;; flag is true if and only if n1 is less than n2. - xor rax,rax - pop rbx - cmp qword [rsp], rbx - jge p_lessthan.ge - not rax -p_lessthan.ge: - mov qword [rsp], rax - next + pop rax + cmp qword [rsp],rax + jl pop_true_next + jmp pop_false_next + + WORD p_lessequal, '<=',fasm + ;; ( n1 n2 -- flag ) + ;; flag is true if and only if n1 is less than n2. + pop rax + cmp qword [rsp],rax + jle pop_true_next + jmp pop_false_next WORD p_equal, '=',fasm ;; ( x1 x2 -- flag ) ;; flag is true if and only if x1 is bit-for-bit the same as ;; x2. - xor rax,rax - pop rbx - cmp qword [rsp], rbx - jne p_equal.ne - not rax -p_equal.ne: - mov qword [rsp], rax - next + pop rax + cmp qword [rsp],rax + je pop_true_next + jmp pop_false_next + WORD p_unequal, '!=',fasm + ;; ( x1 x2 -- flag ) + ;; flag is true if and only if x1 is bit-for-bit the same as + ;; x2. + pop rax + cmp qword [rsp],rax + jne pop_true_next + jmp pop_false_next + WORD p_greaterthan, '>',fasm ;; ( n1 n2 -- flag ) ;; flag is true if and only if n1 is greater than n2. - xor rax,rax - pop rbx - cmp qword [rsp], rbx - jle p_greaterthan.le - not rax -p_greaterthan.le: - mov qword [rsp], rax - next + pop rax + cmp qword [rsp],rax + jg pop_true_next + jmp pop_false_next + WORD p_greaterequal, '>=',fasm + ;; ( n1 n2 -- flag ) + ;; flag is true if and only if n1 is greater than n2. + pop rax + cmp qword [rsp],rax + jge pop_true_next + jmp pop_false_next