Segment

xiaoxiao2021-03-06  107

This is a bit segment, divides a byte into several sections to store several information. The so-called segment is a member in the structure type defined in the position of the unit. Such as: struct packed-data {unsigned a: 2; unsigned B: 6; Unsigned C: 4; Unsigned D: 4; Int i;} DATA; where A, B, C, and D occupies 2, 6, 4, 4 Bit, 4 digits. I is intellectual, accounting for 4 bytes. The reference to the segment member is as follows: DATA.A = 2;, etc., but should not pay attention to the range definitions of the bit segment. If the bit segment member A is defined as 2 bits, the maximum is 3, ie (11) 2, so data.a = 5; if it takes 5, the two low positions are assigned, and the desired value is not required. Some important instructions about the definition and reference of the segment: 1 If a certain segment is to be stored from another word, you can define: unsigned A: 1; Unsigned B: 2; unsigned: 0; Unsigned C: 3; Another unit) uses a bit section of length 0, and the effect is to store the next bit segment from the next memory unit. 2 A bit segment must be stored in one storage unit and cannot cross two units. 3 can define an unknown segment. Such as: unsigned A: 1; UNSIGNED: 2; (These two-bit space is not available) Unsigned B: 3; 4 Segment length cannot be greater than the length of the memory cell, nor can it define the number of bits.

转载请注明原文地址:https://www.9cbs.com/read-102418.html

New Post(0)