DoctorWkt / acwj

A Compiler Writing Journey
GNU General Public License v3.0
10.55k stars 1.02k forks source link

does not generate correct code for Windows #47

Open szdytom opened 2 years ago

szdytom commented 2 years ago

I tired to port the compiler to Windws but there are some errors:

Generated out.s does not compile correctly on Windows.

GAS(the AT&T asm) on Windows don't work identical, it have a little difference about psedo-ops. So I wrote a cg.c for NASM.

It passes the compiling stage, but it still faces a runtime error. It seems because of something called shadow storage on Windows:

The x64 Application Binary Interface (ABI) uses a four-register fast-call calling convention by default. Space is allocated on the call stack as a shadow store for callees to save those registers. https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170

the x64 calling convention on Windows it very different (and hard to understand for me), do you have any idea on fixing this?

ravenleeblack commented 1 year ago

Is your nasm cg.c available @szdytom?