DecimalHours=RTCHours>>4
DecimalHours=(DecimalHours&$03)*10
DecimalHours=DecimalHours+(RTCHours&$0F)
RTCHours is read from the DS1307. It is in BCD format.
The first line takes bits 4 thru 7 and loads them into Decimal Hours as bits 0 thru 3. These are the DECIMAL TENS DIGIT VALUE of the BCD HOURS (plus a couple of additional control bits).
If you notice from the Datasheet, only bits 4 and 5 are the BCD TENS DIGIT (which we have moved to bits 0 and 1 of variable DecimalHours. Since we only need those two bits, we exclude all others with the AND '&' operator, ANDing it with $03. The result of that operation we simply multiply by ten. We now have our TENS DIGIT value extracted.
The third line takes the lower four bits ONLY (by ANDing them with $0F) of the RTCHours variable (those four bits being the BCD UNITS VALUE) and we ADD them to our previously extracted TENS VALUE.
We now have a BYTE variable called DecimalHours which contains a value between 0-23 (assuming you are running a 24 hour clock). You can Output it to your LCD with the command...
LCDOUT #DecimalHours
If you wanted your alarm at say 7am you can now simply say...
AlarmHours=7
If AlarmHours=DecimalHours then goto SoundKlaxxon




Bookmarks