Pseudo code to bytecode converter ?

This topic is 3498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi everyone , i'll try to be quick ... I'm looking for a tool (or something similar) that will convert some pseudo script code into bytecode so i can actually study a little bit better what's going on when , for example ,calling a function , or jumping outside of scope. For example , it should be able to turn this code:

some_variable   a = 1;


into this (just an example):

BC_POPA get from stack intptr(addr) ( a = 1 )


or something similar ... Any ideas if such a thing exists ???

Share on other sites
Quote:
 Original post by 3DgonewildAny ideas if such a thing exists ???
It is called a compiler, and the 'bytecode' it produces is assembly language [smile]

Most compilers have an option to produce assembly, for gcc you provide the -S option on the command line, not sure about MSVC.

Share on other sites
Quote:
 Original post by 3Dgonewildcalling a function
Even some things as simple as calling a function do different things in different languages and on different platforms. For instance, a function call in C behaves differently from a function call in Objective Caml, and within the C language a __cdecl call is different from an __stdcall.

As swiftcoder explains, most compilers provide a switch to output assembly instructions so you can look at them.

Share on other sites
For MSVC you'd want the /FA family of switches. Generally I use /FAs to get intermixed assembly and source code, but you can also use /FAc to get the actual machine code.

Share on other sites

Thanks all for the replies , -S flag is exactly what i've been looking for!

Some quick tests :

	int i = 22;

->>>>>>>>>>>>>>>

	.file	"main.cpp".globl i	.data	.align 4	.type	i, @object	.size	i, 4i:	.long	22	.ident	"GCC: (Ubuntu 4.3.2-1ubuntu11) 4.3.2"	.section	.note.GNU-stack,"",@progbits

void jmp_test(){	bool jmp = false;	if(jmp)	{		int something_to_test_jmp = 1;	}else{		int something_to_test_jmp = 0;	}}

->>>>>>>>>>>>>>>

	.file	"main.cpp"	.text.globl _Z8jmp_testv	.type	_Z8jmp_testv, @function_Z8jmp_testv:.LFB2:	pushl	%ebp.LCFI0:	movl	%esp, %ebp.LCFI1:	subl	$16, %esp.LCFI2: movb$0, -1(%ebp)	cmpb	$0, -1(%ebp) je .L2 movl$1, -8(%ebp)	jmp	.L4.L2:	movl	\$0, -12(%ebp).L4:	leave	ret.LFE2:	.size	_Z8jmp_testv, .-_Z8jmp_testv	.ident	"GCC: (Ubuntu 4.3.2-1ubuntu11) 4.3.2"	.section	.note.GNU-stack,"",@progbits

• 37
• 12
• 10
• 10
• 9
• Forum Statistics

• Total Topics
631362
• Total Posts
2999570
×