Delphi Embedded Assembly [17]-logic operation

Source: Internet
Author: User
<xmp> <Br/> and: logic and command <br/> or: logic or command <br/> XOR: logic difference or command <br/> not: logical non-instruction <br/> </xmp>
This is exactly the same as the logic commands of Delphi.
// Logical non-not: {not 1 = 0; not 0 = 1;} var bytenum: byte; begin // assign a value of 111111b (255); reverse: ASM mov Al, 11111111b {eax contains ax; ax contains al; Al is the low eight bits of eax} Not Al {returns 11111111} mov bytenum to the 00000000 reverse, al {give the value in register Al to the variable bytenum} end; showmessage (inttostr (bytenum); {0} // assign a value of 1B (1) to get the inverse: ASM mov Al, 00000001} mov bytenum, Al end; showmessage (inttostr (bytenum); {11111110} // returns the inverse value of 254 B (128: ASM mov Al, 00000001b not Al {returns 10000000} mov bytenum, Al end; showmessage (inttostr (bytenum); {01111111} end;
  
   
 // Logic 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;
  
   
 // Logic and And: {1 and 1 = 1; 1 and 0 = 0; 0 and 1 = 0; 0 and 0 = 0;} var bytenum: byte; begin // Example 1 ASM mov Al, 111111b {255} mov Cl, 11111111b {255} and Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {255} // Example 2 ASM mov Al, 1_1_ B {0} mov Cl, 1_ B {0} and Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {0} // Example 3 ASM mov Al, 111111b {255} mov Cl, 1_ B {0} and Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {0} // Example 4 ASM mov Al, 10101010b {170} mov Cl, 01010101b {85} and Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {0} end;
  
   
 // Logic or XOR: {1 XOR 0 = 1; 0 XOR 1 = 1; 1 XOR 1 = 0; 0 XOR 0 = 0;} var bytenum: byte; begin // Example 1 ASM mov Al, 111111b {255} mov Cl, 111111b {255} XOR Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {0} // Example 2 ASM mov Al, 111111b {255} mov Cl, 1_ B {0} XOR Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {255} // Example 3 ASM mov Al, 10101010b {170} mov Cl, 01010101b {85} XOR Al, CL mov bytenum, Al end; showmessage (inttostr (bytenum )); {255} end;
  
   
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.