Turbo C 2.0 vs MSC 5.1

Fred Smith fredex at cg-atla.UUCP
Wed Jul 12 23:00:06 AEST 1989


In article <3607 at cps3xx.UUCP> usenet at cps3xx.UUCP (Usenet file owner) writes:
>in article <644 at octopus.UUCP>, mikem at slp.UUCP (Mike Morris) says:
>> 
>> 
>> I am considering purchasing Borland's Turbo C 2.0 professional package and 
>> am wondering what kind of experiences other netland users have had using it.  
>
>Having used both professionally, I'd highly recommend Turbo over
>Microsoft. On the basis of just the C compiler Turbo has two features
>that aren't found in Microsoft. (1) Turbo has inline assembler. 
>(2) Turbo can declare functions as interrupt routines. For both of
>these in Microsoft you need a separate assembler module (unless I
>missed something in the manual). Turbo's manuals are also easier
>to find things in.
>


----------------------------------------


Below is a short piece of code written for Microsoft C 5.1 which illustrates
how easy it is to  write interrupt routines in C, despite what the other
poster said.

He was right, however, in the implication that it is difficult to find
things in the Microsoft manuals. They contain lots of information, but 
somehow locating the particular piece you need is difficult. Please note
that some of the information on interrupt routines is hidden in the
various documentation supplement files  provided on the distribution
floppies so that it IS difficult to find.

I must admit that I have not had the opportunity to use Turbo C or
Zortech C, so I cannot offer a comparison--I just felt called upon to
correct the error stated in the previous posting.

This program is a complete program which you can test easily--just
compile with MSC 5.1 using the -DDEBUG switch on the command line and
try it!


ulowell!cg-atla!fredex
------------------------------


#include <stdio.h>
#include <dos.h>

static void intercept_timer(void);
static void restore_timer(void);
static void interrupt far newtimer (void);
static void (interrupt far *oldtimer)(void);
static unsigned int ticker = 0;

#define timeup() (ticker==0)
#define timerset(tenths) ticker=(unsigned int)((long)tenths*182L/100L+1L)
#define TIMER     0x1c

#define getvect _dos_getvect
#define setvect _dos_setvect

static void intercept_timer (void)
    {
    if (oldtimer == NULL)
        {
        oldtimer = getvect(TIMER);
        setvect (TIMER, newtimer);
        }
    }

static void restore_timer(void)
    {
    if (oldtimer)
        setvect(TIMER, oldtimer);
    oldtimer = NULL;
    }

static void interrupt far newtimer()
    {
    (*oldtimer)();      /* call old timer ISR */
    if (ticker)
        --ticker;
    }

void sleep(int seconds)
	{
	intercept_timer ();
	timerset (seconds * 10);
	while ( ! timeup())
		;
	restore_timer ();
	}



#if DEBUG
#include <stdio.h>
main()
    {
    char input[100];
    int val;
    long when;
    
    printf ("Enter delay amount in 1/10 seconds: ");
    gets (input);
    val = atoi (input);

    intercept_timer();
    when = timerset (val);
    while (!timeup (when))
        ;
    restore_timer();
    }
#endif



More information about the Comp.lang.c mailing list