Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!im4u!oakhill!davet From: davet@oakhill.UUCP Newsgroups: comp.sys.m68k Subject: Re: move sr/move ccr: crock Message-ID: <827@oakhill.UUCP> Date: Fri, 23-Jan-87 05:47:37 EST Article-I.D.: oakhill.827 Posted: Fri Jan 23 05:47:37 1987 Date-Received: Sat, 24-Jan-87 06:43:41 EST References: <809@imagen.UUCP> Reply-To: davet@oakhill.UUCP (Dave Trissel) Organization: Motorola Inc. Austin, Tx Lines: 30 Keywords: logic? In article <809@imagen.UUCP> geof@imagen.UUCP (Geoffrey Cooper) writes: >In the 68000, the move from sr instruction is not a privileged >instruction. In the 68010 and 68020 a new instruction exists, >move from ccr, which just moves the condition codes out of the >SR, the other bits being zero. In the 68010 and 68020 move from >SR is a privileged instruction. This was done to support virtual machine capability. User code must not be allowed to examine any privileged resource without control passing to the supervisor first for validation, substitution replacement or denial. >This appears to be a crock. It means that simple assembly >language routines must be different for 68010 and 68020. It >significantly affects the portability of code between them >(especially when compilers like to generate code to save the >condition codes on the stack). I was not happy myself with the decision, but there are ways around it. First, an O.S. can simply patch the move sr to a move ccr by setting one bit on in the instruction. That way, you only have a penalty the first time the move sr is hit in memory. Thereafter it runs at raw CPU speed. Another solution is to have code in the privilege exception handler which dynamically builds a move ccr equivalent followed by a jump back into the program on the stack which is RTEd to. This handles the rare case where a move sr is in rom and cannot be altered. The routine is small and is published in a Motorola Technical document. -- Dave Trissel Motorola, Austin. {seismo,ihnp4}!ut-sally!im4u!oakhill!davet