First Win32 assembler basic concept
Win32 program runs in protection mode, Windows puts each Win32 application into a separate virtual address space, that is, each application has its independent 4GB address space, the operating system will apply When the program is running, the conversion between 4GB virtual addresses and physical memory addresses is divided into DATA, and the memory mode is divided into DATA. The memory mode is different. Win32 has only one memory mode, which is Flat mode, all Win32 The application is running in a continuous, flat, huge 4GB space. This also means that you don't have to deal with segment registers, you can use any segment register addressing any address space, which makes it as convenient to use 32-bit assembly languages and as C language.
Programming under Win32, there are many important rules that need to be observed. One is important: Windows frequently uses ESI, EDI, EBP, EBX registers internally, and does not detect if the value of these registers is changed, so when you want to use these registers, you must save their values, stay After using it, restore them, one of the most significant application examples is in Windows's Callback function.
.386; Tell the compiler Our program is available using the 80386 instruction set. 486.586 is the safest. .MODEL flat, stdcall; specifying memory mode, parameter delivery mode, and call function Who will resume stack (caller or function) .DATA; Note that Win32 has a segment (sectionment) concept, but you can divide the program into different segments. There are only two DATA and CODE
The segmentation is not like the DOS, respectively indicates different segment registers, respectively, because there is only one 4GB segment under Windows, and the segmentation performance in the Windows program is different segmentation when the program is loaded. Properties, for example, when your program is loaded, for Ring3 programs, the .code segment is not writable, and .DATA segment is writable, if you try to write your own code part as in DOS, you will Get a blue screen error