so, I have this asm code with me and i wish to use it inline with c++, (a combo of asm and cpp)
i have seen many links for this but none answer how to do this, the asm code is below
.text
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0: <<<<<<< ********************************************** LC0 is here
.ascii "Hello, world!\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
LFB15:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $16, %esp
call ___main
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
LFE15:
.ident "GCC: (MinGW.org GCC-8.2.0-3) 8.2.0"
.def _printf; .scl 2; .type 32; .endef
SO, yeah. can someone pls write the code with the asm above? its just a simple hello world program.
btw, it was devived from a c code so yeah, im trying to convert one language to another(using inline in the other)
What I have tried:
I have tried to do this:
#include<iostream>
using namespace std;
int main() {
__asm__(
"pushl %ebp;"
"movl %esp, %ebp;"
"andl $-16, %esp;"
"subl $16, %esp;"
"call ___main;"
"movl $LC0, (%esp);"
"call _printf;"
"movl $0, %eax;"
"leave;"
"ret;"
);
}
but without the var $LC0, it doesn't work. and i have no clue how to do this,
please help me, and PLEASE DONT PROVIDE ANY LINKS!
I have seen all links and none actually help me, so, pls write down the code for me.