2014-04-07 93 views
-1

我有問題。 如果我報警== 60我需要切換INC alarmM並重置報警,但是我有一個問題裝配鬧鐘

increment_alarm_second: 
inc alarmS       ; increment alarmS 
cpi alarmS , 0x5A ; 0x3C   ; Compare alarmS to 60 
breq increment_alarm_minute   ; If true, jump incMinute 
swap alarmS       ; swap here to save registers (swap nibbles) 
cpi alarmS , 0xA0     ; compares alarmS register to an inverted 10 
brlo endIncSecal     ; branch if lower then an inverted 10 to endIncSecal 

    incSecTenal:    
     andi alarmS, 0x0F   ; does an AND + increment on the alarmS register 
     inc alarmS     ; increments the alarmS register 
     swap alarmS     ; swaps alarm_s register 
    ret        ; returns from the calll 

endIncSecal:       
swap alarm_s      ; swap back 
ret 

爲什麼CPI報警,0x5A?而不是0x3C,即60 ..

之後,我們交換半字節,並與之比較,0xA0?爲什麼是這樣?

預先感謝

回答

0

該代碼段被單獨地跟蹤的秒的數字。也就是說,第一個半字節是10秒的倍數。剩餘的是第二個半字節。

當第二個半字節達到10時,它被清除並且第一個半字節增加。

如果該值達到「50和10」(即60秒),那麼它被清除並且分鐘遞增。

這段代碼的主要問題是所有這些都需要在代碼的註釋中解釋。要求它是意想不到的。

+0

好吧,謝謝你有道理,但你怎麼知道它是檢查小節? 有沒有更簡單的方法來做這個片段? –