| View previous topic :: View next topic |
| Author |
Message |
ramaz
Joined: 18 Sep 2008 Posts: 2
|
Posted: Thu Sep 18, 2008 9:14 am Post subject: mips, self modifying code |
|
|
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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Sep 18, 2008 11:11 am Post subject: |
|
|
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 |
|
 |
ramaz
Joined: 18 Sep 2008 Posts: 2
|
Posted: Thu Sep 18, 2008 12:51 pm Post subject: |
|
|
| 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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Sep 18, 2008 1:11 pm Post subject: |
|
|
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 |
|
 |
|