Coffeehouse Post

Single Post Permalink

View Thread: Machine code
  • User profile image

    The most common assembler for handwriting x86 is NASM (the Netwide assembler). It uses Intel syntax, which is the same as WinDbg and Visual Studio's syntax. FASM, MASM and GAS tend to have peculiarities because they're either really old, or really intended as a compiler back-end.

    But if you're just interested in playing with assembler, create a C project (in visual studio) and do this:

    __declspec(naked) foo()
        int 3
        mov eax, 0xaabbccdd

    void main()
      int result = foo();
      printf("%08x\r\n", result);

    "int 3" gives you a manually inserted breakpoint so you can step through the function.

    You can also right click the program at any breakpoint when you're running C or C++ code and click "view disassembly" to show the output of the compiler. You'll notice there that the code is much less understandable but also much shorter when running release builds.

    Finally you can right click in the disassmbly window to "Show Code Bytes", which will show you the actual opcodes that are being sent to the processor.