1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Tutorial] ASM - Level: Beginner (Pre request for Tutorial 4 of hack making)

Discussion in 'Programming' started by DarkSpace, Sep 11, 2010.

  1. DarkSpace

    DarkSpace Well-Known Member Coder

    Ok guys, Before i make Tutorial 4 for the trainer in c++ i'll have to explain some ASM to you.
    Because ASM (Assembly) is quite a big subject to fit into just 1 tutorial. i'll have to write few little tutorials
    to cover the basics. Then we can move on with C++ Trainers and hacks.

    Is Any Pros see something wrong with my tutorial leave a message and i'll correct it.

    What is Assembly?
    Assmebly is what all comes down to. what ever program you make will be kinda translated into ASM language.
    its the most basic, simplest form of programming language.

    What we need to remember When dealing with ASM in C++
    ALWAYS PUT 0x in front of numbers.

    Lets look at a simple ASM code

    Code (Text):
    2. MOV EAX, 0x01
    MOV = MOVE.
    It will move the value thats on the right hand side INTO the Variable on the left hand side.

    That would be like saying

    Following code isnt asm but its to prove an example

    MOV Can, Pepsi

    what is in the can now?
    Its Pepsi.

    Next thing we are going to look at is cmp

    Code (Text):
    2. CMP EAX, 0x01
    CMP = Compare
    It will compare Left side(EAX) with the right (0x01). Depending on the result of the compare we can execute different code using Jumps

    example of cmp and jump would be

    Code (Text):
    2. MOV EAX, 0x01
    3. CMP EAX, 0x01
    4. JE valueIsSame
    5. JNE valueIsntSame
    If EAX is 0x01 valueIsSame will execute
    else if EAX is greater or lower than 0x01 valueIsntSame will execute

    In our case We Moved 0x01 into EAX, so EAX's Value is 0x01.

    Now lets look at the Jumps

    There are quite few Jumps available for us. We'll just cover the basic ones.

    JMP = JUMP // This will always jump to a label or address that comes after
    JE = JUMP IF EQUAL // This will only activate if cmp values are equal
    JNE = JUMP IF NOT EQUAL // This will only activate if cmp values arent equal.
    JG = JUMP IF GREATER // This will only run if left hand's value is greater than right hand's value
    JNG = JUMP IF NOT GREATER // If left hand value is lower than right hand value
    JL = JUMP IF LESS // If left hand value is less than right.
    JNL = JUMP IF NOT LESS // If left value is not less than right hand value

    Now lets have a look at Labels.

    Labels help us when we need to run a different kind of code depending on what our values are

    Code (Text):
    2. MOV EAX, 0x01
    3. CMP EAX, 0x01
    4. JE valueIsEqual
    5. JNE valueIsntEqual
    7. valueIsEqual:
    8. MOV EAX, 0x02
    9. CMP EAX, 0x01
    10. JL valueIsLess
    11. JG valueIsGreater
    13. valueIsntEqual:
    14. JMP valueIsGreater
    16. valueIsGreater:
    17. MOV EAX, 0x03
    18. CMP EAX, 0x01
    19. JE valueIsEqual
    20. JNE valueIsntEquail
    A label is made with a name of the label followed by a colon ( : ), A name can be Anything as long
    as it doesnt start With A number.

    The script above will start off by Moving 0x01 into EAX
    Then we Compare EAX with 0x01.
    if the value is equal we'll go to valueIsEqual
    if EAX isnt equal to 0x01 we go to valueIsntEqual

    In this case. EAX is 0x01. so we ignore the rest of the code and go to valueIsEqual
    we continue on by reading the values there

    We move 0x02 into EAX
    compare EAX with 0x01
    now we are testing if EAX is less than or greater than 0x01.
    EAX is Greater than 0x01 so we go to the label valueIsGreater

    now we continue reading the code from valueIsGreater
    We move 0x03 into EAX
    Compare EAX with 0x01
    Again we test if value is Equal or Not Equal
    in this case, EAX is not Equal to 0x01
    So we go to valueIsntEqual

    only has 1 bit of code

    now every time value isnt equal.
    we are going to jump to valueIsGreater.

    and thus create a constant loop

    I'll Create 1 or 2 more of these tutorials to cover all things we need to start converting hacks like 7Miss Godmode, PVACs
    and other.
    • Like Like x 3
  2. NonLeaf

    NonLeaf Well-Known Member

    Nice one w8Dark as always :)
  3. fag

    fag Banned Banned

    The CMOVcc instructions are pretty useful.
  4. spunge

    spunge Well-Known Member Retired

    CMOVcc has limited use.
    Anyways, if you're planning on supporting x64, inline assembly is a no go. Look into intrinsics.

    The best way to learn assembly is to go grab the Intel docs. You're missing important information, e.g., EFLAGS. The way your code snippet branches is also clumsy.
  5. Razz

    Razz Dedicated Supporter Dedicated Donor

    Most people here just want to learn it for maple hacking. Then its no need to learn the whole asm language.
  6. highlights

    highlights Well-Known Member

  7. spunge

    spunge Well-Known Member Retired

    If you really want to know how to hack maple, then you MUST know assembly.
  8. DarkSpace

    DarkSpace Well-Known Member Coder

    i dont care if there are other tutorials and if they cover more. i just want to cover the basics of what tutorial 4 will need people to know.

    if they need to know more about asm then they can search around the net. but thanks for the replies tho =D

    good luck
  9. DarkSpace

    DarkSpace Well-Known Member Coder

    at the end of my tutorial i said there is gonna be more of tutorials to cover the rest.
    also again in my last post i said i just want people to understand what im talking about when i do the tutorial.
    so i am not going into details about all jumps out there.
    because most hacks that are out dont even use more than 4 =S

    so if anyone doesnt like the way i do this, feel free to make your own
  10. NonLeaf

    NonLeaf Well-Known Member

    W8Dark your doing an awesome job , keep it up man :]
  11. Nebbis

    Nebbis Banned Banned

    Thanks bud :)
  12. Krow

    Krow Well-Known Member

    can sumone help me with this code plz
  13. DarkSpace

    DarkSpace Well-Known Member Coder

    didnt say you said that =P. and yea i'll do add, sub, inc, push, pushad, pop, popad, and call in the next thread.
    and they are just the basic things that will be needed to convert a simple AA script

    i could go into conversion of AA -> C++ but then what? people wont know what any of those things mean in the code.
    so when they run into some problems, errors they dont know whats making it.

    i had it also with few scripts where i had to go and learn what things meant to know more about the script. also
    edit the script to something else(kami) by changing things around and adding new values =D
  14. Kyuute

    Kyuute New Member

    It always looks so simple with your tuts.
    Great great great job!
  15. DarkSpace

    DarkSpace Well-Known Member Coder

    push eax, 0x00

    i'll explain what push does in later tutorial but for now

    push will kinda back up your eax and put it aside.

    mov eax, 0x09 //eax here is 9
    push eax //backs it up
    mov eax, 0x02 //now eax is 2
    pop eax //now eax is 9 again, it restores eax to what it was when you pushed it.

    now what push eax, 0x00 does.
    is backs up eax and sets it to 0
    so when its restored back, its gonna be 0

    shorter version of
    MOV eax, 0x00
    PUSH eax
  16. David...

    David... Banned Banned

    Fucking lol'd..


    Code (Text):
    1. mov can, pepsi
    that's fail code right thar..
    unless either can/pepsi is a definition..
    mov [can], pepsi
    that makes more sense
    but the size of pepsi is still unknown

    Code (Text):
    2. valueIsntEqual
    3. only has 1 bit of code
    valueIsntEqual has 2 bytes of code...
    eb *

    EDIT: not saying this tut sucks btw o:
  17. DarkSpace

    DarkSpace Well-Known Member Coder

    as i stated before i write can/pepsi statament

    there i was using real life example of
    a can that can contain anything at all and i choose to put pepsi in it

    now when ever i want to see what my can contains, it will always contain the thing i put into it.

    Code (Text):
    2. valueIsntEqual
    3. only has 1 bit of code
    it has 1 BIT of code, not bit as in 8bits = 1 byte
    but as in 1 bit as in

    1 thing
    1 line,
    1 sentince
    only 1 thing is happening in that label.

    i never expected the famous DAVHEED to post without reading... o.o

    anyhow thanks for your comment. again if anyone doesnt like the way i do this, go write your own, simple as that
  18. spunge

    spunge Well-Known Member Retired

    push does not set registers aside. push is used in order to put a value onto the stack.
  19. DarkSpace

    DarkSpace Well-Known Member Coder

    true true. but can also be used to backup old values stored in registers for hacking maplestory for example

    after you return out of the asm if registers dont match what they are suppose to match to, the game will crash
    that is why we push a register, change it to what ever we like, at the end pop it back.

    also a stack is like some sort of an array. first thing pushed is last in the stack, last thing will always get popped out 1st.

    but you are correct, push is used to push registeres to a stack
  20. devilboyzakk

    devilboyzakk Well-Known Member

    thank you it's a simple guild. verry usefull

Share This Page