CMOS time
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:CMOS time
i don't see a particular reason for this ... maybe something wrong in your code, i know that the CMOS chip behaves a bit differently from the other component of the PC ...
Re:CMOS time
yea i found the problem but im not sure why it occurs.
i change the number i get to ascii code.
char a=CHANGETOASCII(cmoshours&f); low
char b=CHANGETOASCII(cmoushours>>4) high
when i put the ascii codes in a pointer like:
char *temp;
temp[0]=a;
temp[1]=b;
temp[2]=0;
print(temp);
.....it doesnt work...nothing prints
so i have to do:
char temp[3];
temp[0]=a;
temp[1]=b;
temp[2]=0;
WHY DOES THIS HAPPEN?
i change the number i get to ascii code.
char a=CHANGETOASCII(cmoshours&f); low
char b=CHANGETOASCII(cmoushours>>4) high
when i put the ascii codes in a pointer like:
char *temp;
temp[0]=a;
temp[1]=b;
temp[2]=0;
print(temp);
.....it doesnt work...nothing prints
so i have to do:
char temp[3];
temp[0]=a;
temp[1]=b;
temp[2]=0;
WHY DOES THIS HAPPEN?
Re:CMOS time
Because you don't understand C strings. The first piece of code doesn't allocate any memory for the string. Your temp pointer points nowhere, so you're writing to a random memory address. In your second piece of code, you access temp as an array. The compiler allocates three elements for it, and everything works.
Re:CMOS time
also remember the cmos timmer outputs BCD numbers which need to be converted.
-- Stu --
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:CMOS time
BCD Numbers: a nibble of a byte represents a number? also known as packed numbers in mainframe asm?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image