![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2006
Posts: 2
Rep Power: 0
![]() |
Optimizing MIPS in SPIM
Hey guys (newbie to the forums.... play nice!),
In my final project of the semester I was given C code, which I then had to switch into MIPS.. after taking it to my professor he told me I needed to optimize it using $v and $a registers... and I'm stuck and running out of time. Payment is doable if this does in fact take a whole lot of effort for those expert programmers out there . I have to get this done by Thursday and I have hit a brick wall..text memset: addiu $sp,$sp,-16 sw $fp,8($sp) move $fp,$sp sw $a0,16($fp) sw $a1,20($fp) sw $a2,24($fp) lw $v0,20($fp) sb $v0,0($fp) lw $v0,16($fp) sw $v0,4($fp) L2: lw $v0,24($fp) beq $v0,$0,L3 lw $v1,4($fp) lbu $v0,0($fp) sb $v0,0($v1) lw $v0,4($fp) addiu $v0,$v0,1 sw $v0,4($fp) lw $v0,24($fp) addiu $v0,$v0,-1 sw $v0,24($fp) j L2 L3: lw $v0,16($fp) move $sp,$fp lw $fp,8($sp) addiu $sp,$sp,16 j $ra a_memmove: addiu $sp,$sp,-16 sw $fp,8($sp) move $fp,$sp sw $a0,16($fp) sw $a1,20($fp) sw $a2,24($fp) lw $v0,16($fp) sw $v0,0($fp) lw $v0,20($fp) sw $v0,4($fp) lw $v1,4($fp) lw $v0,0($fp) sltu $v0,$v1,$v0 beq $v0,$0,L11 lw $v1,4($fp) lw $v0,24($fp) addu $v1,$v1,$v0 lw $v0,0($fp) sltu $v0,$v0,$v1 beq $v0,$0,L11 lw $v1,0($fp) lw $v0,24($fp) addu $v0,$v1,$v0 sw $v0,0($fp) lw $v1,4($fp) lw $v0,24($fp) addu $v0,$v1,$v0 sw $v0,4($fp) L7: lw $v0,24($fp) beq $v0,$0,L10 lw $v0,0($fp) addiu $v0,$v0,-1 move $v1,$v0 sw $v1,0($fp) lw $v0,4($fp) addiu $v0,$v0,-1 sw $v0,4($fp) lbu $v0,0($v0) sb $v0,0($v1) lw $v0,24($fp) addiu $v0,$v0,-1 sw $v0,24($fp) j L7 L11: lw $v0,24($fp) beq $v0,$0,L10 lw $v1,0($fp) addiu $a0,$fp,4 lw $v0,0($a0) lbu $a1,0($v0) addiu $v0,$v0,1 sw $v0,0($a0) move $v0,$v1 sb $a1,0($v0) addiu $v1,$v1,1 sw $v1,0($fp) lw $v0,24($fp) addiu $v0,$v0,-1 sw $v0,24($fp) j L11 L10: lw $v0,16($fp) move $sp,$fp lw $fp,8($sp) addiu $sp,$sp,16 j $ra a_strcat: addiu $sp,$sp,-16 sw $fp,8($sp) move $fp,$sp sw $a0,16($fp) sw $a1,20($fp) sw $a2,24($fp) lw $v0,16($fp) sw $v0,0($fp) L15: lw $v0,0($fp) lb $v0,0($v0) beq $v0,$0,L18 lw $v0,0($fp) addiu $v0,$v0,1 sw $v0,0($fp) j L15 L18: lw $v0,24($fp) beq $v0,$0,L19 lw $v0,20($fp) lb $v0,0($v0) beq $v0,$0,L19 lw $v1,0($fp) addiu $a0,$fp,20 lw $v0,0($a0) lbu $a1,0($v0) addiu $v0,$v0,1 sw $v0,0($a0) move $v0,$v1 sb $a1,0($v0) addiu $v1,$v1,1 sw $v1,0($fp) lw $v0,24($fp) addiu $v0,$v0,-1 sw $v0,24($fp) j L18 L19: lw $v0,0($fp) sb $0,0($v0) lw $v0,16($fp) move $sp,$fp lw $fp,8($sp) addiu $sp,$sp,16 j $ra I think I have memset pretty much done, which looks like this memset: move $v1, $a0 L2: beq $a2, $0, L3 addiu $a2, $a2, -1 lbu $v0, 0($a1) addiu $a1, $a1, 1 sb $v0, 0($v1) j L2 L3: j $ra move $va, $a0 Guys ... I'm desperate! If this wasn't so important I wouldn't be doing this, but please.... somebody... anybody.... Thanks for your time |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You're willing to hire your schoolwork done, and you're asking us to play nice?
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Nov 2006
Posts: 2
Rep Power: 0
![]() |
It's not like I'm not working on it.. I'm just looking for help...
Tutoring Center doesn't help much with MIPS/SPIM and with no prior knowledge of assembly... it gets a little tough.. Please don't look at it as me hiring, but more as me looking for tutoring... If you cannot help or do not wish too, I will grind it out and do my best, but ANY help would be appreciated |
|
|
|
|
|
#4 |
|
PFO Founder
![]() ![]() |
Where exactly are you hitting a wall. If you ask a more specific question about something, I am sure people would be willing to help.
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Optimizing my win32api function? | Sane | Python | 3 | Sep 3rd, 2005 8:40 PM |
| Smashing a stack in MIPS assembly code | tsgrimey | Assembly | 2 | Feb 27th, 2005 1:06 PM |
| SPIM Assembly Programming Simulation Problem | tsgrimey | Assembly | 1 | Feb 9th, 2005 2:21 AM |