Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!rochester!crowl From: crowl@rochester.UUCP (Lawrence Crowl) Newsgroups: net.arch Subject: Re: Addressing modes Message-ID: <15403@rochester.UUCP> Date: Tue, 18-Feb-86 18:02:14 EST Article-I.D.: rocheste.15403 Posted: Tue Feb 18 18:02:14 1986 Date-Received: Wed, 19-Feb-86 20:40:06 EST References: <137@hhb.UUCP> <3686@utah-cs.UUCP> Reply-To: crowl@rochester.UUCP (Lawrence Crowl) Organization: U. of Rochester, CS Dept. Lines: 48 In article <3686@utah-cs.UUCP> b-davis@utah-cs.UUCP (Brad Davis) writes: >In article <137@hhb.UUCP> mlopes@hhb.UUCP (Marco Lopes) writes: >>Immediate addressing would be simulated by allocating a memory >>location for the immediate value, and loading its address into a register. > >How do you load the address of the memory location into a register without >using an immediate addressing mode? Any practical architecture must have a mechanism for loading a constant value into a register or using an absolute address. With constant addressing the value can be placed in a memory location and then loaded with an absolute addressing mode. If constant value loading is present, the value can be loaded and then used indirectly to achieve absolute addressing. However, it apears both authors assume no constant loading facility at all. So, in response, I present a method to obtain constants without such a facility. To get the constant 10, (mixture of C and Pascal) r1 := r1 - r1 ; { r1 == 0 } r1 := ~r1 ; { r1 == -1, assuming two's complement } r2 := r2 - r2 ; { r2 == 0 } r2 := r2 - r1 ; { r2 == 1 } { from here the algorithm is constant and register dependant } r3 := r3 - r3 ; { r3 == 0 } r3 := r3 + r2 ; { r3 == 1 } r3 := r3 >> r2 ; { r3 == 2 } r3 := r3 >> r2 ; { r3 == 4 } r3 := r3 + r2 ; { r3 == 5 } r3 := r3 >> r2 ; { r3 == 10 } The method can be extended in the obvious manner to generate arbitrary constants. I cannot recommend an architecture relying on this method. I suggest looking very seriously at the addressing mode provided by Patterson for the RISC I and RISC II chips. The form is value in register + constant = effective address This allows absolute addressing with a 0 valued register, register indirect with a 0 valued constant, and register displaced when both are non-zero. This mode is very usefull for accessing variables off the stack frame (you will need one even if you rely on registers). In addition, it is very useful for accessing pointer based records and such. -- Lawrence Crowl 716-275-5766 University of Rochester Computer Science Department ...!{allegra,decvax,seismo}!rochester!crowl Rochester, New York, 14627