Page 1 of 1

assembly help

Posted: Sun May 07, 2006 9:55 am
by JorDy
the compiler keeps returning these errors wheni try to compile my functions.s
file with my main c file
functions.s:

Code: Select all

#include "r5900_regs.h"
        
.set noreorder

.text

	.global notarealfnc
	.ent	notarealfnc
notarealfnc:
	lw	v0,	0x00(t0)
	addiu	v0, v0	4
	sw	v0, 	_addr
	jr	ra
	nop
	.end notarealfnc
ive defined my function in the c source as "extern void notarealfnc(void);" but the compiler throws out these errors, the only command it likes is a nop:

Code: Select all

	$ make
	ee-as -G0  functions.s -o functions.o
	functions.s: Assembler messages:
	functions.s:0: Warning: end of file not at end of a line; newline inserted
	functions.s:10: Error: illegal operands `lw v0,0x00(t0)'
	functions.s:11: Error: illegal operands `addiu v0,v0 4'
	functions.s:12: Error: illegal operands `sw v0,_addr'
	functions.s:13: Error: illegal operands `jr ra'
	make: *** [functions.o] Error 1
thnx in advance

Posted: Sun May 07, 2006 7:50 pm
by jbit
Unless I'm forgetting something, gas (ee-as) can't use "#include", since it doesn't invoke the CPP (C Preprocessor), ".include" does work though.

You can of course use ee-gcc to compile a .S or .s file though, if you want to use CPP directives. (hint: r5900_regs.h probably requires you do this)

Hope this helps.

Posted: Sun May 07, 2006 8:44 pm
by Saotome
...and if that doesn't work (I'm not saying that it shouldn't)
you could try to put a "$" before the register names (i.e. "addiu $t0,$t0,1"), thats how I solved the problem ;)

Posted: Sun May 07, 2006 10:13 pm
by JorDy
thanks alot guys the $ did help but my addiu also didnt like me using register names for some reason so i had to use the register numbers

Posted: Mon May 08, 2006 2:54 pm
by ooPo
> I tried to #include the .h file in the assembley file and feed it to
> the c preprocessor. The output had the #include file data in it, so
> 'as' choked.

Use gcc to preprocess the assembly, like so:

gcc -c foo.S

Both .S and .s are assembler. By convention, .S is assembly source that
needs to be preprocessed. Otherwise, gcc doesn't care.
http://sourceware.org/ml/crossgcc/1997/msg00002.html

There's also an include file in ps2sdk somewhere that maps the register numbers to register names.