Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!eru!hagbard!sunic!news.funet.fi!hydra!hylka!pirinen From: pirinen@cc.helsinki.fi Newsgroups: comp.society.futures Subject: Re: C's sins of commission (was: (pssst...fortran?)) Summary: Pointers are not sequential; array indexing is fast on Intel Keywords: C, pointer, array, index, Intel Message-ID: <3113.26f56d95@cc.helsinki.fi> Date: 18 Sep 90 00:43:01 GMT References: <1990Sep14.160429.2732@abcfd20.larc.nasa.gov> <3643@vexpert.dbai.tuwien.ac.at> Organization: University of Helsinki Lines: 26 From article <1990Sep14.160429.2732@abcfd20.larc.nasa.gov>, by jcburt@ipsun.larc.nasa.gov (John Burton): > Sorry, but it IS more expensive (execution time wise) to sequentially > index through an array, than it is to simply increment a pointer... > Array indexing is better for randomlly accessing the array... > just because random access is better for somethings, should we > totally do away with sequential access? come on, be fair... Pointer derefencing, as such, is not sequential, it is in fact more random than array indexing (can you say "aliasing"?). A loop over an array that uses indexing can be compiled using pointer incrementing -- it's a standard compiler technique. In article <3643@vexpert.dbai.tuwien.ac.at>, mst@vexpert.dbai.tuwien.ac.at (Markus Stumptner) writes: > [C compiler manual for MIPS RISC chip-based computer says:] > - Do not use pointer incrementing for sequential array access This doesn't surprise me a bit: modern chips have been designed to execute high-level languages effectively, array indexing being a case in point. Intel 80286, 386, and i486 data sheets say that all indirect memory addressing modes take a equal number of clocks, including scaled indexed addressing. This eliminates the supposed advantage of pointer incrementing in most cases, if the compiler didn't already. Pekka P. Pirinen University of Helsinki pirinen@cc.helsinki.fi pirinen@finuh.bitnet ..!mcvax!cc.helsinki.fi!pirinen Read my Lisp: no new syntax! -nil