我想分配一个字符串数组,然后用ASCII码填充该数组。
.data
.align 4
array: .space 102400
.text
la $t0, array #t0 = address of an array
li $t7, 0 #loop counter
loop:
beq $t7,255,exit #exit if all ascii codes added
li $v0, 9 #alocate memory
li $a0, 2 #alocate 2 bytes (i have tried 1 and 2 bytes -> 1
#becouse i wanted to alocate one char and 2 becouse i
#wanted to try allocate one sign as:
#<string> = <ascii code> + $0 (end_of_string)
syscall
sw $v0,($t0) # save adress of allocated memory in array (so array
#is something like array of pointer)
move $t5,$v0 #copy adress to $t5 (i will use this to print string)
sb $t7,($t5) #save value of counter in allocated place
addi $t5,$t5,1 #next index
sb $0,($t5) #end_of_string
#print string
li $v0, 4
move $a0,$t0 #t0 should contain adress of allocated memory -> string
syscall
addiu $t0,$t0,4 #next cell in array
addiu $t7,$t7,1 #counter ++
b loop
exit:
我被期望像这样: “ ..... ABCDEFGHIJ .....”,我的意思是-所有ASCII值 但是我明白了:
“ .... $(,048 <@ DHLPTX`dhlptx |¤¤°/´¸¼ÀÄÌÌÔØÜàäèèððøü $(,048 该如何解决?