Jump to content

Array in MIPS

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 429 posts
My program. Fills a vector i= 0 to i <16.
array[i] = 2*i

Why the program does not print anything?

    .data
    
array:    .space 64


    .text
    .globl main
    
main:
    li        $t0, 0                
    li        $t2, 0                
    
loop:
    beq        $t0, 16, sair        
    add        $t3, $t3, $t0        
    add        $t4, $t3, $t3
    sw        $t4, array($t2)
    addi    $t0, $t0, 1
    addi    $t2, $t2, 4
    j        loop
sair:
    la        $a0, array
    li        $v0, 4
    syscall
    li        $v0, 10
    syscall


#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
I don't know MIPS assembly (just Intel assembly). But if you tell me what each of those instructions means and what you're trying to do, then I could try helping you.

Some of the instructions I inferred to be:
LI operand1, operand2 : load integer, load operand1 with (immediate) integer in operand2
BEQ operand1, operand2, operand3 : jump to operand3 if operand1 is below or equal to operand2
ADD operand1, operand2, operand3 : operand1= operand2 + operand3
ADDI operand1, operand2, operand3 : same as ADD, but operand3 is an integer (immediate)
SYSCALL : call the operating system

Correct me if I'm wrong, anywhere, in the above inferences.

Though I would need more information about the rest of the instructions, the system calls, and what you're trying to do, for me to help. So if there's someone on this forum who knows MIPS assembly, they could help you, otherwise I could try helping, but I'll need more information.

#3
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 429 posts

RhetoricalRuvim said:

I don't know MIPS assembly (just Intel assembly). But if you tell me what each of those instructions means and what you're trying to do, then I could try helping you.

Some of the instructions I inferred to be:
LI operand1, operand2 : load integer, load operand1 with (immediate) integer in operand2
BEQ operand1, operand2, operand3 : jump to operand3 if operand1 is below or equal to operand2
ADD operand1, operand2, operand3 : operand1= operand2 + operand3
ADDI operand1, operand2, operand3 : same as ADD, but operand3 is an integer (immediate)
SYSCALL : call the operating system

Correct me if I'm wrong, anywhere, in the above inferences.

Though I would need more information about the rest of the instructions, the system calls, and what you're trying to do, for me to help. So if there's someone on this forum who knows MIPS assembly, they could help you, otherwise I could try helping, but I'll need more information.

OK. Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users