[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Missing clobbered register in gemlib



Hello Vincent,
On 18 Dec 2009 at 22:13, Vincent Rivière wrote:
> 
> GEM/assembler specialists should have a look at the following code from the 
> GemLib:
> 
> In gemlib/gem_aesP.h:
> static inline void
> _aes_trap (AESPB * aespb)
> {
> 	__asm__ volatile (
> 		"move.l	%0,d1\n\t"	/* &aespb */
> 		"move.w	#200,d0\n\t"
> 		"trap	#2"
> 		:
> 		: "a"(aespb)
> 		: "d0","d1","a0","memory" /* <--- Clobber List here */
> 	);
> }
> 
> The Clobber List assumes that a trap #2 for AES does not change the value of
> a2 and other registers. Is this true ?

In two different Atari developers' newsletters, it is stated that registers D0-
D2 & A0-A2 may be destroyed by a trap call.  Also, the Lattice C AES interface 
routine specifically saves and restores A2/D2 across the trap (A0,A1,D0,D1 are 
always treated as 'volatile' across subroutine calls, so the interface routine 
is allowed to clobber them via the trap).

> One could add other registers to the clobber list (at least a1, maybe d2 and
> a2) to see what happens. This could prevent some optimization to occur 
> (very, very little), but in no case it could introduce bugs.
> 
> Similar stuff in gemlib/gem_vdiP.h:
> _vdi_trap_esc
> _vdi_trap_00
> 

I think it would be a good idea to make the clobber list A0-A2, D0-D2.

Roger Burrows