⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wierdptrs.ct.html

📁 this is a mirrored site c-faq. thought might need offline
💻 HTML
字号:
<html><!-- Mirrored from c-faq.com/null/wierdptrs.ct.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:55 GMT --><head><title></title></head><body>[I and correspondent were discussing, among other things, thefact that pointer types aren't necessarily all identicaland that pointer casts might therefore involve actual conversions.I drew Chris Torek into the conversation,and the text below is excerpted from his contribution.]<p>From: Chris Torek<br>Date: Sat, 5 Nov 1994 05:32:05 -0800<br>Message-Id: &lt;199411051332.FAA11040@elf.bsdi.com&gt;<br>Subject: Re: Q: How do you assign a float to a (void) data?<p>I just want to add one or two specifics to Steve's message...<p>&gt;Word-addressed machines are by no means hypothetical.  I can<br>&gt;never remember the details, but I believe that machines<br>&gt;manufactured by Data General, PR1ME, and/or Cray have used such<br>&gt;schemes, and C compilers have been written for these machines.<br>&gt;(Writing code for these machines, and especially porting existing<br>&gt;code to such machines, is a real lesson in portable pointer usage.)<p>I have never used a Cray, but I believe the list above is correct(if not complete).  On the other hand, I have used the Data GeneralMV-series machines.  These have `word pointers' and `byte pointers',where words are made up of two bytes.  (This seems odd at first,as the machine has 32-bit integers, but is due to the history ofthe machine; the pointer format is an extension of that used onthe DG Nova, a 16-bit word-addressed machine.  The Nova also hadonly 8 ALU ops, including a subtract-with-borrow but no subtract-without-borrow.  This was because they used a 74xx series ALU, thathad 16 ops, but had only 3 bits left in the instruction, so theyhardwired one of the ALU operand pins to a `1'.  The MV seriesfixed <em>that</em> particular annoyance.)<p>On the DG, to convert a word pointer to a byte pointer, you shiftthe word pointer left, introducing a 0 bit as the `byte offset'bit.  The top bit of a word pointer is an `indirection' bit; thisis lost in the conversion.  Similarly, to convert a byte pointerto a word pointer, you shift the byte pointer right, losing thebyte offset and introducing a 0 bit as the `indirection' bit.  Sucha shift also moves the segment and ring bits, and I can no longerrecall whether they were expected to be shifted this way, or whetherthere was a special pair of shift instructions that preserved thesebits, moving only the address bits.</body><!-- Mirrored from c-faq.com/null/wierdptrs.ct.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:55 GMT --></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -