大会闹钟 [英] Assembly Alarm Clock

查看:262
本文介绍了大会闹钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。
如果我的报警== 60我需要切换INC alarmM并重置报警,但是我有一个问题

I have a question. If my alarmS == 60 i need to switch inc alarmM and reset the alarmS but I have a question

 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报警,5AH即可?而不是0x3C符号是60 ..

why is cpi alarmS , 0x5A ? and not 0x3C which is 60..

后,我们交换半字节,并与比较,0XA0?这是为什么?

after that we swap the nibbles and compare it with , 0xA0?? why is this?

在此先感谢

推荐答案

该片段单独跟踪的秒的数字。即,第一半字节是10秒的倍数。第二个半字节的余数。

The snippet is keeping track of the digits of the seconds separately. That is, the first nibble is the multiple of 10 seconds. The second nibble is the remainder.

在第二四位到达10,它被清零,前半部分增加。

When the second nibble reaches 10, it is cleared and the first nibble incremented.

如果该值达到50和10(即,60秒),然后它被清除,分钟递增。

If the value reaches "50 and 10" (that is, 60 seconds) then it is cleared and the minutes incremented.

在这个片段中的主要问题是,这一切都需要在code注释加以解释。这足以不期而至要求的。

The major problem with this snippet is that all this needs to be explained in a comment in the code. It is unexpected enough to demand it.

这篇关于大会闹钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆