gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > changing opcodes manually

#8301 - Lupin - Mon Jul 07, 2003 7:44 pm

Is it possible to turn an specific 32bit opcode into another one? Finding out the opcode value is no problem, I think i could use an opcode table.

#8305 - DekuTree64 - Mon Jul 07, 2003 10:31 pm

Yeah, it's called dynamic or self-modifying code. I haven't ever found any uses for it myself, but basically you just copy in new opcodes. All you have to do is ldr rTemp, =opcode, then adr rPos, label (generates an add rPos, pc, #distToLabel) and str rTemp, [rPos]. Just make sure your code is in RAM, since you can't overwrite ROM.