| ??? 10/25/06 04:40 Read: times |
#126967 - Decimal Counting down Responding to: ???'s previous message |
Store each BCD digit in its own byte.
Load the LCB digits into the accumulator and decrement it. When the accumulator underflows to FF, then reload it with 9. Use the branch to decrement the next most significant digit. Merge the digits to print them.
BEG: MOV A,COUNT1 ; Move LSD to A
DEC A ; Decrement the LSD
CJNE 0FFh, BEG2 ; Check for underflow
MOV COUNT1, #09h ; If underflow, reload with 09 and dec MSD
;
MOV A, COUNT2 ; Fetch MSD
DEC A ; Decrement the MSD
CJNE 0FFh, BEG1 ; Check for underflow
MOV A, #09h ; Reload MSD with 9
BEG1: MOV COUNT2, A ; Save the MSD
JP BEG3 ; Jump to end
BEG2: MOV COUNT1,A ; Save LSD
BEG3:
Good Luck |
| Topic | Author | Date |
| AT89C51 countdown timer | 01/01/70 00:00 | |
| I Think... | 01/01/70 00:00 | |
| Decimal Counting down | 01/01/70 00:00 | |
| if you post errors | 01/01/70 00:00 | |
| it seems to be non-51 | 01/01/70 00:00 | |
| aha | 01/01/70 00:00 | |
| I screwed up | 01/01/70 00:00 | |
| we just wanted to run down on somebody :-) | 01/01/70 00:00 | |
| This group | 01/01/70 00:00 | |
| BCD=IncrementByAdding01HDecByAdding99H | 01/01/70 00:00 | |
| RTFB | 01/01/70 00:00 | |
| Why count BCD down? | 01/01/70 00:00 | |
| Why microcontroller? | 01/01/70 00:00 | |
The Appliction | 01/01/70 00:00 | |
| Why count BCD down? | 01/01/70 00:00 |



