Friday 15 February 2013

MIPS A String to Integer Conversion -



MIPS A String to Integer Conversion -

basically, read string console, no problem. first , 3rd characters in string 0-9 number , want these numbers store ıntegers in memory reuse later. "exception occured @ pc=0x0040004c" , when clicking abort "unaligned address in store:0x100100c9".

what problem? please, help!

edit:when run step step, error occurs in line 24.

.data exp: .space 201 #allocate 200 bytes logic look read stdin. +1 null char. dimension: .space 8 #allocate 8 bytes dimensions of environment .text main: li $v0, 8 # load appropriate scheme phone call code register $v0; # code reading string 8 la $a0, exp # load address of string read $a0 li $a1, 201 # load length of string read $a1 syscall # phone call operating scheme perform read operation la $t0, exp la $t1, dimension add together $t2,$zero,$zero lb $t2, 0($t0) addi $t2, $t2, -48 sw $t2, 0($t1) li $v0, 10 syscall

you have align info @ word boundary when storing word.

for have utilize .align directive parameter 2.

in illustration dimension not aligned because exp 201 bytes length (not multiple of 4). have use:

.data exp: .space 201 #allocate 200 bytes logic look read stdin. +1 null char. .align 2 # align info dimension: .space 8 #allocate 8 bytes dimensions of environment .text

string mips

No comments:

Post a Comment