EMU8086 is an emulator, assembler,...etc. for 8086 16bits code only. It emulates old 16 bits DOS OS. Specifically the code you used starting with an ORiGin metainstruction denotes the writing of a binary '.com' executable (by default located at adrress 0x100). To print out characters you use DOS interrupt calls (INT 21H).
Actual Os's are 32/64 bits they use a different memory layout, and are normally located at 0x40000, but can be reorganized by linker. In actual code the program will start normally from runtime library (i.e. MSVCrt.lib/MSVCrt.dll) that then call your entry point (main, wmain, WinMain, etc. depending on subsystem choosed in the linker). In actual programs '
printf
' is a library function, not a a DOS call, so the compiler generates code to call it.
In modern OS's there is a standard sequence of instructions to save actual stack pointer and allocate space for local variables (on top of stack) called '
preamble
'. The preamble is what seems so strange to you...
Why I made this so complicated? Because nowadays is it a little bit more complicate than the old DOS days :(.
The assembler you got from gcc is for a 32bit PE executable, not for 8086 16bits old DOS :).
Moreover your assembly (as supported by MS MASM) is INTEL syntax, while GCC use AT&T assembly syntax that is the deafult GAS (GNU ASsembler) format. See
here[
^] for AT&T syntax.
Look
here[
^], you'll find a llot of tutorials. Just after reading the first you'll get surprisingly a better understood of the assembler you got from GCC ;).
P.S. Try adding '
-masm=intel
' to you g++ command line it should emit assembler in INTEL syntax.