/*C-- example for MenuetOS, by Barry Kauler. Using Sphinx C-- version 0.238. Thanks to Alexey Sugonyaev for the original library code. You need to have this file 'cpuspeed.c--', 'msys.h--', 'startup.h--', and 'c--.exe' in the same directory. Just type 'c-- cpuspeed' (at the DOS prompt) and you will have an executable, 'cpuspeed.com'. Rename to 'cpuspeed' and copy to the MenuetOS floppy disk then reboot.*/ #pragma option X //disable sphinx header in output file. #pragma option LST //generate asm listing file. //#pragma option OC //optimisation for code size.(BK:makes run file bigger!!!) //#pragma option 4 //for i80486. //#pragma option A //align data from parity address. #pragma option J0 //disable initial jump to main(). ? resize 0 //disable mem. resizing code at start of output file. #include "msys.h--" char smsg1="CPU speed: "; dword cpuspeed; void draw_window(void) { sys_window_redraw(1); sys_draw_window(100<<16+300,100<<16+200,0x001111CC,0x8099BBFF,0x00FFFFFF); sys_write_text(8<<16+8,0xFFFFFF,"C-- CPU speed example for MenuetOS",34); sys_draw_button(281<<16+12,5<<16+12,1,0x5599CC); // sys_write_number(4<<16,cpuspeed,25<<16+40,0xFFFF80); // or, do it the hard way... $mov eax,cpuspeed //loads contents of "cpuspeed" (square brackets not allowed). $mov edi,#smsg1+16 //the "#" means immediate-mode (address-of "smsg1"). $mov ecx,5 $newnum: $xor edx,edx $mov ebx,10 $div ebx $add dl,48 $mov DSBYTE[edi],dl //keyword "DSBYTE" is required. $sub edi,1 $loop newnum sys_write_text(25<<16+25,0xFFFF80,#smsg1,17); sys_window_redraw(2); } void main(void) { cpuspeed=sys_service(5,0)/1000000; //get CPU speed. draw_window(); while(1) { switch(sys_wait_event()) { case 1: draw_window(); continue; case 2: /*sys_get_key();*/ continue; case 3: if(sys_get_button_id()==1) sys_exit_process(); continue; } } } char endofcode;