• <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 閱讀(312) 評論(0)  編輯 收藏 引用 所屬分類: 粗心題
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久久久综合狠狠综合| 久久久精品人妻无码专区不卡| 中文字幕无码av激情不卡久久| 99热热久久这里只有精品68| 97r久久精品国产99国产精| 久久精品中文闷骚内射| 久久精品草草草| 久久久人妻精品无码一区 | 国产偷久久久精品专区| 99久久国语露脸精品国产| 久久91这里精品国产2020| 久久久久久久久久久精品尤物| 久久精品午夜一区二区福利| 日韩一区二区三区视频久久| 久久久噜噜噜久久中文福利| 狠狠人妻久久久久久综合| 久久99热这里只频精品6| 亚洲国产精品人久久| 无码人妻久久一区二区三区免费丨| 久久电影网2021| 久久人人爽人人人人片av| 久久久久国色AV免费观看 | 久久精品国产精品亚洲下载| 久久午夜伦鲁片免费无码| 久久伊人中文无码| 欧美精品一本久久男人的天堂| 伊人久久大香线焦AV综合影院| 久久伊人五月天论坛| 狠狠色丁香婷婷综合久久来来去| 2022年国产精品久久久久| 一本久久a久久精品亚洲| 久久久久亚洲AV片无码下载蜜桃 | 久久精品无码一区二区三区| 久久精品aⅴ无码中文字字幕不卡| 久久久久18| 久久综合丝袜日本网| 久久精品国产福利国产秒| 99999久久久久久亚洲| 色欲久久久天天天综合网| 无码久久精品国产亚洲Av影片| 久久无码AV一区二区三区|