![]() This same behavior happen in C++, Fred would need to not have any constructors. What is a “POD type”?Ī type that consists of nothing but Plain Old Data.Ī POD type is a C++ type that has an equivalent in C, and that uses the same rules as C uses for initialization,Īs an example, the C declaration struct Fred x does not initialize the members of the Fred variable x. However this won’t work in C or C++ since 5×7 is 35, meaning using char*s to walk through memory would “skip”Ī bit every fifth byte (and also because C++ requires bytes to have at least 8 bits). Note: one of the popular non-C/C++ approaches on the PDP-10 was to pack 5 bytes (of 7-bits each) into each 36-bit The important point here is that memcpy() has to be able to see everyīit of memory: there can’t be any bits between two adjacent bytes. A more complicated approach could be used for those 4 bits, e.g., by packing nine bytes (ofĨ-bits each) into two adjacent 36-bit words. However theĪbove technique wouldn’t allow us to define a PDP-10 C++ “byte” as 8-bits, since 8×4 is 32, meaning every 4th byte Using the same logic, it would also be possible to define a PDP-10 C++ “byte” as 12-bits or 18-bits. Int* could still be implemented as a single hardware pointer, since C++ allows sizeof(char*) != sizeof(int*). The word into a register, then use bit-masks and bit-shifts to change the appropriate 9-bit byte within that word. For example, the code generated for *p = 'x' might read In that case, the C++ compiler would need to addĮxtra instructions when compiling code using char* pointers. The 36-bit word, the second could be a bit-offset within that word. ![]() Another validĪpproach would be to define a “byte” as 9 bits, and simulate a char* by two words of memory: the first could point to One way to abide by all the above rules is for a PDP-10 C++ compiler to define a “byte” as 36 bits. Possible for a pointer to point 8 bits to the right of where some other pointer points. That means a pointer can point only at things on a 36-bit boundary: it is not The PDP-10 has 36-bit words with no hardware facility to addressĪnything within one of those words. Let’s work an example to illustrate these rules. Include the header, then the actual number of bits per byte will be given by the CHAR_BIT macro. The C++ language gives you a way to find out how many bits are in a byte in your particular implementation:. ![]() Will never cause a change to a different byte.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |