Answer the question
In order to leave comments, you need to log in
An example of using logical operations AND, OR, TEST in assembler?
Greetings,
Can I have an example of using logical operations in assembler?
As far as I understand, they are used to perform bit inversion, BUT I don’t understand when this may be needed in real tasks and for what (I will be glad to see an example)?
If there are people who are fluent in asm, then explain :)
Answer the question
In order to leave comments, you need to log in
An example is the storage of flags of certain states.
In order not to use a whole byte to store one state (0 or 1), we take a byte and set a certain flag - for example, in a certain bit:
mov ah, myflag
or ah, b00001000 # установили флаг
mov myflag, ah # обратно сохранили в переменную
...
mov ah, myflag # берем обратно нашу переменную
and ah, b00001000 # и проверяем наше состояние
jz прыгнули_ если_флаг_равен_0
...
mov ah, myflag # берем обратно нашу переменную
and ah, b00000010 # проверяем наше состояние в каком-то другом бите
jz прыгнули_ если_флаг_равен_0
most common are boolean conditions, combining multiple conditions
if((var & 1) == 1) {} ... can become TST
if(var1 == 0 && var2 == 1) can use AND
and so on
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
indicated this?
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question