I have a (very) basic understanding of assembly using system calls on Linux (I use the GNU assembler as).
On Windows 7, I am using the MinGW (32-bit) port of the GCC compiler suite to produce assembler programs. On Linux I regularily use the C library for some OS interactions in my assembler programs, and on my Windows platform this works perfectly as well using MinGW. Sometimes, however, I want to use low-level system calls -- mostly to keep my executables as small as possible. On Linux I know how to do this:
movl $0, %ebx
movl $1, %eax
int $0x80 ; exit with code 0
I also use these system calls for reading/writing chars to/from the terminal (for writing syscall with 4 in EAX for example). I was wondering how to do this on a Windows NT platform. Is it possible? I looked at this table, but I don't really understand the names of the syscalls. Any help is welcome.
calling a library wrapper function doesn't usually save much code size, especially if you're missing well-known optimizations likexor %ebx,%ebxinstead ofmov $0, %ebx. Also,int 0x80on Linux is the slow legacy way to invoke the 32-bit ABI. The recommended way is to call into the VDSO so it can usesysenterfor better performance. blog.packagecloud.io/eng/2016/04/05/…xor ebx, ebx; lea eax, [ebx + 1]. orxor eax, eax; cdq; inc edxwhich costs only 4 bytes (5 in x86_64)