home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!sschaem
- From: sschaem@teleport.com (Stephan Schaem)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: 8 Jan 1996 10:33:22 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4cqrti$f6u@maureen.teleport.com>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <jasonb.820051107@cs.uwa.edu.au> <4c9i2l$h3i@sunsystem5.informatik.tu-muenchen.de> <4ck47h$g07@maureen.teleport.com> <19960106.4EE928.CF59@sisyphus.demon.co.uk> <4cokkg$415@maureen.teleport.com> <19960107.533250.14585@sisyphus.demon.co.uk>
- NNTP-Posting-Host: kelly.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Dave.Sparks@sisyphus.demon.co.uk wrote:
- : >>>>> "SS" == Stephan Schaem <sschaem@teleport.com> writes:
-
- : SS> Dave.Sparks@sisyphus.demon.co.uk wrote:
- : >> >>>>> "SS" == Stephan Schaem <sschaem@teleport.com> writes:
-
- : >> SS> I cant see how people can write code without knowing what data or
- : >> SS> type they manipulate...
-
- : >> Real-world programmers do it all the time. If you ever want to
-
- : SS> So you do math operation without knowing that your destination need
- : SS> to be a float or a 2 byte int?
-
- : Yes. This is a trivial example of polymorphism.
-
- polymorphism?
-
- int a,b,c;
-
- ...
- a = b /c;
- a *= result;
- ...
- struct.float = a;
-
- I dunno , I just find it puzzling to declar variable without giving
- a care of what its usage will be. You programing practice is VERY unwise...
-
- : >> join us, you'll have to learn to do it too. One of many examples
-
- : SS> Real world = commercial? I'm deep in it, thanks
-
- : Is your employer happy that you're so out of touch with modern
- : programming practices?
-
- I actually think that they like that I know what I'm doing VS
- programing on asuption (polymorphism?)
-
- : >> is the ANSI C definition of the 'clock' function: the value returned
- : >> is of type 'clock_t', which is defined in a system-dependent header
- : >> file. SAS/C defines 'clock_t' to be an unsigned 32-bit value, but
- : >> other implementations can (and do) define it to be signed or even
- : >> 64-bit floating-point. Since the C arithmetic operations (add,
- : >> subtract, multiply, divide) are overloaded (can be used on values of
- : >> ...
-
- : SS> ANSI for good reason decided on a minimal size of all its basic
- : SS> type. This to help you the program choose the right type for your
- : SS> need.
-
- : SS> The only way you dont care is if you typedef all the ANSI type.
-
- : SS> So you created a structure to hold clock value with ulong? now
- : SS> recompile this on the system using a clock size of 64bit... where did
- : SS> the upper 32bit goes... you know have code that is broken.
-
- : I know better than to declare a value as unsigned long when I'm
- : going to assign a clock_t to it. And if I did, I'd lose the
- : fractional part of a floating-point clock_t, not the upper 32 bits.
-
- You said yourself after peeking at the .h that clock_t was a ulong.
- But you know better then not using a ulong... ? Should I assume
- you alway use the largest data type available,double ? (What a waist)
- And you mean you would loose the fractional part of clock_t if you
- used ulong , not the upper 32bits? This make absolutly no sense since
- we are talking about interger types.(BTW copy 0x00000001 into a 2byte int,
- you will loose the upper 16bit... )
-
- If the header file was programmed correctly it would not use ANSI data
- type directly.... Anyway, you must know that since you are the cream of
- the real world programmer with polymorhism programming.
-
- : SS> ex of something that wont break with a recompile:
-
- : SS> typedef short point2d
-
- : SS> struct RECTANGLE { point2d x1; point2d y1; point2d x2;
- : SS> point2d y2; } rectangle, *rectangle;
-
- : SS> then you declare you variable using rectangle, or point2d
-
- : SS> Then if later you find out in your design you need to use long (Or
- : SS> create another set of include for another platform), you can just
- : SS> chnage point2d... I rarely see that done... anyway
-
- : So you don't know that many fields in the UNIX header files have
- : changed from 16 bits to 32 (for example the user-id and group-id
- : in the directory-handling structures)? You have led a sheltered life.
-
- I did live a sheltered life? Is this a call for sympathy, for all the
- hardhacks you went trought??
-
- Anyway:
-
- Where those field public?
-
- ex: if those field where defined with ushort with no mention of extension
- people could have wrote function to set those field using ushort has
- function parameter... now with the new header file you need to go back
- and modify your functions prototyping otherwise they break.
-
- : SS> ...
-
- : SS> about loop counter size... should I use ulong and forget about it,
- : SS> or use ushort to be sure of optimal speed on my target CPU and
- : SS> remember my declaration type in case I want to use it for a loop
- : SS> count bigger then 65535?. (this result in a sub/bcc vs dbcc encoding
- : SS> on 680x0... )
-
- : target CPU? How quaint ...
-
- But target CPU is something that come up often in the real world of
- programming... oh, forgot you think you are part of it.
- C compiler cannot change and optimize the variable type at compile
- time, the compiler take your word for it that you done a wise choice.
- Use float everywhere for all I care, and see how your code compile
- on a 68000.
-
- : And why use subq/bcc rather than dbcc, if speed is all-important?
- : It's easy enough to decrement and check the upper word whenever
- : the lower word has just expired, so why assume that a compiler
- : will generate the slower code? In any case, if you're using the
- : loop counter to index an array, the compiler will probably have
- : transformed the loop counter and be subtracting the size of an
- : array element, to avoid the use of a (slow) multiply instruction in the
- : body of the loop; it couldn't use dbcc anyway. You don't get
- : optimal speed by optimizing the instructions, but by optimizing
- : the algorithm.
-
- A 32bit counter need to use subq/bcc or a nested swap/dbcc/swap/dbcc.
- If you know you never need >65535 iteration why use a 32bit counter?
- Anyway, if you use an array index in your loop its probly fine on
- some risc CPU that doesn't support 'complex' addressing modes, but
- on a 680x0 I suggest auto incrementing your array pointer.
-
- The way you get optimal speed is optimizing the optimal algorithim.
- If you stop at the algorithm you loose... Optimizing at this stage
- will give an exponential result on the work you done on the algorithm.
- And usually this stage is done in assembler.
-
- Stephan
-