trouble with spim.....

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
I am trying to run a program in SPIM, but when i tell it to run it just tells me that _start is undefined. Am I missing a directive or something?
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Are you referring to the MIPS simulator? If so how are you running your program?
 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
yeah

I type my program in notepad...I give it the .asm extension

I got to file->open-> I open the file I want

i then go to Simulator->Go

It asks for address and command line. If I leave both blank, it just does nothing

If I start at address 0x00400000 (this is the first address that corresponds to the assmebly code when it is loaded into the window), it gives me the _start message.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
That is interesting, when I load up a program and hit go it automatically fills in the start value for me. Go into settings and see if everything is there.

If you can post your code I can perhaps take a look at it to see if I can get it to run over here.

Also try this program and see if it runs.

 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
Your program had the message, but the console actually responded and it ran.

this program is just supposed to take values that I stored in memory and add them. I think i am doing it right.
.data
A: .word 7
B: .word 5
Sum: .word 0
Dif: .word 0

.text
.gobl main
main:
la $s1, A
la $s2, B
la $s3, Sum
la $s4, Dif
add $s3, $s1, $s2
sub $s4, $s1, $s2
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
A few things
.gobl main throws a syntax error. You don't need it at all, any reason why you put it there?

la is not the intstruction you want to use to load your variables.
la loads the address of the label you supplied. So it will be storing 0x10010000 in $s1 and 0x10010004 in $s2

If you use la then you need to use a lw instruction as well, using $s0 and $s1 as your base addresses.

The simpler solution is to just use lw to begin with

lw $s1,A
lw $s2,B
lw $s3, Sum
lw $s4, Dif
 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
the globl was put there because my prof. said you need it, but that was the first time i ever seen it written, so i just put it down.

I was gonna use lw, but when teh TA was talking today, he said that using LW would be harder....man, my ece program at my school is messed up......

Does your solution load A from memory. That is what messes me up. I have to retrive it from memory, but to do that, don't you need to define what allocation it is at?
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
To be honest I have never seen la before. My guess is that it is a pseudo instruction for lui as that is what spim is telling me which is not what you want.

You are trying to load a word from memory, so lw would be the way to do it. lw with just a register and label as parameters is a pseudo instruction for

lui $at, .data
lw $s0,8($at)

^^ That is the proper way to do it, but lw $s0,A works because of it being a psuedo instruction.