lasarus / C-Compiler

Yet another C compiler.
28 stars 6 forks source link

-dhalf-assemble #3

Closed icyfox168168 closed 2 years ago

icyfox168168 commented 2 years ago

-dhalf-assemble -fabi=ms -fdebug-stack-size=0 -fcmodel=large

If this parameter is added, the test examples that get the correct results in the previous compilation cannot get the correct results Has the work behind this parameter been completed?

lasarus commented 2 years ago

-dhalf-assemble is still work in progress, and should not really be used. Its purpose is to allow me to more easily implement the assembler. It works by replacing some instructions with the corresponding byte-code. For example movl -28(%rbp), %edi is replaced with .byte 0x8b, 0x7d, 0xe4.

In which way does it not give the correct results? On my system all tests pass with it activated.

icyfox168168 commented 2 years ago

Different results are obtained in an MD5 algorithm

test. C file I send you email

char decrypt[16] ={0};

printf("gg %02x %d \n",decrypt[0],str_len1("88"));

MD5_CTX md5;
MD5Init(&md5);
MD5Update(&md5, "88", str_len1("88"));
MD5Final(&md5, decrypt);

printf("ff %02x %d \n",decrypt[0],str_len1("88"));

cc.exe test.c -fabi=ms -fdebug-stack-size=0 -fcmodel=large -D test.s -IC:\Users\fix\Desktop\C-Compiler-Test\include gg 00 2 ff 2a 2 ret 24

cc.exe test.c -dhalf-assemble -fabi=ms -fdebug-stack-size=0 -fcmodel=large -D test0.s -IC:\Users\fix\Desktop\C-Compiler-Test\include gg 00 2 ff ffffff90 2 ret 23

icyfox168168 commented 2 years ago

The latest version solves the problem

gg 00 2 ff 2a 2 ret 24

icyfox168168 commented 2 years ago

Internal compiler error on line 171 file src/assembler/assembler.c of compiler source: "Could not assemble cmpl"

compiler bddisasm

lasarus commented 2 years ago

I'm not able to reproduce that bug. bddisasm with the example provided in their README.md compiles on my system. In which source file does the error occur?

lasarus commented 2 years ago

I have found the error. It should work with the latest master

icyfox168168 commented 2 years ago

bddisasm\bdshemu\bdshemu.c

bddisasm\bdshemu\bdshemu.c -dhalf-assemble -fabi=ms -fdebug-stack-size=20480 -fcmodel=large -D bdshemu.s -fmingw-workarounds

Internal compiler error on line 180 file src/assembler/assembler.c of compiler source: "Could not assemble cmpl"

icyfox168168 commented 2 years ago

Without -dhalf-assemble everything works fine

lasarus commented 2 years ago

It should be fixed now.

icyfox168168 commented 2 years ago

ok

icyfox168168 commented 2 years ago

Internal compiler error on line 161 file src/assembler/assembler.c of compiler source: "Could not assemble testw 1 1 0 0"

lasarus commented 2 years ago

Encoding for testw was added in latest commit. Since -dhalf-assemble no longer exists, I will close this issue.