Differences between Win32 assembly and 8086 assembly

Source: Internet
Author: User

 

Win32ProgramWhen running in protection mode, the history of protection mode can be traced back to 80286. In Windows, every Win32 application is put to a separate virtual address space for running. That is to say, each application has an independent 4 GB address space, of course, this does not mean that they all have 4 GB physical address space, but that they can be addressed within a 4 GB range. The operating system converts the 4 GB virtual address and the physical memory address when the application is running. This requires that the compiling of applications must comply with Windows specifications, otherwise it will easily cause memory protection mode errors. In the past Win16 memory mode, all applications run in the same 4 GB address space. They can "see" other program content to each other, this can easily cause one application to corrupt the data of another application or even the operating system.Code.

Unlike the memory mode in which code is divided into data and code segments in 16-bit windows, Win32 only has one memory mode, namely, flat mode,It means the "flat" memory mode without the 64 K segment size limit. All Win32 applications run in a continuous, flat, huge 4 GB space. This also means that you do not have to deal with segment registers.In this way, you do not need to consider the stack segment address and the segment address. You only need to care about their offset addresses..

You can use any segment register to address any address space, which is very convenient for programmers. This makes it as convenient to use a 32-bit assembly language as a C language. Programming in Win32 requires many important rules to be followed. One important thing is that Windows frequently uses ESI, EDI, EBP, and EBX registers internally, and does not check whether the values of these registers are changed, in this way, when you want to use these registers, you must first save their values and restore them after they are used up. The most significant application example is the Windows callback function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.