Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly AVR程序集添加溢出_Assembly_Arduino_Avr - Fatal编程技术网

Assembly AVR程序集添加溢出

Assembly AVR程序集添加溢出,assembly,arduino,avr,Assembly,Arduino,Avr,我知道这是个新手问题,但我还是会问,因为我找不到答案。这是我正在查看的代码 LDI R15, 0x72 ;R15=114 LDI R16, 0x18 ;R16=24 ADD R16, R15 ;I know this causes signed overflow, but I'm not sure how avr handles this ;or if this number is unsigned LDI R17, 0x91

我知道这是个新手问题,但我还是会问,因为我找不到答案。这是我正在查看的代码

LDI R15, 0x72     ;R15=114
LDI R16, 0x18     ;R16=24
ADD R16, R15      ;I know this causes signed overflow, but I'm not sure how avr handles this 
                  ;or if this number is unsigned

LDI R17, 0x91     ;R17=-111 if this is a signed number, which I assume it is. 
ADD R17, R16      ;no idea what the value is because of previous unkowns. 
我基本上是试图找到什么SREG标志将为此,但不能由于缺乏对AVR的理解。请注意,我目前没有微控制器,如果没有,我会简单地测试以找到指定的值


谢谢你的帮助

如果你没有真正的芯片,你仍然可以使用模拟器。 或者,可怕的是,读一下手册。它有所有SREG位的公式。它说:

H: Rd3·Rr3+Rr3·!R3+!R3·Rd3
   Set if there was a carry from bit 3; cleared otherwise
S: N ^ V, For signed tests.
V: Rd7·Rr7·!R7+!Rd7·!Rr7·R7
   Set if two's complement overflow resulted from the operation; cleared otherwise.
N: R7
   Set if MSB of the result is set; cleared otherwise.
Z: !R7· !R6 ·!R5· !R4 ·!R3 ·!R2 ·!R1 ·!R0
   Set if the result is $00; cleared otherwise.
C: Rd7 ·Rr7 +Rr7 ·!R7+ !R7 ·Rd7
   Set if there was carry from the MSB of the result; cleared otherwise.

因此,
H=0
S=1
V=0
N=1
Z=0
C=0
。这意味着,如果使用无符号算术,则没有溢出(
C=0
),结果(
0x8a=138
)有效。然而,签名溢出确实发生了(
S=1
),因为
0x8a
签名意味着
-118

谢谢,我确实阅读了手册,但是我不知道AVR是如何运行的、签名的还是未签名的。另外,您知道您将使用的模拟器的名称吗?