Hello Evreryone,

I am new here and would love some help with a project I have. I have to create a MIPS program where we implement different funcntions. I was able to do strcopy but Im having trouble finding how to code the strchr, strcmp, and memset functions. Unfortunately I am new to MIPS and do not know how the funcntions are written. Could anyone show me how to write the code or some code examples for the three library functions please? The functions will be called by a test file so no main is needed. Thanks for all the help. Heres my str copy, I hope it is right

strcpy:

addi $sp, $sp, -4

sw $s0, 0($sp)

add $s0, $zero, $zero

L1:

add $t1, $s0, $a1

lb $t2, 0($t1)

add $t3, $s0, $a0

sb $t2, 0($t3)

beq $t2, $zero, L2

addi $s0, $s0, 1

j L1

L2:

lw $s0, 0($sp)

addi $sp, $sp, 4

jr $ra

For this, I would NEVER write these as these are what I call wheels. Remember I take it that you are not doing this for homework and want solid tested well used solutions. Again, these are what I call wheels. You go get them, slap them on and test.

https://www.google.com/search?q=strchr%2C+strcmp%2C+memset+for+MIPS finds them. Example?

Read https://git.sphere.ly/Kevinjoa/bionic/commit/1d824c39127764ab50b01ee2ed8bcdb6a59d48cc which has the assembler versions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.