Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mcgill-vision.UUCP Path: utzoo!linus!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: net.arch Subject: Re: What I miss in micro-processors (fairly long) Message-ID: <142@mcgill-vision.UUCP> Date: Tue, 10-Sep-85 17:38:04 EDT Article-I.D.: mcgill-v.142 Posted: Tue Sep 10 17:38:04 1985 Date-Received: Thu, 12-Sep-85 21:48:10 EDT References: <1517@umcp-cs.UUCP> Organization: McGill University, Montreal Lines: 56 > > ... It would be so nice to end each routine with a CASE (R7),TABLE > > and have control passed to the routine who's address is at TABLE+R7*size. > > How about > > movl table[r7],pc > > or something like that? That's what I thought too. I considered trying something like jmp *_table[r7] but unfortunately the way indexed mode works, that comes out grouped as (*_table)[r7] instead of *(_table[r7]). So I wrote the following routine: .globl _callroutine .globl _table _callroutine: .word 0xffc movl 4(ap),r0 addl3 $2,_table[r0],pc This assembled silently. I wrote a C test driver for it, ran it and boom, illegal instruction. Adb told me pc was just after the addl3 (the instruction there was a "halt"). Put in "calls $0, _abort" there so I could tell, and sure enough, this time it called abort before dying. So the addl3 wasn't functioning as a jump. I look at the architecture handbook: 3.4 GENERAL MODE ADDRESSING FORMATS 3.4.1 Register Mode [...]. PC may not be used in register mode addressing. If PC is read, the value read is UNPREDICTABLE. If PC is written, the next instruction executed or the next operand specified is UNPREDICTABLE. [...] So I guess we can't do that. We seem to be reduced to movl _table[r7],r0 jmp (calls, etc) (r0) which I haven't tried, but I feel certain would work. Ugh. -- der Mouse {ihnp4,decvax,akgua,etc}!utcsri!mcgill-vision!mouse philabs!micomvax!musocs!mcgill-vision!mouse Hacker: One responsible for destroying / Wizard: One responsible for recovering it afterward