Reputation: 15
I'm writing a clone of the ancient Turbo Pascal v.3 8086 compiler. I want to compare two unsigned integers and if they are equal, set ax=1 (true) else set ax=0 (false).
Given the statement
bool:=1=2;
Turbo Pascal emits
mov ax,1 ; argument 1
cmp ax,2 ; argument 2
mov ax,1 ; 1 = true
jz L1 ; arguments are equal, ax=1
dec ax ; arguments are not equal, ax=0
L1:
mov bool,ax
Yes, it works, but seems clumsy and awkward. Is there a better way in 8086?
Upvotes: 0
Views: 830
Reputation: 23737
mov ax,argument1
sub ax,argument2
add ax,-1
sbb ax,ax
inc ax
mov bool,ax
Upvotes: 4