简体   繁体   English

使用程序集(Keil)比较R0与R1

[英]Comparing R0 with R1 using assembly (Keil)

I have two values stored in R0 and R1 . 我有两个值存储在R0R1 I am comparing the two as follows: 我将两者进行如下比较:

MOV R3, #(R0 XOR R1)
CJNE R3,#0,NOT_EQUAL

Apparently it is not possible to use the XOR OPERATOR this way. 显然,不可能以这种方式使用XOR运算符。 Is there another way to compare R0 with R1 and check is they are equal or not? 还有另一种比较R0R1并检查它们是否相等的方法吗?

Since you want to perform the XOR at runtime, you will have to use instructions to accomplish that. 由于要在运行时执行XOR ,因此必须使用说明来完成。 Unfortunately, the XRL instruction only operates on the A register, so you might have to do some rearranging. 不幸的是, XRL指令仅对A寄存器XRL ,因此您可能必须进行一些重新排列。 Assuming A is not available, but R3 is, you can do: 假设A不可用,但R3可用,则可以执行以下操作:

MOV R3, A ; save A to R3
MOV A, R0
XRL A, R1
XCH A, R3 ; restore A and put the result into R3
CJNE R3, #0, NOT_EQUAL

If A is available, you can use the CJNE accepting a memory operand knowing that registers are memory mapped: 如果A可用,则可以使用CJNE接受内存操作数,而知道寄存器是内存映射的:

MOV A, R0
CJNE A, 1, NOT_EQUAL ; 1 is the bank0 address of R1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM