Subject: Re: m68k gas optimisation
To: ITOH Yasufumi <itohy@netbsd.org>
From: Gregory McGarry <g.mcgarry@ieee.org>
List: tech-toolchain
Date: 02/08/2002 20:23:52
ITOH Yasufumi wrote:

> > #define _RELOC(var, ar)         \
> >         lea     var,ar;         \
> >         addl    %a5,ar
> > #define ASRELOC(var, ar)        _RELOC(_ASM_LABEL(var), ar)
> 
> #define _RELOC(var, ar)         \
>         movel   #var,ar;        \
>         addl    %a5,ar
> 
> should work around the problem.

Hmm.  That didn't work.  The following hack works on both toolchains.
Tidy this up and go with it?

	-- Gregory McGarry <g.mcgarry@ieee.org>


*** locore.s.orig	Wed Feb  6 20:26:15 2002
--- locore.s	Thu Feb  7 20:33:31 2002
***************
*** 102,107 ****
--- 102,114 ----
  #define	ASRELOC(var, ar)	_RELOC(_ASM_LABEL(var), ar)
  
  /*
+  * Macro to force jmp instructions to non PC-relative
+  */
+ #define JMP(label)		\
+ 	.word	0x4ef9;		\
+ 	.long	label
+ 
+ /*
   * Final bits of grunt work required to reboot the system.  The MMU
   * must be disabled when this is invoked.
   */
***************
*** 412,419 ****
--- 419,435 ----
  	movl	%d1,INTIOBASE+MMUBASE+MMUSSTP | load in sysseg table register
  Lstploaddone:
  	lea	MAXADDR,%a2		| PA of last RAM page
+ #if 0
  	ASRELOC(Lhighcode, %a1)		| addr of high code
  	ASRELOC(Lehighcode, %a3)	| end addr
+ #else
+ 	.word	0x43f9
+ 	.long	Lhighcode
+ 	addl	%a5, %a1
+ 	.word	0x47f9
+ 	.long	Lehighcode
+ 	addl	%a5, %a3
+ #endif
  Lcodecopy:
  	movw	%a1@+,%a2@+		| copy a word
  	cmpl	%a3,%a1			| done yet?
***************
*** 453,470 ****
  	.long	0x4e7b0003		| movc %d0,%tc
  	movl	#0x80008000,%d0
  	movc	%d0,%cacr		| turn on both caches
! 	jmp	Lenab1
  Lmotommu2:
  	movl	#MMU_IEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD
  					| enable 68881 and i-cache
  	RELOC(prototc, %a2)
  	movl	#0x82c0aa00,%a2@	| value to load TC with
  	pmove	%a2@,%tc		| load it
! 	jmp	Lenab1
  Lhpmmu3:
  	movl	#0,INTIOBASE+MMUBASE+MMUCMD		| clear external cache
  	movl	#MMU_ENAB,INTIOBASE+MMUBASE+MMUCMD	| turn on MMU
! 	jmp	Lenab1					| jmp to mapped code
  Lehighcode:
  
  	/*
--- 469,486 ----
  	.long	0x4e7b0003		| movc %d0,%tc
  	movl	#0x80008000,%d0
  	movc	%d0,%cacr		| turn on both caches
! 	JMP(Lenab1)
  Lmotommu2:
  	movl	#MMU_IEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD
  					| enable 68881 and i-cache
  	RELOC(prototc, %a2)
  	movl	#0x82c0aa00,%a2@	| value to load TC with
  	pmove	%a2@,%tc		| load it
! 	JMP(Lenab1)
  Lhpmmu3:
  	movl	#0,INTIOBASE+MMUBASE+MMUCMD		| clear external cache
  	movl	#MMU_ENAB,INTIOBASE+MMUBASE+MMUCMD	| turn on MMU
! 	JMP(Lenab1)
  Lehighcode:
  
  	/*