luserdroog
2020-08-27 20:06:13 UTC
Hi everyone,
I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.
My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?
CODE(0=, zeroeq, POP(AX),MOVCXI(1,0), CMP(,R,AX,CX), SBB(,R,AX,AX), PUSH(AX))
CODE(0>, zerogt, POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JL,3,MOVCXI(0xff,0xff), PUSH(CX))
CODE(0<, zerolt, POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JG,3,MOVCXI(0xff,0xff), PUSH(CX))
testing:
WORD(run, run, c_lit,0, c_zeroeq, c_dot,
c_lit,12, c_zerogt, c_dot,
c_lit,minus(50), c_zerolt, c_dot,
c_lit,79,c_emit, c_lit,75,c_emit, c_lit,5,c_double,c_emit, c_bye)
output:
$ ./a8086
110OK
I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.
My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?
CODE(0=, zeroeq, POP(AX),MOVCXI(1,0), CMP(,R,AX,CX), SBB(,R,AX,AX), PUSH(AX))
CODE(0>, zerogt, POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JL,3,MOVCXI(0xff,0xff), PUSH(CX))
CODE(0<, zerolt, POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JG,3,MOVCXI(0xff,0xff), PUSH(CX))
testing:
WORD(run, run, c_lit,0, c_zeroeq, c_dot,
c_lit,12, c_zerogt, c_dot,
c_lit,minus(50), c_zerolt, c_dot,
c_lit,79,c_emit, c_lit,75,c_emit, c_lit,5,c_double,c_emit, c_bye)
output:
$ ./a8086
110OK