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 > Pascal Misc > Re: Translating...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 20 Topic 708 of 811
Post > Topic >>

Re: Translating an embedded C algorithm

by CBFalconer <cbfalconer@[EMAIL PROTECTED] > Jan 18, 2007 at 04:49 PM

Richard Engebretson wrote:
> Femme Verbeek wrote:
> 
>> I answered your question already a few days ago in
>> Comp.lang.pascal.borland Complete with translated and tested
>> code attached.
>>
>> This is what you get if you multipost your question.
> 
> Yes, that is what borland pascal looks like. But it is not what
> embedded pascal necessarily looks like. (Even though the
> commercial version I saw was modeled after borland.)
> 
> The UCSD group is worth the effort. They have a large number of
> programs already available. CB Falconer was a pioneer in
> (essentially) embedded pascal.
> 
> If you find a borland pascal compiler for embedded systems,
> please let me know. (Yes, tp3 worked on CP/M. just to avoid
> another round)

Unfortunately I lost most of my Pascal system in a disk crash some
years ago, otherwise it would have been updated for general use. 
The remains, including a compiler that will run under MsDos (but
not generate MsDos code) and a binary only system and manuals is
available on my pages.  The basic compiler generates a text file of
Pcode instructions, and requires a code generator to advance to
machine code for a particular machine.  One code generator
generates PCD binaries, which can be executed by an interpreter,
and is highly ****table.  This results in very compact code, some
slowdown, and is well suited to embedded machinery.

The compiler is basically ISO standard, level 0, without
procedure/function parameters or goto out of functions.  The manual
details all this.

At one point I did publish the missing pieces, but I have never
found them again.  They may be on various ancient 5" floppies.  I
had converted them all about 8 years ago at a PPOE, but some schlub
lifted the entire set of floppies.

As far as the original enquiry is concerned, a better algorithm
would be to use the equation directly with integer arithmetic. 
This requires a little algebra to substitute for the variable, and
avoid any overflows.  This is fairly easily done for input in the
range 1 to 2.5, by using X = xin * 10 - 10 and a little elementary
algebra.  The result can be scaled to function on 16 bit integer
machines.  You could use 2 calls to the convert function, and use
the third input sig. digit for linear interpolation.  A C version
is:

/* Input range 10 <= v <= 25 */
int convert(int v) {
   v -= 10;
   return (((v * 136 - 13762)/10 * v) + 13732) / 100;
} /* convert */

or (untested)

FUNCTION convert(v : integer) : integer;

   BEGIN (* convert *)
   v := v - 10;
   convert := ((v * 136 - 13762) DIV 10 * v) + 13732) DIV 100;
   END; (* convert *)

I believe these are immune to overflow within the input range. 
Note that Pascal specifically separates integer and real division
operators.

The other attitude is a generic interpolation mechanism, which
requires a definition of the table interval available.  There are
various interpolation schemes extant, but the simplest is linear
interpolation.  Other methods involve matching various derivatives
at the table points.  Look up such words as spline.

Look about: <http://cbfalconer.home.att.net/download/>

To the OP (Talulah) - PDF files are a great pain.  Text is much
more easily incor****ated into source as comments, etc., occupy less
space, and can be included in usenet posts.  Just keep line lengths
under 72 chars.

-- 
 Sending unsolicited commercial e-mail to
     cbfalconer at maineline dot net
 incurs a fee of 500 USD per message, and
 acknowledges the legality of this contract.
 




 20 Posts in Topic:
Translating an embedded C algorithm
"Talulah" <p  2007-01-15 06:35:25 
Re: Translating an embedded C algorithm
"Richard Engebretson  2007-01-16 02:53:13 
Re: Translating an embedded C algorithm
Eli Gottlieb <eligottl  2007-01-17 10:01:22 
Re: Translating an embedded C algorithm
"Talulah" <p  2007-01-18 01:09:20 
Re: Translating an embedded C algorithm
"Richard Engebretson  2007-01-18 03:06:48 
Re: Translating an embedded C algorithm
"Talulah" <p  2007-01-18 05:33:09 
Re: Translating an embedded C algorithm
Femme Verbeek <fv@[EMA  2007-01-18 14:39:52 
Re: Translating an embedded C algorithm
"Richard Engebretson  2007-01-18 08:52:16 
Re: Translating an embedded C algorithm
"Richard Engebretson  2007-01-18 09:31:54 
Re: Translating an embedded C algorithm
CBFalconer <cbfalconer  2007-01-18 16:49:45 
Re: Translating an embedded C algorithm
"Talulah" <p  2007-01-19 03:50:21 
Re: Translating an embedded C algorithm
Jonas Maebe <Jonas.Mae  2007-01-19 14:32:45 
Re: Translating an embedded C algorithm
Marco van de Voort <ma  2007-01-19 15:25:10 
P-Code, JVM and IL (was: Translating an embedded C algorithm)
"Chris Burrows"  2007-01-20 10:55:47 
Re: Translating an embedded C algorithm
CBFalconer <cbfalconer  2007-01-19 17:33:00 
Re: Translating an embedded C algorithm
CBFalconer <cbfalconer  2007-01-19 17:15:56 
Re: Translating an embedded C algorithm
Waldek Hebisch <hebisc  2007-01-19 21:53:51 
Re: Translating an embedded C algorithm
"Richard Engebretson  2007-01-20 08:12:24 
Re: Translating an embedded C algorithm
"Talulah" <p  2007-01-22 01:45:19 
Re: Translating an embedded C algorithm
"Richard Engebretson  2007-01-23 04:01:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri Jul 25 18:53:27 CDT 2008.