I have written a code in assembler emulator emu8086 of comparing x + c with 0 and I need my functions to work by result of comparison.
f1, when x + c < 0
f2, when x + c = 0
f3, when x + c > 0
MOV ax, x[si]
MOV bl, c
CBW
ADD ax, bx
CBW
CMP ax, 0
JE f2;
JL f1;
JG f3 ;
I am expecting to get f2 function work when ax(x + c) is equal to zero, f1 to work when ax(x+c) is less than zero and f3 when ax(x+c) is greater than zero, but somehow it only does f2 and f3 correctly, I get f2 done instead of f1, I can not understand what is wrong. Even when I am writing
JE f1;
JL f1;
JG f1 ;
it still doesn't do f1, does f2 instead of f1, but if I delete f3 out of my code, then f1 get's done. functions look like:
f1: MOV ax, 2
IMUL a
JO kl1 ;
MOV bx, x[si]
CMP bx, 0
JG mod
NEG bx
mod: ADD ax, bx
MOV dx, ax
JO kl1
f2: MOV ax, 6
ADD ax, 3
JO kl1
JMP re
f3: MOV ax, 4
JO kl1
JMP re