AND: 邏輯與指令 OR : 邏輯或指令 XOR: 邏輯異或指令 NOT: 邏輯非指令這和 Delphi 的邏輯命令完全一致.
//邏輯非 Not:{
//賦值 11111111B (255) 取反:
not 1 = 0;
not 0 = 1;
}
var
ByteNum: Byte;
begin asm
ShowMessage(IntToStr(ByteNum)); {0}
mov al, 11111111B {eax 包含 ax; ax 包含 al; al 是 eax 的低八位}
not al {給 11111111 取反會得到 00000000}
mov ByteNum, al {把寄存器 al 中的值給變量 ByteNum}
end;
//賦值 00000001B (1) 取反: asm
ShowMessage(IntToStr(ByteNum)); {254}
mov al, 00000001B
not al {給 00000001 取反會得到 11111110}
mov ByteNum, al
end;
//賦值 10000000B (128) 取反: asm
//邏輯或 Or:
mov al, 00000001B
not al {給 10000000 取反會得到 01111111}
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {127}
end;{
//邏輯與 And:
1 or 0 = 1;
0 or 1 = 1;
1 or 1 = 1;
0 or 0 = 0;
}
var
ByteNum: Byte;
begin
asm
mov al, 10101010B {170}
mov cl, 01010101B {85}
or al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {255}
end;{
//例1
1 and 1 = 1;
1 and 0 = 0;
0 and 1 = 0;
0 and 0 = 0;
}
var
ByteNum: Byte;
begin asm
//例2
mov al, 11111111B {255}
mov cl, 11111111B {255}
and al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {255} asm
//例3
mov al, 00000000B {0}
mov cl, 00000000B {0}
and al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {0} asm
//例4
mov al, 11111111B {255}
mov cl, 00000000B {0}
and al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {0} asm
//邏輯異或 Xor:
mov al, 10101010B {170}
mov cl, 01010101B {85}
and al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {0}
end;{
//例1
1 Xor 0 = 1;
0 Xor 1 = 1;
1 Xor 1 = 0;
0 Xor 0 = 0;
}
var
ByteNum: Byte;
begin asm
//例2
mov al, 11111111B {255}
mov cl, 11111111B {255}
xor al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {0} asm
//例3
mov al, 11111111B {255}
mov cl, 00000000B {0}
xor al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {255} asm
mov al, 10101010B {170}
mov cl, 01010101B {85}
xor al, cl
mov ByteNum, al
end;
ShowMessage(IntToStr(ByteNum)); {255}
end;