AND: 逻辑与指令 OR : 逻辑或指令 XOR: 逻辑异或指令 NOT: 逻辑非指令 这和 Delphi 的逻辑命令完全一致.
//逻辑非 Not: 
{
  not 1 = 0; 
  not 0 = 1;
}
var
  ByteNum: Byte;
begin
  //赋值 11111111B (255) 取反:
  asm
    mov al, 11111111B {eax 包含 ax; ax 包含 al; al 是 eax 的低八位}
    not al            {给 11111111 取反会得到 00000000}
    mov ByteNum, al   {把寄存器 al 中的值给变量 ByteNum}
  end;
  ShowMessage(IntToStr(ByteNum)); {0}


  //赋值 00000001B (1) 取反:
  asm
    mov al, 00000001B
    not al            {给 00000001 取反会得到 11111110}
    mov ByteNum, al
  end;
  ShowMessage(IntToStr(ByteNum)); {254}


  //赋值 10000000B (128) 取反:
  asm
    mov al, 00000001B
    not al            {给 10000000 取反会得到 01111111}
    mov ByteNum, al
  end;
  ShowMessage(IntToStr(ByteNum)); {127}
end;

//逻辑或 Or: { 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;
//逻辑与 And: { 1 and 1 = 1; 1 and 0 = 0; 0 and 1 = 0; 0 and 0 = 0; } var ByteNum: Byte; begin //例1 asm mov al, 11111111B {255} mov cl, 11111111B {255} and al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {255} //例2 asm mov al, 00000000B {0} mov cl, 00000000B {0} and al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {0} //例3 asm mov al, 11111111B {255} mov cl, 00000000B {0} and al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {0} //例4 asm mov al, 10101010B {170} mov cl, 01010101B {85} and al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {0} end;
//逻辑异或 Xor: { 1 Xor 0 = 1; 0 Xor 1 = 1; 1 Xor 1 = 0; 0 Xor 0 = 0; } var ByteNum: Byte; begin //例1 asm mov al, 11111111B {255} mov cl, 11111111B {255} xor al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {0} //例2 asm mov al, 11111111B {255} mov cl, 00000000B {0} xor al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {255} //例3 asm mov al, 10101010B {170} mov cl, 01010101B {85} xor al, cl mov ByteNum, al end; ShowMessage(IntToStr(ByteNum)); {255} end;
posted on 2008-01-28 10:04  万一  阅读(5338)  评论(3编辑  收藏  举报