C vs BASIC (Was: Pow

 BBS: Inland Empire Archive
Date: 04-24-92 (04:24)             Number: 198
From: DARYL POSNETT                Refer#: 32
  To: MATT HART                     Recvd: NO  
Subj: C vs BASIC (Was: Pow           Conf: (2) Quik_Bas
MH> DP> And the argument still exists, There are still
MH> DP> applications that can be
MH> DP> written in C without ASM that cannot be written in BASIC without ASM.

MH>If you consider SPEED an essential part of that application, then this is
MH>true - C can do some things almost as fast as assembly that
MH>BASIC without assembly add-ins CAN DO - but slowly.

Matt, this is really a dead issue.  While you are right, that is if you
are saying that BASIC with ASM is as fast as C with ASM and sometimes
faster than C alone.  That is not at all what I was referring to.  There
are some classes of applications, those that use interrupts mostly, that
simply cannot be written in BASIC without ASM, but can be written in C
alone.  The C compiler (mine anyway) is pretty good about generating
code for interrupt handlers and the speed is usually very comparable.

A while back I was playing with multitaskers, not DOS multitaskers, but
rather a multitasker that would be embedded into an application to allow
your application to run several tasks concurrently.

Very useful for instance in industrial control software where you don't
want the control loop to stop just because the user is changing a
setpoint.  I had this problem once, and rather than implementing a
multitasker I set up a rather complex set of state conditions that
allowed the input routines to go and run the rest of the program in
between keystrokes yet maintain a windowed graphic enviroment for the

Anyway, This is a straigtfoward procedure in C.  I attempted to
duplicate my C efforts in BASIC w/ASM and ran into a brick wall.

You can't just trap int 8, point the stack,ip, and cs at the next task
and go. Basic doesn't like this at all and the machine locks hard.

Here is the scenario, perhaps you or one of other gurus could show me
how to make this work


        ' Each task is either a GOSUB subroutine or a SUB program
        ' whatever can be made to work.
        ForeGround.Task:                'do anything here, including dos
              FOR X% = 1 to 1000
                Print "Forground Task"
                Print "BG:"; Y&
              NEXT X%

        BackGround.Task:                ' No non-reentrant functions
                                        ' should be used here. ie: DOS
                                        ' functions of any kind, or any
                                        ' BASIC functions that call DOS

                WHILE Y& < 1000000
                   Y& = Y& + 1

        ' To start these tasks you need to call the ASM tasker
        CALL MultiTask

in ASM:
        implement an ASM procedure to initialize the scheduler, and a
        replacement for int 8 or int 1c to time slice the two BASIC
        tasks defined above.

There is a simple and elegent solution this problem that can be
implemented in C alone and it will use standard C functions as tasks (no
need to use labels).  Please don't respond with "oh yeah, well QB has
the ON COM statement".  I know what QB has, and I know that a lot of
the shortcut toys like DRAW and ON COM usually have to be replaced with
real code in any production programming.  And PDQ isn't always a
solution either.  PDQ does not support all of the functions in BCOMM and
some are harder to use.  So in some instances PDQ takes away some of the
reasons to use BASIC in the first place.

Instead, let's discuss THIS problem from a QuickBASIC point of view.
I am really interested in the insights of the guys who really know the
QB internals.

So if Dave Cleary can put away his broadsword long enough for me to grab
my universal translator, perhaps we can have some interesting objective
QB discussion here.

 X SLMR 2.0 X This message is guaranteed to be only 10% opinion free.

--- Maximus 2.00
 * Origin: Inland Empire Archive (1:346/10)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET