[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Low-level vs. High-level programming



In article <bd6if8$829$5@titan.btinternet.com>,
Kevin Lawton <kepla@btinternet.com> wrote:
 
> Paul Schlyter <pausch@saaf.se> wrote:
> | In article <bd5fsv$qli$5@titan.btinternet.com>,
> | Kevin Lawton <kepla@btinternet.com> wrote:
> |
> ||| I would love to see someone control a port at a non-standard address
> ||| in Basic, Fortran, Cobol, C, C++, etc without using extensions
> ||| beyond the standard language.  The truth is that your statement "If
> ||| you can do it in asm you can do it in any language that is
> ||| sufficiently complete." is not quite true.  Many computer languages
> ||| do have limitations built into them. One good example is reentrant
> ||| code, some can some can not.
> ||
> || Fine, and I would love to oblige you.
> || If you would care to give me the address of the hypothetical port,
> || then I would be happy to furnish you with examples in Basic (yeauch
> || !), Fortran, Cobol
> |
> | It'll be very hard to do this in Fortran and Cobol unless you use
> | some compiler specific extension of the language.  Sorry....
> 
> I can envisage two possible techniques for this when using 'traditional'
> compiled languages like Fortran or Cobol which don't include facilities for
> addressing memory-mapped hardware directly (because in many installations
> they would be running on a virtual machine).
> Either:
>  1)  Link out to a module written in a language which does allow direct
> memory mapped hardware access, like C or Assembler.
 
The standard language doesn't specify how to do that - you'd have to
use some vendor specific extension to accomplish this.
 
> Or:
>  2)  Make use of the inbuilt features of the language in a roundabout
> fashion, noting that a program written in Fortran or Cobol uses a rigidly
> fixed (at compilation time) internal data structure which allows the same
> data areas to be viewed in a variety of different ways. If the location
> (within the memory map) of the program's data storage area can be discovered
> then it is not difficult to calculate an offset from the start of program
> data storage to the required memory-mapped location and access it, provided
> that the location falls within one of the program's accessible memory
> blocks. The leaves only the issue of knowing whereabouts within the (virtual
> or real) machine memory map the program storage lies, and this can be either
> determined at program run time or (preferably) the program loaded at a given
> address prior to execution.
 
Again, that's non-standard use of the language....
 
Let me remind you of your own requirements:
 
# I would love to see someone control a port at a non-standard address
# in Basic, Fortran, Cobol, C, C++, etc without using extensions
# beyond the standard language.
 
If you read the language standards carefully, you'll soon notice that
such use of the language is within the realm of "undefined behaviour".
And language standard purists frown at that.
 
 
If you're going beyond the standard language anyway, why not instead
use some vendor specific extension for poking at machine addresses
or ports?
 
 
 
-- 
----------------------------------------------------------------
Paul Schlyter,  Grev Turegatan 40,  SE-114 38 Stockholm,  SWEDEN
e-mail:  pausch at stockholm dot bostream dot se
WWW:     http://www.stjarnhimlen.se/
         http://home.tiscali.se/pausch/