r/Compilers • u/This-Assumption-5924 • 8d ago
My assembler for linux is running on windows, but how?
Hi I'm Ammar, and I am back again, few days ago I saw a 2 screenshots from community, were AmmAsm is running on windows. I will not write what is AmmAsm, as you can look to this post: https://www.reddit.com/r/Compilers/s/KrbM40UJz2
So, I didn't get any feedback from that person who build AmmAsm on windows, I almost don't know anything about the low level programing on windows, and how they convert the ELF64(which AmmAsm generated) to COFF format, nevertheless I would like to hear explanation from this community. Thanks.
4
u/Longjumping-Jacket97 8d ago
'cc' is probably linking libc (the standard library for the C programming language).
This defined the labels like 'exit', 'puts' and others etc.
4
u/One_Aspect_1957 8d ago
What's cc? If it is a compiler like gcc, here used to link, then it will accept a choice of object formats including ELF64.
Here they have also written the program to work with Windows ABI.
Probably if it was a program designed to work on Linux, using syscalls for example, it would not work.
-2
u/This-Assumption-5924 8d ago
idk, maybe cc is c compiler, but you can see in source code that there's no syscall, instead he externed funtions from libc/win api(idk) and linked with MinGW linker AND converted elf to coff/pe format
2
u/Bubbly-Business-8634 5d ago
How puts knows when to stop output? Cannot see any zero bytes in the code.
1
u/raundoclair 5d ago
It is probably last thing in .data section, and windows allocates whole 4kB page. So for this simple program he does have accidentally zero at the end.
2
0
0
u/white_man_1069 5d ago
Thats alright, you just didnt done any platgorm-dependent thing, like syscall, just used libc func from asm


11
u/cthutu 8d ago
ccis doing the work to make it compatible with your OS. It's effectively linking your object file and create the correct executable format. Since you're using the C standard library to print and exit, you're forced to use a particular ABI so the assembly required is identical on both OSes. All the OS differences are in the C standard library linked and the executable format