swap(x,y)

News system news at ism780c.isc.com
Fri Sep 22 07:31:30 AEST 1989


In article <714 at philmtl.philips.ca> ray at philmtl.philips.ca (Raymond Dunn) writes:
>This sounds dangerously like the arguments made by Herman Rubin that 'C'
>should provide facilities to access all the functionality of the machine
>architecture in some direct way.
>
>Since when was that the goal of *any* language other than assemblers?

It used to be the goal.  FORTRAN had statements like:

      IF SENSE SWITCH  -- gave access to switches on the operators console
      SENSE LIGHT      -- to turn on a light on the operators console
      IF OVERFLOW      -- gave access to alu overflow state
      REWIND n         -- generated a single machine instruction
      ABS(X)           -- generated a single machine instruction
      SIGN(A,B)        -- the IBM/704 had a shift instruction which had the
			  effect of copying a sign from one register to
			  another.
      MIN(A,B,...)     -- generated two instructions for each operand
      PAUSE n          -- A single instruction, displayed 'n' in lights
			  on the operator console.  The operator could
			  continue execution by pressing a start button.
			  PAUSE was intended to be used for console debugging

With the exception of REWIND, these 'features' were all put into the language
because they were 'easy' to implement and provided direct access to hardware.
(I wonder if SIGN is used in any FORTRAN program outside a test suite :-)

Since those days, language designers tend to put only generic facilities into
the language.  One reason C exists on so many machines is that it does NOT
have access to the 'features' of a machine.

     Marv Rubinstein



More information about the Comp.lang.c mailing list