How do I convert something from BCD to ascii in C/C++? Have tried to port ASM code but I didnt get it to work. Should be used for a time function or something. The code I use now is:
outbyte(0x70,0x4);
unsigned char h = inbyte(0x71);
and I wanna know how to get the current hour out of this number
BCD converter
Re:BCD converter
Code: Select all
char hour[2];
outbyte(0x70,0x4);
unsigned char h = inbyte(0x71);
/* h assumed BCD encoded byte sized value */
hour[0] = (char)(((h & 0xf0) >> 4) + 0x30);
hour[1] = (char)((h & 0x0f) + 0x30);
Re:BCD converter
Well it works a little better now..but the minute is changed about every second and all that.. and when I reboot bochs, the hour i different..
Re:BCD converter
Sorry man it works great the first time, guess it?s bochs problem that the time changes when I reboot?
me being just as stupid as allways
me being just as stupid as allways