Jump to content

  •  

  • Photo

    What do those Labels (move.w, sub.w, bcs.s , etc. Most of the others)


    • This topic is locked This topic is locked
    9 replies to this topic

    #1 DarkLeach

    DarkLeach

      Behold the Power of DarkLeach7! Tomorrow...

    • Member
    • 193 posts
    • Gender:Male
    • Location:I don't even know...

    Posted 06 January 2012 - 02:58 AM

    I've been Sonic hacking for a little while and I've had something troubling me. I want to add features/ modify things in Sonic 1. I notice these labels and I have no clue what they do, but I could figure out a few (Like add, subtract, and check to see if this is here). (Most of you probably know this, but I can't find info on it anywhere). I just copy/ do what tutorials tell me to do and copy and paste from the other sections of the Sonic 1 ASM Code. I know what a few things do but these labels are so confusing :P . If someone could tell me what each Label does or point me in the right direction to find out what these all stand for, it would be greatly appreciated! :)
    • -1

    #2 Ravenfreak

    Ravenfreak

      The 8-bit games need more love!

    • Pro User
    • 249 posts
    • Gender:Female
    • Location:O'Fallon, MO
    • Interests:Hacking both the 8-bit and 16-bit Sonic games, collecting Sonic merchandise, cats, hedgehogs.

    Posted 06 January 2012 - 03:47 AM

    First off, the w after "move" means word. A word is a two-byte value, while a byte consists of two nibbles (or just one digit.) You might also come across a move.l, which means you're moving a longword value. For example this is a word:
    01 02 and this is what a byte looks like: 03. Now move.w means you're moving a word value to another address or register. Sub.w means you're subtracting a word from another value whether it be a register, or an address. Of course, this is all from memory as I haven't touched any of the 16-bit Sonic games in a long time. So I suggest you also check out these two guides on Sonic Retro:
    http://info.sonicret...Instruction_Set
    http://info.sonicret...ssembly_Hacking
    I hope that helps. :P
    • 1

    #3 DarkLeach

    DarkLeach

      Behold the Power of DarkLeach7! Tomorrow...

    • Member
    • 193 posts
    • Gender:Male
    • Location:I don't even know...

    Posted 06 January 2012 - 04:28 AM

    I see all the commands that I've been Having trouble with! Thanks! :) , I'll study them whenever I get some time and be able to do what I want to do. However on the Instruction Page, I didn't see "BCS" What does that do? :P
    • 0

    #4 Crash

    Crash

      8 Chaos Emeralds

    • Member
    • 216 posts
    • Gender:Male
    • Location:Australia

    Posted 06 January 2012 - 07:40 AM

    Here's a really good beginner ASM tutorial that MarkeyJester wrote: http://mrjester.hapisan.com/04_MC68/
    • 0

    #5 Dandaman955

    Dandaman955

      6 Chaos Emeralds

    • Pro User
    • 699 posts
    • Gender:Male
    • Location:North Wales

    Posted 06 January 2012 - 04:52 PM

    I'm sure BCS branches when a certain bit is set. The other would be BCC.
    • 0

    #6 GT Koopa

    GT Koopa

      2 Chaos Emeralds

    • Member
    • 84 posts
    • Gender:Male
    • Location:Elgin. IL

    Posted 08 January 2012 - 12:54 AM

    http://68k.hax.com/

    This is the site I use. Still can't make heads or tails of most of it but in general it is a big help.
    • 0

    #7 MarkeyJester

    MarkeyJester

      We're all mad here

    • Pro User
    • 1842 posts
    • Gender:Male

    Posted 08 January 2012 - 06:22 AM

    BCS = Branch if Carry Set
    BCC = Branch if Carry Clear

    The processor has its own set of flags to determin the conditions (or "results") of your instructions, there are 5 as I understand it C (Carry), V (oVerflow), Z (Zero), N (Negative), X (eXtended):

    The instructions above reads the carry flag to see if it is set or cleared, an example of the instrution in use:

    Recheck:
    add.b d0,d0
    bcc Recheck


    If we were to imagine that d0 was 00 00 00 08, as we're only adding a byte, we only need to pay attention to the 08, now 08 in binary is 0000 1000.

    So, adding d0 to d0 means adding 08 to 08, this results in 10. With 08 in binary meaning 0000 1000, and 10 in binary meaning 0001 0000, all that's happened here is the bits have shifted left:

    C d0
    
    v v
    
    - 0000 1000
    < Shift left once <
    C d0
    
    v v
    
    0 0001 0000

    Now you can see the very far left bit (a.k.a. the most significant bit) has shifted so far, it has gone outside the byte space, this bit is sent to the carry flag as the carry bit, now the carry flag = 0 (it is now clear).

    The next instruction is branch if carry is clear, now it was cleared by the add instruction, so it branches back to "Recheck".

    Once again, it adds d0 to d0, 10 + 10 = 20:

    C d0
    
    v v
    
    0 0001 0000
    < Shift left once <
    C d0
    
    v v
    
    0 0010 0000

    Once again, 0 has shifted into the carry flag, so bcc branches back to "Recheck", adding again d0 to d0, 20 + 20 = 40:

    C d0
    
    v v
    
    0 0010 0000
    < Shift left once <
    C d0
    
    v v
    
    0 0100 0000

    Again, 0 has shifted into the carry flag, so bcc branches back to "Recheck", adding again d0 to d0, 40 + 40 = 80:

    C d0
    
    v v
    
    0 0100 0000
    < Shift left once <
    C d0
    
    v v
    
    0 1000 0000

    And again, 0 has shifted into the carry flag, so bcc branches back to "Recheck", adding again d0 to d0, 80 + 80 = 100:

    C d0
    
    v v
    
    0 1000 0000
    < Shift left once <
    C d0
    
    v v
    
    1 0000 0000

    This time, 1 has shifted into the carry flag, so now bcc will not branch as carry is set, it will now resume.
    • 0

    #8 Irixion

    Irixion

      6 Chaos Emeralds

    • Pro User
    • 595 posts
    • Gender:Male
    • Location:Ontario, Canada

    Posted 10 January 2012 - 05:06 AM

    Oh Jester, you can't expect him to completely understand that!

    I'd suggest reading up the basic commands of ASM here: http://info.sonicret...68000_assembly The guide assumes you know what hex is and how it basically works, and the guide will teach you the basics. It's all (usually) logical, and the more complex things aren't really related to ASM, but how the game itself is set up. At times this can be mind melting even for the best of us.


    Edit: Ninja'd, but seriously, go read it again.

    Edited by Irixion, 10 January 2012 - 06:26 PM.

    • 0

    #9 DarkLeach

    DarkLeach

      Behold the Power of DarkLeach7! Tomorrow...

    • Member
    • 193 posts
    • Gender:Male
    • Location:I don't even know...

    Posted 10 January 2012 - 05:37 AM

    Oh Jester, you can't expect him to completely understand that!

    I'd suggest reading up the basic commands of ASM here: http://info.sonicret...68000_assembly The guide assumes you know what hex is and how it basically works, and the guide will teach you the basics. It's all (usually) logical, and the more complex things aren't really related to ASM, but how the game itself is set up. At times this can be mind melting even for the best of us.


    Edit: Ninja'd, but seriously, go read it again.


    I'd read this but there is no text on the page. :o Is it broken? Oh and MarkeyJester your tutorial that someone linked to in this thread is great! I haven't finished it yet, I read it when I have some time and the 68k commands and the RAM stuff makes a lot more sense ( I think I'm on page 20 now). I know what Hex is and it isn't that hard once you understand. I'm taking Computer Science I (This year we're learning about Visual Basic) and this ASM stuff is making a lot more sense. (Obviously not the 68k commands and system calls but still ;) )
    • 0

    #10 Irixion

    Irixion

      6 Chaos Emeralds

    • Pro User
    • 595 posts
    • Gender:Male
    • Location:Ontario, Canada

    Posted 10 January 2012 - 06:25 PM

    Seems SSRG mucked up the link--get rid of the period at the end of it. It was linked earlier in the topic but it's still a good read.
    • 0




    0 user(s) are reading this topic

    0 members, 0 guests, 0 anonymous users