??? 04/29/04 13:17 Read: times |
#69478 - RE: routines for date time arithmetic? Responding to: ???'s previous message |
Peter took me up on my offer to send him the code that I have in the 'HC08 format. It occurred to me that I should post a link to it since it could be of use to others either as a base for translation or otherwise. I know that even though this is off topic for this forum, source for small assembly language date and time calculation routines is scarce on the WEB. Maybe if Peter or someone else translates the code I made to 8051 assembly it can be posted here too and bring this subject totally back on topic.
To download / view the HC08 Date/Time Calculation Code click here. Here are some comments to go with it: ---------------------------------------------------- The routines are written in Motorola 'HC08 type language. I had these in a product I did that used a MC68HC908GP32. To translate to 8051 it is necessary to be familiar with the HC08 instruction set which you can find in this manual at the Mot web site. I made these for use with a product that has an RTC chip that kept track of real time. The product had an array of features that needed to track the passage of time. In some cases time stamps of certain events were written into a serial EEPROM and then later compared to the RTC to see of say 90 days had gone by. I tried to keep the implementation simple so these were designed to support dates from 1-1-2000 through 1-1-2100. (The RTC was strictly limited to a 100 year century byte and the product life span was never expected to extend into the next century. You will see routines for converting a date to a number of days since the reference start date and back again. So if you want a date 90 days hence take todays MM/DD/YY from the RTC, convert to a day number, add 90 and convert back. Both routines are shown. These day numbers conveniently fit with 16 bits. In a similar manner I made routines to convert HH:MM:SS values to a second number and back again. These use a reference time of 00:00:00 at midnight. A bit of higher level work would be required to compute on intervals that combine date and time together. Over many years of embedded work however I have never found it necessary to compute and compare times and dates together. Almost always it is .... "so many days from now" or "some number of hours or minutes or seconds ago". Michael Karas |
Topic | Author | Date |
routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic? | 01/01/70 00:00 | |
RE: routines for date time arithmetic?![]() | 01/01/70 00:00 |