1)why the following test programs are not working?
#include "stdio.h"
#include "time.h"
int i,x,step;
time_t s1,s2;
void main(void){
step=20;
s1=time(NULL);
for(i=0;i<32;i++){
cprintf("%c",32);
}
cprintf("\n\r");
for(i=32;i<64;i++){
cprintf("%c",32);
}
s2=time(NULL);
cprintf("%f",difftime(s2,s1));
getch();
s1=time(NULL);
for(i=0;i<64;i++){
if(i==32) cprintf("\n\r");
cprintf("%c",32);
}
s2=time(NULL);
cprintf("%f",difftime(s2,s1));
getch();
exit(0);
}
---------------------------------------
#include "stdio.h"
#include "time.h"
int i,x,step;
clock_t s1,s2;
void main(void){
step=20;
s1=clock();
for(i=0;i<32;i++){
cprintf("%c",32);
}
cprintf("\n\r");
for(i=32;i<64;i++){
cprintf("%c",32);
}
s2=clock();
cprintf("%ld",s2-s1);
getch();
s1=clock();
for(i=0;i<64;i++){
if(i==32) cprintf("\n\r");
cprintf("%c",32);
}
s2=clock();
cprintf("%ld",s2-s1);
getch();
exit(0);
}
they show zeros and 1s.as i know, one of them should show time in seconds
elapsed at cicle execution and the other time in clock impulses.by the way,
what kind of impulses, from the external clock, or the clock speed of
instructions execution(at microcontrolers or other simple programmable
hardware,the external clock rate is divided at a integer which is a power of
2 resulting internal clock rate)?when we say that a PC runs at 100mhz which
clock rate is this?
2)it is a difference between tiny or other model generated by the compiler?
i've compiled the source file in tiny and medium model and except the size of
exe file and a "no stack" warning at tiny model i didn't noticed any
change in runing the programme.