Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly 370 > Fast and Safe C...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 39 of 39 Topic 292 of 328
Post > Topic >>

Fast and Safe C Strings: User friendly C macros to Declare and use

by Clem Clarke <oscarptyltd@[EMAIL PROTECTED] > Apr 13, 2007 at 03:46 PM

Some 20 years ago, it became clear that C strings were not as safe, nor
as fast, as strings in PL/I,  Assembler or Pascal.

The primary reasons are that one needs to find the current length of a
string before or during a copy process - this is very time consuming.

Secondly, there is no way of determining the maximum length of a string,
and therefore when copying to a string, it is easy to over-write
adjacent storage with often disastrous consequences, including the
deliberate introduction of viruses.


Decades have passed and the C string problem continues.  Buffer
over-runs are just part of the story, and the bugs that can be
introduced - the safety problem is still with us all and it has come
back to bite all of us on the lower part of our anatomy, over and over
again.

I have spent some years studying this problem and have developed some
User friendly C macros that solve the problem.

These solutions do enhance the speed and safety aspects of all "C"
programs - these benefits of speed and safety can be passed on to your
users.

The main benefits are:

    * Increased speed (up to 20 times for some string handling)
    * More reliability (strings cannot overwrite adjacent storage)
    * Easier coding and debugging (consistent set of macros)
    * Easier external variables

Here is a very short example:

   dcl (op,charvar,253," ",ext);   // Variable 'op' is defined
//            as an External variable - Max length of  253 characters.
   dcl (symbolic,charfixed,8,"        ",ext);  // Fixed length of 8

   cpylit(op, "This is a 30 character string ");
   cat(op,op);     /* Concatenate variable op with it self.  Now 60
                        characters */

   cpy(symbolic,op);  /* Truncates it to 8 characters */

   cpy(op,symbolic);    /* Copy it back.   */

I invite you download the macros and code at
http://members.ozemail.com.au/~oscarptyltd/fastsafe.html
where a fuller
discussion can be found.



Clement Clarke



  ,-._|\  Clement V. Clarke - Author Jol, EASYPANEL, OSCAR, 370TO486
/  Oz  \ Web: www.ozemail.com.au/~oscarptyltd
\_,--.x/ 38 Kings Park Road, West Perth, AUSTRALIA, 6005.
       v  Tel (61)-8-9324-1119, Mob 0401-054-155.
 




 39 Posts in Topic:
Cycles per ASM instruction
"Roded" <rod  2007-02-13 06:46:45 
Re: Cycles per ASM instruction
"Robert" <rj  2007-02-13 11:52:48 
Re: Cycles per ASM instruction
"Petr" <plav  2007-02-14 00:28:50 
Re: Cycles per ASM instruction
hancock4@[EMAIL PROTECTED  2007-02-20 13:10:07 
Re: Cycles per ASM instruction
"Sven Pran" <  2007-02-20 23:18:42 
Re: Cycles per ASM instruction
glen herrmannsfeldt <g  2007-02-20 16:25:05 
Re: Cycles per ASM instruction
glen herrmannsfeldt <g  2007-02-20 16:22:21 
Re: Cycles per ASM instruction
Arthur T. <arthur@[EMA  2007-02-21 00:32:41 
Re: Cycles per ASM instruction
"John W. Kennedy&quo  2007-02-22 01:53:04 
Re: Cycles per ASM instruction
glen herrmannsfeldt <g  2007-02-23 12:49:27 
Re: Cycles per ASM instruction
"John W. Kennedy&quo  2007-02-23 23:44:37 
Re: Cycles per ASM instruction
"robertwessel2@[EMAI  2007-02-20 21:05:42 
Re: Cycles per ASM instruction
hancock4@[EMAIL PROTECTED  2007-02-21 13:19:55 
Re: Cycles per ASM instruction
Steve Myers <noone@[EM  2007-02-21 17:39:31 
Re: Cycles per ASM instruction
"Gerard Schildberger  2007-02-21 17:25:57 
Re: Cycles per ASM instruction
Steve Myers <noone@[EM  2007-02-21 21:54:00 
Re: Cycles per ASM instruction
Arthur T. <arthur@[EMA  2007-02-21 21:13:23 
Re: Cycles per ASM instruction
Sparky Spartacus <Spar  2007-02-26 05:15:10 
Re: Cycles per ASM instruction
"Sven Pran" <  2007-02-26 12:11:29 
Re: Cycles per ASM instruction
"John W. Kennedy&quo  2007-02-26 22:45:46 
Re: Cycles per ASM instruction
Michael Phillips <mich  2007-02-27 16:23:46 
Re: Cycles per ASM instruction
"John W. Kennedy&quo  2007-02-22 01:57:17 
Re: Cycles per ASM instruction
Jerry Peters <jerry@[E  2007-02-22 21:29:47 
Re: Cycles per ASM instruction
"Sven Pran" <  2007-02-22 23:27:47 
Re: Cycles per ASM instruction
Sparky Spartacus <Spar  2007-02-26 05:17:32 
Re: Cycles per ASM instruction
Sparky Spartacus <Spar  2007-02-26 05:20:31 
Re: Cycles per ASM instruction
Jerry Peters <jerry@[E  2007-02-26 21:38:40 
Re: Cycles per ASM instruction
Michael Phillips <mich  2007-02-27 16:16:30 
Re: Cycles per ASM instruction
Jerry Peters <jerry@[E  2007-02-27 21:49:29 
Re: Cycles per ASM instruction
Anne & Lynn Wheeler &  2007-02-21 19:47:44 
Re: Cycles per ASM instruction
Anne & Lynn Wheeler &  2007-02-21 20:30:29 
Re: Cycles per ASM instruction
hancock4@[EMAIL PROTECTED  2007-02-22 10:58:18 
Re: Cycles per ASM instruction
Anne & Lynn Wheeler &  2007-02-23 09:21:44 
Re: Cycles per ASM instruction
peter.ludemann@[EMAIL PRO  2007-02-25 10:46:20 
Re: Cycles per ASM instruction
Anne & Lynn Wheeler &  2007-02-26 09:44:55 
Re: Cycles per ASM instruction
glen herrmannsfeldt <g  2007-02-26 22:48:09 
Re: Cycles per ASM instruction
"robertwessel2@[EMAI  2007-02-26 23:13:46 
Re: Cycles per ASM instruction
Anne & Lynn Wheeler &  2007-02-27 08:34:51 
Fast and Safe C Strings: User friendly C macros to Declare and
Clem Clarke <oscarptyl  2007-04-13 15:46:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 20:34:35 CDT 2008.