我刚刚开始一个流水线编程课,我遇到了问题的问题,我加了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 --*
答案 0 :(得分:0)
我确信有更聪明的方法,但你可以使用brcs
,如果携带设置分支:
add r0, r16
add r0, r17
add r0, r18
brcs carry ; Branch if carry set
carry: ldi r1, 0x1 ; Branch destination