Advanced C Programming Spring 2004 Exercise 10. (I/O-ports, CMOS-memory ) Write a program that reads the current date and time from the CMOS memory and displays this data on the screen. In PC:s the information which must be preserved even when the power is switched off are stored in the CMOS memory (setup information). The same IC contains also the RTC (Real Time Clock), wich is running when the power is off. The RTC/CMOS is a device connected to the bus. It can be accessed via i/o-ports. Because RTC/CMOS contains many internal device registers (memory locations), the address/data port technique (option 3, in the handsout material, part 7) is used to keep the number of i/o-ports reasonable. The address port is 70H and the dataport is 71H. The layout of the CMOS memory (regarding RTC) is decribed below. Remark 1. The setup program which you can start during the booting process, reads the information from the CMOS and writes it back, when you decide to change setup information. Remark 2. The hours, minutes and seconds are stored in BCD-format (Binary Coded Decimal). Print the results in hexadecimal format (using format specifier %02x) in the first version of your program to get the right result. When the results are correct this way, write a function convertBCDtoBin to convert two digit BCD number to binary format (two's complement representation). Use this function to convert the BCD date, month, year, hours, minutes and seconds to binary. After the conversion the result must be correct on the screen when you use normal format specifier %02d in your printf function. Appendix. CMOS address Contents 00H RTC current second 01H RTC alarm second 02H RTC current minute 03H RTC alarm minute 04H RTC current hour 05H RTC alarm hour 06H RTC current day of the week 07H RTC current day of the month 08H RTC current month 09H RTC current year 0AH RTC status register A 0BH RTC status register B 0CH RTC status register C 0DH RTC status register D ... Other information in CMOS memory