Far and near two pointers in C/A + +

Source: Internet
Author: User

Dos is designed to be based on 16-bit CPUs, that is, each register (register) in the CPU is only 16 bits, only the value of 0-65535 (64K) can be stored. In order to access more than 64K of memory, people used a segmented method, with two 16-bit number to record the logical address, the first is the segment value (Segment), the second is the offset (offset), the written format is generally the segment value: Offset. such as 0100:0020 (16 binary, the address is usually in hexadecimal digits). This will have a 32-bit address. Strictly speaking, because of the hardware, the segment value of bits (hexadecimal digits of course) can only be zero, and this segmented method does not access all addresses in the 32-bit range.

The General DOS program puts the executed code in one segment, and the data in the other segment. Of course, this is only logical. And there are exceptions, such as all the COM format of the program code snippet also put data.

The executable (EXE) generated by the 16-bit C compiler (such as TC 2.0, m$ C) under Dos can be selected in code mode, for example: Huge, Large, Medium, Small, Tiny (Compact) and so on. The difference is only the number of segments to put code and data.

If you understand the above, the following is a good understanding.

The integer and pointer of the 16-bit C compiler are 16 bits by default. The default pointer has only a value of offset (offset) and can only point to the same segment. Also called proximity pointer (near Pointer). When you want to use a pointer to access another segment, you define a remote pointer (far Pointer) with a pointer of 32 bits. A pointer must be defined as a remote pointer (far Pointer) when the program has more than one code snippet (if it is a function pointer) or data segment (if it is a variable pointer) and the pointer is not in the same segment as the point where it is pointing.
Their own posts back, this is the previous akuma of the explanation of the far pointer, understand!

Far and near two pointers in C/A + +

Related Article

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.