mips Runtime exception at 0x00400004: address out of range 0x00000000

0

I'm trying to learn mips and I'm kinda new to this :P When I try to run this code it gives me "Runtime exception at 0x00400004: address out of range 0x00000000" on lb $t2,0($t0). What am I doing wrong?

    .data
    .text
    .globl strlen


strlen: li $t1,0        # len = 0;
    move $t0, $a0       # $a0 = char*s
    lb $t2,0($t0)
while:          # while(*s++ != '\0')
    beq $t0, '\0', endw
    addiu $t0,$t0,1     #
    addiu $t1,$t1,1
    lb $t2,0($t0)
    j while             # }
endw:   move $v0,$t1        # return len;
    jr $ra 
exception
assembly
runtime
mips
mars
asked on Stack Overflow Nov 4, 2019 by Joao Machado

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0