c++.dos.32-bits - Helping getting dos tickcount
- Arthur Becker (25/25) Feb 14 2007 Hi,
- Heinz Saathoff (24/49) Feb 16 2007 Which memory model do you use? This example will not work with the DOS
Hi, I love DMC and am (slowly) getting used to doing some programming in ASM as well. I am trying to figure out that processor speed by using rdtsc and then keeping a counter outside of that. The problem I run into is that for some reason I can't correctly get the BIOS tick count on two separate Intel machines. I have tried a crap load of different ways to reference the same memory. Here is the code and the output is the same number over and over no matter how many times I run the program. Your help getting my head "out" would be much appreciated. BTW, I took this example code from the Intel CPU identification and CPUID instruction document. static unsigned int SEG_BIOS_DATA_AREA = 0x040; static unsigned int OFFSET_TICK_COUNT = 0x06c; unsigned int testVal; asm { push SEG_BIOS_DATA_AREA pop es mov esi, OFFSET_TICK_COUNT // The BIOS tick count updates mov ebx, DWORD PTR es:[esi] // ~ 18.2 times per second. mov testVal,ebx } printf("Time Value:%u",testVal);
Feb 14 2007
Hello, Arthur Becker schrieb...I love DMC and am (slowly) getting used to doing some programming in ASM as well. I am trying to figure out that processor speed by using rdtsc and then keeping a counter outside of that. The problem I run into is that for some reason I can't correctly get the BIOS tick count on two separate Intel machines. I have tried a crap load of different ways to reference the same memory. Here is the code and the output is the same number over and over no matter how many times I run the program. Your help getting my head "out" would be much appreciated. BTW, I took this example code from the Intel CPU identification and CPUID instruction document. static unsigned int SEG_BIOS_DATA_AREA = 0x040; static unsigned int OFFSET_TICK_COUNT = 0x06c; unsigned int testVal; asm { push SEG_BIOS_DATA_AREA pop es mov esi, OFFSET_TICK_COUNT // The BIOS tick count updates mov ebx, DWORD PTR es:[esi] // ~ 18.2 times per second. mov testVal,ebx } printf("Time Value:%u",testVal);Which memory model do you use? This example will not work with the DOS extented (Option -mx) or as a Windows application. If you compile this example with dmc -ms t.c you will get the ticker: /**************** t.c ***********************/ #include <stdio.h> unsigned int GetBiosTicker() { unsigned int btick; asm { mov ax,0x0040 mov es,ax mov si,0x006c mov ax,es:[si] mov btick,ax } return btick; }//GetBiosTicker int main() { printf("Bios-Tick = %u\n", GetBiosTicker()); return 0; } /**************** end t.c ***********************/ - Heinz
Feb 16 2007