• <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
            很好的題,很容易錯(cuò)。
            需要計(jì)算機(jī)組成原理的一點(diǎn)知識(shí),沒學(xué)過也能做。
            指令譯碼,(將二進(jìn)制轉(zhuǎn)化為十進(jìn)制并從中獲得操作類型和立即數(shù)x)可以用位運(yùn)算,
            指令執(zhí)行 pc,accu,立即數(shù)x都可以用int表示且是全局變量,memory用數(shù)組表示。
            有很多注意的地方,
            pc不能超過32;不能小于0.
            accu不能超過256.不能小于0.
            自己都沒有注意到。
            pc,accu,
            posted on 2009-07-24 10:59 luis 閱讀(305) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 粗心題
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久久久国产一级毛片高清版| 久久国产精品波多野结衣AV| 伊人久久精品无码二区麻豆| 亚洲中文精品久久久久久不卡 | 秋霞久久国产精品电影院| 久久中文娱乐网| 午夜福利91久久福利| 久久久久人妻一区二区三区vr| 丁香久久婷婷国产午夜视频| 久久久久免费精品国产| 国产成人精品久久免费动漫 | 国产精品美女久久久m| 久久九九久精品国产免费直播| 久久热这里只有精品在线观看| 91精品国产91热久久久久福利| 久久人人爽人人人人爽AV| 精品无码久久久久久久久久| 人妻精品久久久久中文字幕69 | 久久久久久久人妻无码中文字幕爆| 久久久久国产成人精品亚洲午夜| 亚洲午夜无码AV毛片久久| 精品久久久久久99人妻| 99久久这里只有精品| 97精品伊人久久久大香线蕉 | 99国内精品久久久久久久| 精品少妇人妻av无码久久| 久久久久久久精品妇女99| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区| 日韩久久久久久中文人妻| 久久精品国产精品亚洲精品| 无码精品久久一区二区三区| 大美女久久久久久j久久| 久久精品男人影院| 欧美综合天天夜夜久久| 免费观看久久精彩视频| A级毛片无码久久精品免费| 日本久久久精品中文字幕| 99久久精品国产一区二区| 91精品婷婷国产综合久久| 国产精品99久久久久久宅男| 久久黄色视频|