深入理解電腦系統第二版習題解答CSAPP 2.13

來源:互聯網
上載者:User

標籤:style   blog   io   color   使用   sp   資料   on   div   

從20世紀70年代末到80年代末,Digital Equipment的VAX電腦是一種非常流行的機型。它沒有布爾運算AND和OR指令,只有bis(位設定)和bic(位清除)這兩種指令。兩種指令的輸入都是一個資料字x和一個掩碼字m。它們產生一個結果z,z是由根據掩碼m的位來修改x的位得到的。使用bis指令,這種修改就是在m為1的每個位置上,將z對應的位設定為1。使用bic指令,這種修改就是在m為1的每個位置,將z對應的位設定為0。

只使用這兩個函數實現C語言的按位|和^運算。

 1 int bis(int x, int m); 2 int bic(int x, int m); 3  4 int bool_or(int x, int y) 5 { 6     int result = bis(x, y); 7     return result; 8 } 9 10 int bool_xor(int x, int y)11 {12     int result = bis(bic(x, y), bic(y, x));13     return result;14 }

 

深入理解電腦系統第二版習題解答CSAPP 2.13

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.