-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path2.3.txt
35 lines (34 loc) · 836 Bytes
/
2.3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
.data
num: .asciiz "0123456789ABCDEF"
destination: .asciiz "0"
prompt: .asciiz "Starting to copy 0123456789ABCDEF "
pri: .asciiz "the value is :: "
.text
main:
li $v0, 4
la $a0, prompt
syscall
jal stringcpy
j finish
stringcpy:
add $s0, $zero, $zero #i=0
la $a1, num
la $a0, destination
loop:
add $t1, $a1, $s0 #source indexing
lb $t2, 0($t1) #loading source[i] to t2
add $t3, $a0, $s0 #indexing destination
sb $t2, 0($t3)
beq $t2, $zero,loop2
addi $s0, $s0, 1
j loop
loop2:
jr $ra
finish:
#printing the copied string
li $v0, 4
la $a0, pri
syscall
la $a0, destination
li $v0,4
syscall