Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

RDRVSX32: FAT32 RAM drive for HimemSX (Announce)

posted by tom Homepage, Germany (West), 21.05.2022, 17:41

> as the time is directly the BIOS timer tick (converted to seconds and
> centiseconds), I would rather suggest the kernel code to convert ticks into
> seconds is somehow broken (although I couldn't find a possible bug).

converting the suspicious kernel code from kernel\sysclk.c into a test routine as below 'proves' that the kernel code is correct; i.e. an increase in the BIOS tick count results in a greater converted DOS time.

I have no idea how this could happen.

#else                             // #ifdef TEST   

#undef SEEK_SET
#undef SEEK_CUR
#undef SEEK_END


#include "stdio.h"

/* compile with

        set PATH=%WATCOM%\binnt
        set INCLUDE=%WATCOM%\h
        wcl sysclk.c /DTEST /i..\hdr -q
*/     
       


main()
{     
        ticks_t ticks, bios_ticks;
    struct ClockRecord clk, oclk;
    int tmp;


        for (bios_ticks = 0; bios_ticks < 0xffff0000l; bios_ticks++)
                {   
   
        /* The scaling factor is now
           6553600/1193180 = 327680/59659 = 65536*5/59659 */

        ticks = 5 * bios_ticks;
        ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u;

        tmp = (int)(ticks / 6000);
        clk.clkHours = tmp / 60;
        clk.clkMinutes = tmp % 60;

        tmp = (int)(ticks % 6000);
        clk.clkSeconds = tmp / 100;
        clk.clkHundredths = tmp % 100;

                if (bios_ticks < 20)
                        printf("%2d:%02d:%02d.%02d\n", clk.clkHours, clk.clkMinutes,
                                                                                clk.clkSeconds, clk.clkHundredths);
       
        if (clk.clkHours   <= oclk.clkHours &&
            clk.clkMinutes <= oclk.clkMinutes &&
            clk.clkSeconds <= oclk.clkSeconds &&
            clk.clkHundredths <= oclk.clkHundredths)
            {       
            printf("ticks %lu\n", bios_ticks);
                        printf("old %2d:%02d:%02d.%02d\n", oclk.clkHours, oclk.clkMinutes,
                                                                                oclk.clkSeconds, oclk.clkHundredths);
                        printf("now %2d:%02d:%02d.%02d\n", clk.clkHours, clk.clkMinutes,
                                                                                clk.clkSeconds, clk.clkHundredths);
            }
           
                oclk = clk; 
               
                if (clk.clkHours >= 24)
                        {
                        printf("midnight at %lu = 0x%lx\n", bios_ticks, bios_ticks);
                        break;
                        }
                }
               
        return 0;

}
#endif

 

Complete thread:

Back to the forum
Board view  Mix view
22632 Postings in 2109 Threads, 402 registered users, 197 users online (0 registered, 197 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum