Path: utzoo!attcan!uunet!portal!cup.portal.com!bcase From: bcase@cup.portal.com (Brian bcase Case) Newsgroups: comp.arch Subject: Re: A simple question on RISC Message-ID: <11561@cup.portal.com> Date: 20 Nov 88 21:24:17 GMT References: <6544@xanth.cs.odu.edu> <75577@sun.uucp> <1618@imagine.PAWL.RPI.EDU> <419@augean.OZ> <392@ksr.UUCP> <7723@aw.sei.cmu.edu> Organization: The Portal System (TM) Lines: 33 Concerning the ACB (VAX's add-compare-branch instruction) >Secondly, the instruction is not restartable. ?????!!!!! It had better be! Otherwise, what happens when a clock interrupt comes along! >As an aside, the instruction doesn't even work. It implements an add, >compare and branch at the bottom of the loop. The only language that >defines a FOR loop that is always executed at least once is Fortran, >and it requires the sign of the step to be known at compile time. No, there is an optimization called loop rotation that allows test-at- the-top loops (whiles and fors in C, e.g.) to be converted to test-at- the-bottom. This is useful because it eliminates one jump instruction. Of course, the VAX's ACB instruction is a poor match for loop rotation of C loops because you want to test the condition *without* doing the add the first time, but this can be overcome (Don't misunderstand, I do not think this is a good instruction; I'm just saying that it isn't useless). >For all other languages, you have to hand code a compare at the top of the >loop anyway, so it's pretty pointless to code it again at the bottom. Yes, this is one way to overcome the fact that the ACB first adds then tests. This is still worth it because it saves one (untaken) jump on each loop iteration. A compiler can do this (or at least I could have made one of my C compilers do this without much trouble at all). >In other words, there is no >programming language construct to which this instruction corresponds. Yeah, it is a stupid instruction.