hex - How do you clear a specific bit in a register without changing the other bits in ONE instruction? -


For example, suppose the value of Register 4 (R4) is 0001110010101111. How can you change bit 5 (0001110010 & gt; <0 Strong> 1 & lt; 01111) 0 (even if it was already 0) without any hex directive To change or change the other bit of ?

0001110010 1 01111 - & gt; 0001110010 0 01111

because you are and The immediate value for AND is 5 bits and it uses the sign extension, if you are one of the four less important bits, then you can only clean a bit. Otherwise, you will need other instructions to load the mask in a register. I'll give an example of both.

In the case of the 5th bits, the number that will keep the bit mask 0b1111111111011111 . In decimal, this is # 65503 or # - 33 . Since it is too big to fit in instant instruction, so you will not be able to do it in single instruction. You have to declare it in the data segment of your program and load the mask in a register. After that, you can do AND with R4 .

 ; Suppose R4 = 0001110010101111 LD R5, MASK5; Load the mask in R5 and R4, R4, R5; Set R4 = R4 & R5; R4 will be a bit clearer now; Data Segment MASK_5. # 6503 Fill in the case of the third bit, the number that will keep the bit mask  0b1111111111110111 . In decimal, this is  # 65527  or  # - 9 . This will fit in the immediate value of  and , so that you can execute it in single instruction:  
 ; R4 = 0001110010101111 and R4, R4, # -9; Set R4 = R4 and # -9; R4 will now be cleared slightly    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -