Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!utah-cs!shebs From: shebs@utah-cs.UUCP (Stanley Shebs) Newsgroups: comp.lang.misc Subject: Re: Assembly language and Speed... Message-ID: <4114@utah-cs.UUCP> Date: Fri, 19-Dec-86 13:13:30 EST Article-I.D.: utah-cs.4114 Posted: Fri Dec 19 13:13:30 1986 Date-Received: Sat, 20-Dec-86 01:46:46 EST References: <1233@navajo.STANFORD.EDU> Reply-To: shebs@utah-cs.UUCP (Stanley Shebs) Organization: PASS Research Group Lines: 50 Keywords: its sooo frustrating... (when you use Pascal) In article <1233@navajo.STANFORD.EDU> billw@navajo.STANFORD.EDU (William E. Westfield) writes: >But where HLL's fall down is when you >start to do function and procedure calls. And of course you should do >a lot of those in a well structured program. Can you say "interprocedural analysis"? A really hot compiler would flush every subroutine call that it possibly could. Disadvantages are that you must have both the source code for caller and callee available to mess with, and the resulting code is harder to debug at the object level (no stack frames to look at). >An assembly language programmer has the option of writing "fast" >subroutines that pass arguments in registers and don't bother setting >up stack frames, and so on. Some language implementations (for instance Portable Standard Lisp) *do* pass arguments in registers. But of course since a function may be called before it is defined, the calling protocol has to be more conservative and save registers in non-tail-recursive cases. >... One of the things you >have to do is push and pop tokens from a stack. Great. Almost every >popular processor has instructions that do PUSH and POP in hardware. >[... various hardware features] >So what happens when you try to do this in PASCAL, huh? >Well, you write functions called PUSH and POP, and your arguments get >put on a stack frame on the hardware stack, and you do a call >instruction which puts the return addresses on a stack and goes off to >code that probably fetches the value of stack pointer from memory and >puts it back, and does a return instruction that fetches the return >address back, and then you clean up the stack frame and continue on. The first right answer is "don't use Pascal, use a high-level language". The second right answer has already been mentioned by others, and that is to "fix the compiler". You need a sufficiently high-level language (like Lisp) so that you can write the push and pop operations as normal functions. For prototyping, you can use a dumb implementation, then when it's time to optimize, you hack the compiler to opencode the function calls into an appropriate sequence of instructions. Of course, hacking the compiler may not be easy! On the other hand, some compilers (such as the PSL and PCLS compilers) are highly declarative, and it is not unusually hard to add optimizations. At the moment, you still have to know quite a bit about how the system works internally, and we've been working on ways to make optimizations even easier to add/modify. Ultimately, we want a compiler that is completely open and accessible to programmers. >BillW, writing small, fast, programs, in assembler, and happy. stan shebs (orion.utah.edu)