解決 Forth 整合C問題

56 views
Skip to first unread message

燕南

unread,
Jul 31, 2018, 4:16:55 AM7/31/18
to 符式協會
解決 Forth 整合C問題 (未來 C to Forth )






Win32Forth 可以 直接 控制 MINGW 並對 其產生.s 進行加工使用

使用 GNU 工具轉換 C 為組合語言後再修改

gcc -S hello.cpp -o hello.s


http://ccckmit.wikidot.com/as:c2asm



#include <stdio.h>
int main()
{
printf
("Hello, World!");
return 0;
}

 .file "hello.cpp"
 
.def ___main; .scl 2; .type 32; .endef
 
.section .rdata,"dr"
LC0
:
 
.ascii "Hello, World!\0"
 
.text
 
.globl _main
 
.def _main; .scl 2; .type 32; .endef
_main
:
LFB12
:
 
.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
LFE12
:
 
.ident "GCC: (MinGW.org GCC-6.3.0-1) 6.3.0"
 
.def _printf; .scl 2; .type 32; .endef


Reply all
Reply to author
Forward
0 new messages