Announcement

Collapse
No announcement yet.

68000 Assembly Info

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Thanks Hacc (and everyone else).

    0E:C9C0 60 02 BRA #$02 [0E:C9C4]

    Means Branch 2 bytes to ROM address 0EC9C4.

    A quick note about Genesis/68000 branch instructions. This threw me off when I was first learning them. When you are counting how far a branch instruction is going to branch, remember that you don't start counting until the first byte AFTER the actual Branch instruction. In the example above, the starting ROM address is 0E:C9C0, and the ending ROM address is 0E:C9C4. There's a 4 byte difference between the two, but it only branched 2 bytes.

    So just remember that the branch instruction itself is not included when counting how far it's going to branch.

    One cool thing about 68000 branch instructions is that you can branch forwards OR backwards. I'll give an example of that shortly.

    EDIT: Branch instructions are the most common replacement instruction when making Game Genie codes. You'll usually use either an NOP or Branch instruction to kill most unwanted processes (addition, subtraction, move, etc).
    Last edited by Tony H; 09-09-2012, 08:12:29 PM.
    The Code Hut: http://codehut.gshi.org/

    Comment


    • #32
      00:030A 66 F4 BNE #$F4 [00:0300]

      Means if Not Equal, Branch BACKWARDS to ROM address $000300.

      $00~$7F = Branch forward, $80~$FF = Branch backwards.
      The Code Hut: http://codehut.gshi.org/

      Comment


      • #33
        00:0224 67 08 BEQ #$08 [00:022E]

        Means if equal, Branch 8 bytes to ROM address $00022E.

        EDIT: A quick note... if you want to change a BEQ (Branch if EQual), or any other conditional branch so that it ALWAYS branches, just change the second digit to a zero. This info applies to 2 and 4 byte conditional branches. So in our example above, you would change it from 6708 to 6008.

        If you want it to NEVER branch, change it to 4E71 (NOP). This only applies to 2 byte conditional branches.

        If you have a 4 byte conditional branch and you want it to never branch, change it to 6002. (I'll give an example of a 4 byte branch next.)
        Last edited by Tony H; 02-26-2011, 07:08:11 PM.
        The Code Hut: http://codehut.gshi.org/

        Comment


        • #34
          02:A0AC 60 00 BRA #$002E [02:A0DC]

          This is a 4 byte Branch instruction (Branch $002E bytes). Any 4 byte branch instruction will always end in "00". 2 byte branch instructions end in anything else besides "00" (02, 04, etc).
          Last edited by Tony H; 03-02-2011, 07:37:29 PM.
          The Code Hut: http://codehut.gshi.org/

          Comment


          • #35
            0E:1BDC 4E 71 NOP

            Means do nothing (No OPeration).

            This is another popular replacement instruction when making Game Genie codes.

            A few tips on when to use 4E71 (NOP's)... Generally, you only use an NOP to kill an instruction that has no operands. If the instruction you want to kill has operands, then use branch instructions instead (6002, 6004, etc). You can use Pugsy's 68000 assembly list to see how many operands a particular instruction has: http://www.thegshi.org/downloads/68000_Instructions.7z

            Also, you should never use 2 or more NOP's for consecutive addresses when making Game Genie codes. It will work, but you're just wasting GG codes. If you need to NOP consecutive addresses, you're better off using branch instructions instead (see above).

            Just keep in mind that when you're making Game Genie codes and you are trying to kill an instruction, you always want to use an NOP or branch so that it skips to an instruction. If you skip to an operand instead, the game will get confused which can cause glitches or lock-ups.
            Last edited by Tony H; 03-05-2011, 03:59:30 PM.
            The Code Hut: http://codehut.gshi.org/

            Comment


            • #36
              MOVE and PEA

              Code:
              24 2F  MOVE.l  $000C(A7),D2             A7=FFFFFFC4
              For this opcode, the 4 bytes located on the stack at FFFFFFD0 is moved to register D2. ($000C+FFFFFFC4=FFFFFFD0)

              After the operation, let's assume D2=0000000A

              But where did this $0000000A value come from originally?

              From your current spot in the trace log, scroll up and find the push that caused the
              stack register (A7) to be FFFFFFD0. In this example, it turns out to be this:

              Code:
              48 78  PEA     ($000A)
              PEA = Push Effective Address

              In the game this example was based off, the value loaded into D2 was then used as an index for a pointer table. Game Genie/Action Replay codes that changed the $000A to something else ($0009, $000B, etc.) worked as a menu modifier and uncovered a hidden debug screen.
              Last edited by JLukas; 03-18-2011, 02:18:47 AM.

              Comment


              • #37
                Good info. Thanks JLukas.

                I'm hoping you can answer a question. How does the assembly below work? And what's the function of the "[0c 18]" values? I know that A7 is the stack register, but not sure exactly how this one works. TIA.

                04:46B8 4C DF MOVEM.L (A7)+,{a7-d0}[0c 18] A0=000031F8 A1=00000000 A2=FFFFB610 A3=FFFFB68E A4=FFFFD8A0 A5=FFFFB662 A6=00000000 A7=FFFFF8A0 D0=00030001 D1=00000000 D2=00000000 D3=00000001 D4=FFFF9800 D5=00000000 D6=00000000 D7=00000000 XnZvc
                The Code Hut: http://codehut.gshi.org/

                Comment


                • #38
                  Good question. I haven't had to deal with one of those yet.

                  Comment


                  • #39
                    movem is basically a multiple move.

                    Must admit I've only ever used movem a few times and that was 20 years ago.

                    The 68000 instructions I did don't really cover the movem instructions (there are stacks of them).

                    So I've updated the list of 68000 instructions and made MASSIVE separate files for the movem instructions.

                    http://www.mediafire.com/file/24z6bv...ructions_V2.7z
                    Pugsy's MAME Cheat Page : http://mamecheat.co.uk

                    Comment


                    • #40
                      Thanks guys.

                      Pugsy, I've downloaded the updated file and will check it out shortly.

                      EDIT: Pugsy, just wanted to let you know that I use the shit out of your 68000 instruction lists. Thanks for making them.
                      Last edited by Tony H; 03-19-2011, 04:43:40 PM.
                      The Code Hut: http://codehut.gshi.org/

                      Comment


                      • #41
                        Nice to hear they are of use, it saves me time searching though code to find the values I need.

                        I have similar lists for other CPUs...must upload them when I get a chance.
                        Last edited by Pugsy; 03-20-2011, 09:28:03 AM.
                        Pugsy's MAME Cheat Page : http://mamecheat.co.uk

                        Comment


                        • #42
                          Anything for the Saturn?
                          Spoiler Alert! Click to view...

                          THE BAD GUY!!!!!!

                          Comment


                          • #43
                            Saturn is SH-2 if I remember right so just has a bunch of 16bit opcodes. Sounds quite easy, should take me less an hour to come up with something that's usable. Leave it with me....
                            Pugsy's MAME Cheat Page : http://mamecheat.co.uk

                            Comment


                            • #44
                              Ok, it was a bit simpler than I hoped.

                              I think this will suffice, I've optimised it as much as I dare.

                              http://www.mediafire.com/file/wfd5hc...Sega_Saturn.7z
                              Pugsy's MAME Cheat Page : http://mamecheat.co.uk

                              Comment


                              • #45
                                Originally posted by Pugsy View Post
                                Saturn is SH-2 if I remember right so just has a bunch of 16bit opcodes. Sounds quite easy, should take me less an hour to come up with something that's usable. Leave it with me....
                                I wasn't aware that the Saturn used the same instructions as the Sega 32X. I've been looking for a list of 32X instructions for years. Thanks again Pugsy.

                                P.S. You weren't kidding when you said the updated list of 68000 assembly MOVEM instructions was MASSIVE. 428 MB each!! Wow.
                                Last edited by Tony H; 03-20-2011, 12:43:23 PM.
                                The Code Hut: http://codehut.gshi.org/

                                Comment

                                Working...
                                X