🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #781

"funny" gcc output for mips

#781
From: Peter R. Ham
Date: Sun, 12 Nov 1989 17:50
53 lines
1421 bytes
I don't understand why the mips port of gcc seems to
reserve r30 as a frame pointer. Why is this necessary?
The mips cc seems to try to avoid this. In addition,
why isn't the value of the stack pointer (r29) assumed
to be preserved across function calls?

For example:
The following c code:


extern void bar();

void
foo()
{
  bar();
}

Produces the following assebly:

 #	.verstamp	2 0
gcc_compiled.:
.text
	.align 2
	.globl foo
	.ent	foo
foo:
	subu	$29,8	# saveregs=    8
	.frame	$30,0,$31
	.mask	0xc0000000,-4
	sw	$31,4($29)
	sw	$30,0($29)
	addiu	$30,$29,8	# define fp
	addiu	$29,$29,0xfff0	#subsi3	$29,16 -> $29
	jal	bar	# call with 16 arguments
	addiu	$29,$29,0x10	#addsi3	$29,16 -> $29
	addu	$8,$0,$30	# don't trust sp?
	lw	$31,-4($8)
	lw	$30,-8($8)
	addu	$29,$0,$8	# sp not trusted  here 
	j	$31
 	.end	foo







--
Peter Ham			PO Box 3430	(h)(415) 322-4390
MS Computer Science Student	Stanford, CA	ham@cs.stanford.edu
Stanford University 		94309		(o)(415) 723-2067
Technical Details
Message-ID: <HAM.89Nov12095025@Neon.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!shelby!neon!neon.Stanford.EDU!ham

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!shelby!neon!neon.Stanford.EDU!ham
From: ham@Neon.Stanford.EDU (Peter R. Ham)
Newsgroups: gnu.gcc.bug
Subject: "funny" gcc output for mips
Message-ID: <HAM.89Nov12095025@Neon.Stanford.EDU>
Date: 12 Nov 89 17:50:25 GMT
Sender: USENET News System <news@Neon.Stanford.EDU>
Distribution: gnu
Organization: Stanford University
Lines: 53