[英]How to “NOT” a register in mips assembly
既然mips匯編中沒有NOT邏輯運算符,那么一個寄存器的內容怎么可能“不”呢?
您可以使用nor
和zero
寄存器將所有內容放入一條指令中:
nor $<dest_reg>, $<in_reg>, $zero
等效的邏輯表達式為:
a nor 0 = not (a or 0) = not a
另一種方法是使用xor
和-1
因為它在2s分量中被編碼為1111...1111
。
li $<help_reg>, -1 # load -1 into help-register
xor $<dest_reg>, $<in_reg>, $<help_reg> # actual not-operation
等效邏輯表達式為:
a xor 1 = (not a) and 1 = not a
將-1裝入另一個寄存器,然后對寄存器進行XOR。
https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/bitwise.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.