NASM Forum > Programming with NASM
Smallest code/cpu consuming function to get 1 of 2 values
(1/1)
mik3ca:
I have an input to my program (Let's call it AX here) which can be loaded with any value, but the program only works with two values from AX. 0 and 1. So if the input is anything but a zero, then a 1 is returned. This is the code I have so far:
--- Code: ---cmp AX,0h
je nzero
mov AX,1h
nzero:
--- End code ---
Well, I don't have to exactly have '1' as the other value, but in the end I want AX to be one of two values, at least one of them being zero.
Is there a way to crunch my code down without having to do a comparison followed by potential jump?
fredericopissarra:
--- Code: ---test ax,ax
setnz al ; 386+ instruction.
xor ah,ah
--- End code ---
Navigation
[0] Message Index
Go to full version