Subject: Assembler and locore.s
To: None <port-sun3@sun-lamp.cs.berkeley.edu>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: port-sun3
Date: 02/28/1994 15:09:29
> From: Chuck Silvers <chs+@CS.CMU.EDU>
> Date: Mon, 28 Feb 94 14:44:46 EST
> 
> 2)  I'm using gas 2.2 from the FSF instead of whatever version of gas we're
> supposed to be using, and the pc-relative stuff in icode in locore.s
> didn't work as expected.  I ended up replacing:
> 
> 	pea	pc@((argv-.)+2)
> 	pea	pc@((init-.)+2)
[...]

> Date: Mon, 28 Feb 1994 11:53:01 -0800
> From: Adam Glass <glass@sun-lamp.cs.berkeley.edu>
> 
> I think i'll change this to whatever works in moth versions ....

I too had problems with locore.s (first with Sun's as and then with gas).
Here are some changes to make it compile with any gas version.  (It might
compile with Sun's as too with different macros in m68k.h so the first
hunk of changes are for Sun as compatibility.)

This change works around a bug in gas-1.92 but in a rather ugly way.
One SHOULD be able to write just "pea argv" but gas assembles this
instruction incorrectly.  My solution is the sledge hammer below.

Gordon Ross


*** sys/arch/sun3/sun3/locore.s.orig	Wed Feb 23 06:03:17 1994
--- sys/arch/sun3/sun3/locore.s	Thu Feb 24 01:46:27 1994
***************
*** 38,46 ****
  
  .globl tmpstk
  .data
! .space NBPG
  tmpstk:
! .set	_kstack,MONSHORTSEG
  .globl _kstack
  .text
  .globl start; .globl _start
--- 38,46 ----
  
  .globl tmpstk
  .data
! .skip NBPG
  tmpstk:
! 	_kstack = MONSHORTSEG
  .globl _kstack
  .text
  .globl start; .globl _start
***************
*** 142,150 ****
  	.text
  _icode:
  	clrl	sp@-
! 	pea	pc@((argv-.)+2)
! 	pea	pc@((init-.)+2)
! 	clrl	sp@-
  	moveq	#SYS_execve,d0
  	trap	#0
  	moveq	#SYS_exit,d0
--- 142,159 ----
  	.text
  _icode:
  	clrl	sp@-
! |	pea	pc@((argv-.)+2)		| More complicated than necessary
! | This works with Sun's assembler, but GAS-1.92.3 gets it wrong...
! |	pea	argv			| Push arg ptr
! 	.word	0x487a	| pea <short>
! 	.word	argv-.
! |	pea	pc@((init-.)+2)		| More complicated than necessary
! | This works with Sun's assembler, but GAS-1.92.3 gets it wrong...
! |	pea	init			| Push file name
! 	.word	0x487a	| pea <short>
! 	.word	init-.
! 	clrl	sp@-			| Push ret addr (fake)
! 	| Note that NetBSD wants the syscall code in D0.
  	moveq	#SYS_execve,d0
  	trap	#0
  	moveq	#SYS_exit,d0

------------------------------------------------------------------------------