• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 195,  comments - 30,  trackbacks - 0
            You are to write an interpreter for a simple computer. This computer uses a processor with a small number of machine instructions. Furthermore, it is equipped with 32 byte of memory, one 8-bit accumulator (accu) and a 5-bit program counter (pc). The memory contains data as well as code, which is the usual von Neumann architecture.

            The program counter holds the address of the instruction to be executed next. Each instruction has a length of 1 byte - the highest 3 bits define the type of instruction and the lowest 5 bits define an optional operand which is always a memory address (xxxxx). For instructions that don't need an operand the lowest 5 bits have no meaning (-----). Here is a list of the machine instructions and their semantics:

            000xxxxx   STA x   store the value of the accu into memory byte x
            001xxxxx   LDA x   load the value of memory byte x into the accu
            010xxxxx   BEQ x   if the value of the accu is 0 load the value x into the pc
            011-----   NOP     no operation
            100-----   DEC     subtract 1 from the accu
            101-----   INC     add 1 to the accu
            110xxxxx   JMP x   load the value x into the pc
            111-----   HLT     terminate program

            In the beginning, program counter and accumulator are set to 0. After fetching an instruction but before its execution, the program counter is incremented. You can assume that programs will terminate.

            Input Specification

            The input file contains several test cases. Each test case specifies the contents of the memory prior to execution of the program. Byte 0 through 31 are given on separate lines in binary representation. A byte is denoted by its highest-to-lowest bits. Input is terminated by EOF.

            Output Specification

            For each test case, output on a line the value of the accumulator on termination in binary representation, again highest bits first.

            Sample Input

            00111110
                        10100000
                        01010000
                        11100000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00111111
                        10000000
                        00000010
                        11000010
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        00000000
                        11111111
                        10001001
                        

            Sample Output

            10000111
            很好的題,很容易錯。
            需要計算機組成原理的一點知識,沒學過也能做。
            指令譯碼,(將二進制轉化為十進制并從中獲得操作類型和立即數x)可以用位運算,
            指令執行 pc,accu,立即數x都可以用int表示且是全局變量,memory用數組表示。
            有很多注意的地方,
            pc不能超過32;不能小于0.
            accu不能超過256.不能小于0.
            自己都沒有注意到。
            pc,accu,
            posted on 2009-07-24 10:59 luis 閱讀(302) 評論(0)  編輯 收藏 引用 所屬分類: 粗心題
            <2011年4月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            人人狠狠综合88综合久久| 久久精品中文字幕久久| 亚洲国产精品综合久久网络| 久久久噜噜噜久久| 久久综合狠狠综合久久| 国产精品久久久久久久午夜片| 久久久99精品一区二区| 亚洲国产精品无码久久一区二区| 麻豆亚洲AV永久无码精品久久| 91精品国产高清久久久久久国产嫩草| 伊人久久一区二区三区无码| 国产精品久久久久久福利漫画 | 奇米影视7777久久精品人人爽| 色欲av伊人久久大香线蕉影院| 国产精品一久久香蕉国产线看| 亚洲国产成人精品女人久久久| 亚洲中文精品久久久久久不卡| 久久精品国产一区二区| 久久久久高潮毛片免费全部播放 | 久久久久亚洲精品男人的天堂| 久久亚洲AV成人无码电影| 模特私拍国产精品久久| 久久无码人妻精品一区二区三区| 97久久精品人妻人人搡人人玩| 国产成年无码久久久免费| 一本久久免费视频| 无码任你躁久久久久久| 国产精品成人99久久久久| 精品熟女少妇a∨免费久久| 日日躁夜夜躁狠狠久久AV| 亚洲欧美日韩久久精品第一区| 亚洲七七久久精品中文国产| 久久久久无码国产精品不卡| 中文字幕亚洲综合久久2| 久久99精品国产一区二区三区| 久久Av无码精品人妻系列| 国产成人久久AV免费| 国产精品久久久久久久久| 久久免费美女视频| 久久国产成人亚洲精品影院| 久久99久久无码毛片一区二区|