forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mips, self modifying code

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
ramaz



Joined: 18 Sep 2008
Posts: 2

PostPosted: Thu Sep 18, 2008 9:14 am    Post subject: mips, self modifying code Reply with quote

hi, i need help with self modifying code.


the assignment is to actually write a calculator program. it basically takes some input binary,decimal,hex and does 4 operations +,-,*,/ but there is a special case where when the result is 7 the program will modify itself so that from then on entering addition will instead give the logical AND of the two operands.
I dont know anything about self modification.


Last edited by ramaz on Fri Oct 03, 2008 6:01 am; edited 1 time in total
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Sep 18, 2008 11:11 am    Post subject: Reply with quote

So you want us to do your homework for you?

I'll give this much help - go download a MIPS manual and you'll find the assembly language. You're basically being asked to do some simple machine language commands - replacing the add opcode with an and opcode.
Back to top
View user's profile Send private message AIM Address
ramaz



Joined: 18 Sep 2008
Posts: 2

PostPosted: Thu Sep 18, 2008 12:51 pm    Post subject: Reply with quote

no, im sorry i worded it wrong. i was able to do everything. except the self modification. i had no clue how to do it
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Sep 18, 2008 1:11 pm    Post subject: Reply with quote

Okay, that's better. :)

Look up the opcodes you'll need (in the manual I mentioned). Look at the hex values... you'll need to store the code over top of the old code, flush the data cache to make sure the value is written to memory, then invalidate the code cache to make sure the CPU fetches the new code from memory instead of the cache.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> General Discussion All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group