0

Is there some sort of program that allows you to see Machine code and C++ code side by side like how Netwide Assembler does it?

For example

machine code here #include <iostream>
                  
machine code here int main() {
machine code here    cout << "Hello, World!";
                  }

and how NASM does it

     1                                  section .text
     2                                      global _start
     3                                      
     4                                  _start:
     5 00000000 66B804000000                mov eax,4
     6 00000006 66BB01000000                mov ebx,1
     7 0000000C 66B9[00000000]              mov ecx,message
     8 00000012 66BA0D000000                mov edx,len
     9                                      
    10 00000018 CD80                        int 0x80
    11                                      
    12 0000001A 66B801000000                mov eax,1
    13                                      
    14 00000020 CD80                        int 0x80
    15                                      
    16                                  section .data
    17 00000000 48656C6C6F2C20576F-         message db "Hello, World!"
    17 00000009 726C6421           
    18                                      len equ $-message
LuaCoder
  • 1
  • 1
  • 3
    Check out https://godbolt.org/ – Brecht Sanders Apr 17 '22 at 08:38
  • @BrechtSanders While that is interesting, that is not what I am exactly looking for. Sorry, for not being clear, what I'm looking for is something that converts the C++ code to something like the hex next to the x86 assembly code. – LuaCoder Apr 17 '22 at 09:16
  • 1
    @LuaCoder You can turn on hex if you want: https://godbolt.org/z/WfYrGK3Ms – Ranoiaetep Apr 17 '22 at 10:25
  • 1
    `objdump -dS` interleaves source lines and normal objdump disassembly, as in the top answer on [How do you get assembler output from C/C++ source in gcc?](https://stackoverflow.com/q/137038). If you want hex machine code, not just asm source for some reason, that's probably a good way to go. I find the Godbolt "binary mode" output looks messy and hard to read. – Peter Cordes Apr 17 '22 at 10:43
  • You need a disassembler to inspect the generated code. In the past I have used hiew (hacker's view) for this but don't know if this is still an active project – Brecht Sanders Apr 17 '22 at 13:25

0 Answers0