Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Example of Self modifying ASM code :P

  1. #1
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default Example of Self modifying ASM code :P

    Here's a simple code that modifies one of its instructions when certain conditions are met. (like changing an add instruction to a subtract)
    I dunno I was just bored XD

    Press L+R to add to your bells if less than 99,900. If it is more than 99,900, it'll start subtracting instead, until it reaches 100 or less. It'll keep going back and forth :P

    Code:
    023FF090 012FFF11
    E0000000 00000040
    E28F2001 E12FFF12
    8800480A 01122230
    D10D4210 68214C08
    42A94D08 2339DB01
    2964E002 2331DC02
    7053A200 60213164
    00004770 04000130
    021D891C 0001863C
    023FF090 E3520003
    ASM source:


    It works a lot easier in ARM mode, but...it's just an example.
    Always willing to help with anything, code-related or not. :]

  2. #2

    Default

    From the looks of the source, I'm assuming 'adr' points to AddOrSubtract label.
    3DS Friend Code: 4699-6293-3106

  3. #3

    Default

    Neat. So it kind of cycles through to the amount you need?

  4. #4

    Default

    I think his code adds 100 bells to your current amount until you reach 99,000. After that, the code subtracts 100 bells until you get to 100 bells then it adds back up to 99,000 bells and keeps repeating itself.
    3DS Friend Code: 4699-6293-3106

  5. #5
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default

    In regular ARM mod, you could just the pc to overwrite any instruction. In THUMB it says it's not allowed (cause the pc is r15)
    (the pc stands for program counter, it basically tells where the next instruction to be executed is)
    In ARM everything is 32 bit though, including the instructions, so it'd take up more room, but it's definitely more powerful.
    Like, let's say in ARM you wanted to overwrite the very next instruction. Let's say r5 has the instruction you wanna write. To overwrite the very next instruction you'd put....
    str r5, [pc, #-0x4]

    to overwrite the instruction after that instead
    str r5, [pc]
    etc.
    Always willing to help with anything, code-related or not. :]

  6. #6
    Chris (Administrator) Vash's Avatar
    Join Date
    Sep 2007
    Location
    Teh Interwebz
    Posts
    1,992
    Blog Entries
    27

    Default

    I don't know about "self-modifying". Makes it sound like polymorphism. It's more like an ASM switch case.
    Animal Crossing: City Folk
    ACToolkit - NPC_Tool - PattView

  7. #7
    Member
    Join Date
    Aug 2008
    Location
    Arizona
    Posts
    1,073
    Blog Entries
    2

    Default

    Quote Originally Posted by Vash View Post
    I don't know about "self-modifying". Makes it sound like polymorphism. It's more like an ASM switch case.
    Well, it might not be exactly, but...
    according to wikipedia
    "In computer science, self-modifying code is code that alters its own instructions while it is executing."
    and that alters a single instruction while executing XD (it directly overwrites an "add" instruction with a "subtract" instruction, or vice versa)
    Although I'm probably wrong, you're the more advanced hacker.
    Always willing to help with anything, code-related or not. :]

  8. #8

    Default

    Self modifying suggest to me that it actively changes it's own base level instructions, i.e. I could put it in - run it and then go and look at it later and it would have changed - this is obviously impossible as the instructions are stored on your ARDS

    Remember to always click the thanks button of those who help you! It makes them feel wanted:

  9. #9

    Default

    It's a neat idea though, it almost has a "mind" to where it knows when to change action.

    Better watch out. One of these days your codes will start modifying themselves to the point where your DS comes self-aware. The world is in danger when your DS suddenly flares to life and declares it supreme to mankind. Resistance is futile.

  10. #10
    Member
    Join Date
    Aug 2008
    Location
    Vancouver, Washington
    Posts
    226

    Default

    Quote Originally Posted by yoshisrock View Post
    It's a neat idea though, it almost has a "mind" to where it knows when to change action.

    Better watch out. One of these days your codes will start modifying themselves to the point where your DS comes self-aware. The world is in danger when your DS suddenly flares to life and declares it supreme to mankind. Resistance is futile.
    I don't agree with this theory. Technology will never run the world. Even if it did, we would be too busy to care anyways.
    Also, i lol'd.
    I Lost the Game.

    -Lord Was

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •