如何将C ++代码转换为汇编,以便我可以使用Emu8086编译它? [英] How Do I Convert C++ Code To Assembly So I Can Compile It Using Emu8086?
本文介绍了如何将C ++代码转换为汇编,以便我可以使用Emu8086编译它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include < stdio.h >
int main(){
printf( ABCDEFGHIJKLMNOPQRSTUVWXYZ 跨度>);
}
i尝试使用 g ++ -S test1.cpp -o test1.o $ c在windows下编译C ++代码以上$ c>获得组装。但它看起来不像我以前在emu8086中使用的组件。它看起来像这样:
.filetest1.cpp
.def ___main; .scl伪2; .TYPE 32; .endef
.section .rdata,dr
LC0:
.asciiABCDEFGHIJKLMNOPQRSTUVWXYZ\ 0
.text
.globl _main
。高清_main; .scl伪2; .TYPE 32; .endef
_main:
LFB7:
.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)
调用_printf
movl $ 0,%eax
离开
........................... ........ blablablabla
我曾经在emu8086中编写程序集,如下所示:
ORG 100H
TDATA:JMP PROCESS
KAL DB'TEXTTEXTTEXTTEXT',10,13,'$'
流程:MOV CX,11H
XOR BX,BX
LEA DX,KAL
打印:MOV AH ,09H
INT 21H
INC BX
CMP BX,CX
LOOP PRINT
INT 20H
END TDATA
任何想法都将受到赞赏。
谢谢
- 鲁迪
解决方案
-16,%esp
subl
16,%esp
调用___main
movl
LC0,(%esp)
调用_printf
MOVL
#include<stdio.h>
int main(){
printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
i tried to compile above C++ code under windows using g++ -S test1.cpp -o test1.o
to get the assembly. but it didn't look like an assembly like i used to use in emu8086. it looked like this:
.file "test1.cpp"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "ABCDEFGHIJKLMNOPQRSTUVWXYZ\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
LFB7:
.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
...................................blablablabla
I used to write assembly in emu8086 like this:
ORG 100H
TDATA: JMP PROCESS
KAL DB 'TEXTTEXTTEXTTEXT',10,13,'$'
PROCESS: MOV CX,11H
XOR BX,BX
LEA DX,KAL
PRINT: MOV AH,09H
INT 21H
INC BX
CMP BX,CX
LOOP PRINT
INT 20H
END TDATA
any idea will be appreciated.
Thanks
--Rudy
解决方案
-16, %esp subl
16, %esp call ___main movl
LC0, (%esp) call _printf movl
这篇关于如何将C ++代码转换为汇编,以便我可以使用Emu8086编译它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文