I've learnt that compiler produces object code as an output or an assembly language program.
So can I see assembly language program produced as an output of high level language program?
I've learnt that compiler produces object code as an output or an assembly language program.
So can I see assembly language program produced as an output of high level language program?
Since you didn't state which language you're using, I'll assume it's a native one (i.e. a language that translates into assembly, like C not bytecode, like java).
In that case, you can use objdump -D to produce the assembly output:
objdump -D [yourfile]
I wrote a tutorial on this, http://www.staerk.de/thorsten/Assembler_Tutorial#translate_C_to_assembler has a C program
#include <stdio.h>
int main()
{
int i=0x23;
printf("hello world");
}
And translates it under Linux with the command
gcc -o hello.asm -S assembler_file.S
To assembler-code that looks like:
movl $.LC0, %edi
movl $0, %eax
call printf
Note that this way is gcc-specific. The other way to obtain the assembler code is of course to build the executable program and then disassemble it with objdump -d. This will work with any compiler.
Datei: Q4_ASEM.BAS Stand: 05.06.88 Microsoft Quick Basic 4.0
DEFINT A-Z
DECLARE FUNCTION Addieren (A AS INTEGER, B AS INTEGER)
' Assembler-Funktion --^
PRINT " QuickBASIC ruft Assembler"
INPUT " A = "; A
INPUT " B = "; B
Ergebnis = Addieren(A, B)
PRINT "Ergebnis ="; Ergebnis
'------------------------------
' Objektdatei mit BC erstellen
' C>bc a:q4_asem
Datei: BASIC.ASM Stand: 05.06.88 Microsoft Macro Assembler 5.0
.MODEL medium
.CODE
PUBLIC Addieren
Addieren PROC
push bp
mov bp,sp
mov bx,[bp+8]
mov ax,[bx]
mov bx,[bp+6]
mov cx,[bx]
shl ax,1
shl ax,1
add ax,cx
pop bp
ret 4
Addieren ENDP
END
;---------------------------------------
; C>masm basic
; C>link
; Object Modules [.OBJ]: q4_asem+basic
;---------------------------------------