Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2006, 4:14 PM   #1
Winky
Newbie
 
Join Date: Nov 2006
Posts: 2
Rep Power: 0 Winky is on a distinguished road
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
Winky is offline   Reply With Quote
Old Nov 28th, 2006, 4:43 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 28th, 2006, 4:46 PM   #3
Winky
Newbie
 
Join Date: Nov 2006
Posts: 2
Rep Power: 0 Winky is on a distinguished road
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
Winky is offline   Reply With Quote
Old Nov 28th, 2006, 5:05 PM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,612
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
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.
big_k105 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:35 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC