[comp.sys.amiga.tech] C vs. Assembly

doc@crash.cts.com (Mitch Evans) (01/09/90)

Howdy!

	I have a few questions that I hope some kind folks out there in
modem land can answer:


	Is C fast enough to write a BBS program in?  I have seen Pro BBS
(the source is public domain), and the author says that it is unacceptably
slow.  Is this because of his style, or because of the language.

	I have been hacking away in Assembly, seeing what I can do with it.
If there is any way to write the sucker in C, I would prefer that -- as it
is easier.  BUT, I will write it in assembly if need be.  Which brings me
to my last question:

	How do I include assembly code in-line in Manx C.  My trials have been
failures.  How do I address the C variables from the assembly portion.  Any
comments or examples would be very much appreciated.  THANKS!
 
 
						Doc


-- 
*****************************************************************************
ARPA:     crash!doc@nosc.mil
INET:     doc@crash.CTS.COM

Just because I'm paranoid doesn't mean everyone isn't out to get me...
*****************************************************************************

mks@cbmvax.commodore.com (Michael Sinz - CATS) (01/09/90)

In article <1125@crash.cts.com> doc@crash.cts.com (Mitch Evans) writes:
>
>Howdy!
>
>	I have a few questions that I hope some kind folks out there in
>modem land can answer:
>
>
>	Is C fast enough to write a BBS program in?  I have seen Pro BBS
>(the source is public domain), and the author says that it is unacceptably
>slow.  Is this because of his style, or because of the language.
>
>	I have been hacking away in Assembly, seeing what I can do with it.
>If there is any way to write the sucker in C, I would prefer that -- as it
>is easier.  BUT, I will write it in assembly if need be.  Which brings me
>to my last question:
>
>	How do I include assembly code in-line in Manx C.  My trials have been
>failures.  How do I address the C variables from the assembly portion.  Any
>comments or examples would be very much appreciated.  THANKS!
> 

For this application, there is no reason why C would be slow at all.  90%
of your time should be MODEM I/O bound and 9.99% would be disk and the rest
is CPU.  (0.01%)  This is a case where the method is more important than
the language/code.  This should even be doable in "slow" languages such as
(close your eyes, 'cause here it comes) BASIC.  (Assuming you can get at
the correct I/O control functions...)

> 
>						Doc
>
>
>-- 
>*****************************************************************************
>ARPA:     crash!doc@nosc.mil
>INET:     doc@crash.CTS.COM
>
>Just because I'm paranoid doesn't mean everyone isn't out to get me...
>*****************************************************************************

(No!  I don't do BASIC...  It was just an extreme case...)

/----------------------------------------------------------------------\
|      /// Michael Sinz -- CATS/Amiga Software Engineer                |
|     ///  PHONE 215-431-9422  UUCP ( uunet | rutgers ) !cbmvax!mks    |
|    ///                                                               |
|\\\///          When people are free to do as they please,            |
| \XX/                they usually imitate each other.                 |
\----------------------------------------------------------------------/

valentin@cbmvax.commodore.com (Valentin Pepelea) (01/11/90)

In article <1125@crash.cts.com> doc@crash.cts.com (Mitch Evans) writes:
>
>	Is C fast enough to write a BBS program in?  I have seen Pro BBS
>(the source is public domain), and the author says that it is unacceptably
>slow.  Is this because of his style, or because of the language.

Yes, it is. However since a BBS program is merely a set of menus which then
execute a set of scripts, it is much preferable to write it in AREXX. A BBS
is only a shell, therefore use a shell scripting language to write one in.

If Pro BBS is too slow, that is because it is badly designed. Attach a terminal
to the serial port and open a CLI shell through AUX:. Is it too slow? of course
not! Now write a compact BBS in the AmigaDOS scripting language. Is it too
slow? Of course not! Now write a fully featured BBS in AREXX. Did it take more
than a week? Of course not!

The neat thing is that if you write a BBS in AREXX, you do not have to write
special code to allow the buyer to reconfigure menus. He can modify the source
code himself.

>	How do I include assembly code in-line in Manx C.  My trials have been
>failures.  How do I address the C variables from the assembly portion.  Any
>comments or examples would be very much appreciated.  THANKS!

It's in the manual. I believe Aztec Inca Manx 5.0 is about to ship, if not
already shipping. There are example programs on the fish disks which use inline
assembler in Manx C. That is considered bad programming style however. You
should write separate modules enirely in assembler instead.

Valentin
-- 
The Goddess of democracy? "The tyrants     Name:    Valentin Pepelea
may distroy a statue,  but they cannot     Phone:   (215) 431-9327
kill a god."                               UseNet:  cbmvax!valentin@uunet.uu.net
             - Ancient Chinese Proverb     Claimer: I not Commodore spokesman be

karl@sugar.hackercorp.com (Karl Lehenbauer) (01/12/90)

In article <1125@crash.cts.com> doc@crash.cts.com (Mitch Evans) writes:
>	I have been hacking away in Assembly, seeing what I can do with it.
>If there is any way to write the sucker in C, I would prefer that -- as it
>is easier.  BUT, I will write it in assembly if need be.  

This has already been well answered, but to speak in general about C versus
assembly, remember from your operating systems class that 5% of
the code is typically responsible for 95% of the execution time.
A decent profiler (like the Tom Rockiki (sp?) one that comes with Manx)
will identify those portions to you, so you can have the higher lines-of-
debugged-code-per-day of C and the performance of assembly where it counts,
if needed.
-- 
-- uunet!sugar!karl	"Hey, you sass that hoopy Ford Prefect?  Now there's a
--			 frood who really knows where his towel is."  -- HGTTG
-- Usenet access: (713) 438-5018

cmcmanis@stpeter.Sun.COM (Chuck McManis) (01/13/90)

In article <1125@crash.cts.com> doc@crash.cts.com (Mitch Evans) writes:
>	Is C fast enough to write a BBS program in?  

Yes.

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@Eng.Sun.COM
These opinions are my own and no one elses, but you knew that didn't you.
"If it didn't have bones in it, it wouldn't be crunchy now would it?!"

david@ms.uky.edu (David Herron -- a slipped disk) (01/15/90)

A really good pattern to follow when writing code -- a pattern esposed
by the designers of C and Unix -- is:  Write in high level code, first
concentrate on getting it to work, later profile-profile-and-more-profile
to find the parts which are executed a lot, optimize *THOSE* areas.

Profiling shows where optimization will do the most good.

I shouldn't think something like a "BBS" would need assembler code.
That job doesn't seem to be a highly time critical thing..
-- 
<- David Herron; an MMDF guy                              <david@ms.uky.edu>
<- ska: David le casse\*'      {rutgers,uunet}!ukma!david, david@UKMA.BITNET
<- 
<- New official address:  attmail!sparsdev!dsh@attunix.att.com