Page 1 of 1

Time again

Posted: Fri Jul 02, 2004 11:00 pm
by Gor
I need time, didnt managed to fix it... I want the local time (or something, just some kinda time from the RTC)..this is what I got:
        out(0x70,0x4);
        char hours = in(0x71);
        
        out(0x70,0x2);
        char minutes = in(0x71);
        
        out(0x70,0x0);
        char seconds = in(0x71);
what do I need to convert this into time,and how do I do it?

RE:Time again

Posted: Fri Jul 02, 2004 11:00 pm
by ASHLEY4
This is how i converted it in asm.
;----------------------------------------------------;
; bcd_to_ASCII         ;converts bcd number to ASCII ;
;----------------------------------------------------;
;                                                    ;
;   Input:                                           ;
;         Bcd number in al.                          ;
;  Output:                                           ;
;         ASCII number in val.                       ;
;                                             (100%) ;
;....................................................;

bcd_to_ASCII:
       pusha                                            ;start of convert
       mov  ah,al                                       ;copy AL to AH
       and  ax,0f00fh                                   ;mask bits
       mov  cl,4                                        ;CL=04 for shift
       shr  ah,cl                                       ;shift right AH to get unpacked BCD
       or   ax, 3030h                                   ;combine with 30 to get ASCII
       xchg ah,al                                       ;swap for ASCII storage convention
       mov  [val],ax                                    ;store the ASCII value in VAL
       popa

       ret
Let me know if you want all the code.

ASHLEY4.

RE:Time again

Posted: Fri Jul 02, 2004 11:00 pm
by Gor
but how to do it in C? Just cant get it right even though I use the same operations..or how do I send the [val] adress to the ASM function?