[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Low-level vs. High-level programming
- Subject: Re: Low-level vs. High-level programming
- From: "Kevin Lawton" <kepla@btinternet.com>
- Date: Tue, 24 Jun 2003 09:46:42 +0000 (UTC)
- Newsgroups: comp.sys.cbm, comp.sys.apple2, rec.games.video.classic, comp.os.cpm
- Organization: Portmanteau Software Limited
- References: <b3qo6h$5ar$1@barad-dur.nas.com> <bd5fsv$qli$5@titan.btinternet.com> <bd6942$1595$1@merope.saaf.se> <bd6if8$829$5@titan.btinternet.com> <bd901e$22pj$1@merope.saaf.se>
- Xref: archiver1.google.com comp.sys.cbm:59263 comp.sys.apple2:31846 rec.games.video.classic:59380 comp.os.cpm:13534
Paul Schlyter <pausch@saaf.se> wrote:
| 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.
I have used Cobol and/or Fortran on over a dozen different platforms and in
every case I can recall it does not require any extension of the language in
order to link to a module whos source code was written in another language.
Whatever the source language, It is compiled to object code and is then
linked to other object modules to become an executable. Of course, with the
exception of interpreted languages like BASIC or Java. It is thus the
function of the object linker to resolve references between modules. It
requires no extension or mis-use of the source language.
|| 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....
I would suggest that it is called innovation. The language allows this to be
done, no rules are being broken.
| 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?
I honestly know of no versions of either Fortran or Cobol which include such
extensions. The concept of 'poking' is, AFAIK, peculiar to many versions of
BASIC and I would have no wish to bastardise any other language with
BASIC-like extensions. The concept I briefly described involves indexing
down the data storage area of the program a set amount from a known point to
give a reference to a specific location - this technique is often used in,
for example, C. I would contest that if the starting point of the data
storage area and the distance to increment to the require location are both
passed into the program as parameters, then no mis-use or extension of the
language is required. It isn't really very much different from a technique
one might use to, for example, communicate directly with a tape drive buffer
when accessing tapes in a format not known to the machine (so therefore they
cannot be mounted normally).
Kevin.