AVR Studio-AVR模拟器2进位标志问题

AVR Studio-AVR模拟器2进位标志问题,avr,Avr,我刚刚开始了一个装配线编程类,我遇到了一个问题,我将240和49相加,我知道它会溢出,我的目标是当这些数字溢出时,使寄存器1等于1。我知道进位标志是在我添加它们时设置的,但我不确定如何使用该标志使r1等于1 This program should calculate: ; R0 = R16 + R17 + R18 ; ;--*1 Do not change anything between here and the line starting with *-- .cseg ldi r1

我刚刚开始了一个装配线编程类,我遇到了一个问题,我将240和49相加,我知道它会溢出,我的目标是当这些数字溢出时,使寄存器1等于1。我知道进位标志是在我添加它们时设置的,但我不确定如何使用该标志使r1等于1

 This program should calculate:
; R0 = R16 + R17 + R18
;
;--*1 Do not change anything between here and the line starting with *--
.cseg
    ldi r16, 0x30
    ldi r17, 0x31
    ldi r18, 0x32
;*--1 Do not change anything above this line to the --*

;***
; Your code goes here:
;
    add r0, r16
    add r0, r17
    add r0, r18


;****

;--*2 Do not change anything between here and the line starting with *--
done:   jmp done
;*--2 Do not change anything above this line to the --*

我相信有更聪明的方法,但您可以使用BRC,如果设置了进位,则可以使用分支:

add r0, r16
add r0, r17
add r0, r18
brcs carry ; Branch if carry set

carry: ldi r1, 0x1 ; Branch destination