mips, self modifying code

General, off-topic discussion about things of interest to the members of these forums.

Moderator: cheriff

Post Reply
ramaz
Posts: 2
Joined: Thu Sep 18, 2008 9:11 am

mips, self modifying code

Post by ramaz »

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.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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.
ramaz
Posts: 2
Joined: Thu Sep 18, 2008 9:11 am

Post by ramaz »

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
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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.
Post Reply