Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Teaching myself Assembly

  1. Jul 14, 2015 #1


    User Avatar
    Gold Member

    I want to teach myself Assembly language, so I downloaded the next text:
    http://www.ic.unicamp.br/~pannain/mc404/aulas/pdfs/Art Of Intel x86 Assembly.pdf
    and the next software:

    Do I need to download anything else?
    in the first link it says the packages that are used in the text can be downloaded from the website:

    but the latter ftp site doesn't seem to work anymore.
    Does someone know where may I found the packages that were in this site?

    Thanks in advance.
  2. jcsd
  3. Jul 14, 2015 #2


    User Avatar
    Gold Member

    First of all: Thank you for the link. I've missed it.

    I don't think that you can make some usable program, only using assembler code ( all this Windows-XX ). But you can include assembler-code in some inner loop in a high-level-language like C or Fortran, speeding up the calculations very much. You can do anything with assembler ( also bugs ).

    In some languages you can just write:

    pop eax
    pop ebx
    sub eax,ebx
    jnz somewhere


    Also you can link assembler-coded functions/procedures/libraries into the high-level language, where a binary-to-object converter is needed.

    What I'm saying is: Consult the high-level language to be used as for the output-format from the assembler to be accepted. Many high-level languages are included in an "IDE" that contains what is needed.

    Hope you will enjoy it.
  4. Jul 14, 2015 #3


    User Avatar
    Gold Member

    Does the book above compatible (with the syntax) with flat assembler?

    I have quite a long list of stuff to learn this summer... :-D
  5. Jul 14, 2015 #4


    User Avatar
    Gold Member

    As for the "machine instructions" the syntax must be the same.

    There may be some difference as for pseudo instructions, but if you have some "mismatch" ( the assembler will tell you ), just look the correct syntax up as for the flat assembler in its manual. That's the least problem.

    Just start with a small loop, or even a simple high-level statement. Substitute it by assembler, make it work, and expand the substitutions from here.
  6. Jul 14, 2015 #5


    Staff: Mentor

    If you have Microsoft Visual Studio, you can write assembly code either inline or as standalone files. If you're concerned about the cost, the Express version is free.

    The example below has two functions that take two args and return the sum of the passed args. The second function (mySumOfInts) is coded in inline assembly. Writing just the body of the function eliminates a lot of extra work that normally has to be done when you write pure assembly, such as keeping track of the stack frame and copying the parameters from the stack.

    Note: I'm using VS 2013, in which scanf is obsolete, so I'm using the MS-specific scanf_s function.

    Code (C):


    int SumOfInts(int, int);
    int mySumOfInts(int, int);

    int main(void)
       int sum;
       int a, b;
       printf("Enter a: ");
       scanf_s("%d", &a);
       printf("Enter b: ");
       scanf_s("%d", &b);
       sum = SumOfInts(a, b);
       printf("The sum is %d\n", sum);
       sum = mySumOfInts(a, b);
       printf("The sum is %d", sum);
       return 0;

    int SumOfInts(int first, int second)
       return first + second;

    // Assembly version of the above function
    // This function copies the first argument to the EAX register and then adds the second argument.
    // When the function returns, the result is in EAX, which is where the caller expects it to be.
    int mySumOfInts(int primero, int segundo)
       _asm {
       mov eax, dword ptr[primero]
       add eax, dword ptr[segundo]
    Last edited: Jul 14, 2015
  7. Jul 14, 2015 #6


    User Avatar
    Gold Member

  8. Jul 15, 2015 #7


    User Avatar
    Gold Member

    @256bits , does the software in the last link in the website you gave correspond to the version being used in the book I gave a link here?
  9. Jul 15, 2015 #8


    User Avatar
    Science Advisor

    If you use an assembler make sure the linker recognizes your files. You will get an error if you use a linker to link an object file with a different format.
  10. Jul 15, 2015 #9


    User Avatar
    Gold Member

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook