日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Computer Organization and Design--计组作业习题(1)

發(fā)布時(shí)間:2025/7/25 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Computer Organization and Design--计组作业习题(1) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Computer Organization and Design

?

?----------------------個(gè)人作業(yè),如果有后輩的作業(yè)習(xí)題一致,可以參考學(xué)習(xí),一起交流,請(qǐng)勿直接copy

Problem 1:

Convert the following decimal values to both binary and hexadecimal representations using 8 bit two’s complement. If you cannot convert to twos complement please explain why.?

?

2310= 00010111two=17hex

?

-1510= 11110001two=F1hex

?

-12810= 10000000two=80hex

?

12810: 關(guān)于 2’s complement,8 bit可以表示的數(shù)值范圍只有【-128,+127】;故128無法用8 bit2’s complement 表示;

?

?

-110= 11111111two=FFhex

?

Problem 2:

?

Convert the following LC2K assembly code into machine code in hex. All unused bits should be 0 and the machine code instructions should be 32 bits long.

?

? ? ? ? ? ? ? add? ????? 1? 2? 3 ? ? ? ? ? ? ? ? ? ? ? ? ? : 0x000A0003

start? ???? lw? ???????? 4? 5? ten ?????????????????????? : 0x00A50004

? ? ? ? ? ? ?beq? ????? 3? 5? start ? ? ? ? ? ? ? ? ? ? ? : 0x011DFFFE

? ? ? ? ? ? ?halt ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? : 0x01800000

ten? ?????? .fill? ??????? 10 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?: 0x0000000A

?

?

Problem 3:?

Convert the following hex numbers to LC2K instructions.

?

0x00550003 ? ? ? ? ? ? ? ? ? ? : nand? 2? 5? 3

?

0x01670000 ???????????????????? : jalr 4?? 7

?

0x00CAFFFF ? ? ? ? ? ? ? ? ? ? ?: sw??? 1?? 2?? -1

?

?

Problem 4:?

Given the following MIPS assembly code (and assuming all registers start at 0):

?

??? ???????? addi ? $1??? $0??? 3

??? ???????? addi?? $2??? $0??? 8

? ? loop?? add?? $1??? $1??? $2

??? ???????? nand? $3??? $1??? $2

??? ???????? addi?? $2??? $2??? -2

??? ???????? bne?? $0??? $2??? loop

?

?

a) Translate the MIPS code into C Code that performs the same operations. Please use the variable names reg1, reg2, and reg3 for $1, $2, and $3.?

?

int reg1, reg2, reg3;

reg1 = 3;

reg2 = 8;??

do

{

?? reg1 = reg1+reg2;

?? reg3 = ~(reg1&reg2);

?? reg2 = reg2+(-2);

}

while (reg2 !=0);

?

b) How many times is the line, “nand $3, $1, $2” executed?

?? ? 4 times;

c) What is the final value of $3?

??????? -310;

?

Problem 5:?

?

Below is the description of a new, stack-based ISA that only contains one register, REG. The ISA is byte addressable.

?

R-type Instructions?? ???????? bits 7-5: opcode

?? ????????????????????????? bits 4-0: unused

?

?

?

I-type Instructions?? bits 7-5: opcode

?? ???????????????????? bits 4-0: immediate value in 2’s complement form

?

?

?

?

U-type Instructions?? ??????? bits 7-5: opcode

bits 4-2: unused?

bits 1-0: math code

?

?

?

a) Translate the following instructions into machine code. Please write your answers in HEX.

?

?

Instruction

Machine Code

flip

40

load-2

7E

ALU. Sub

C1

?

b) You are given the following C code that you are to translate into this ISA’s assembly.

a = b nand c

?

Assume that the stack is NOT initially empty and STACK[bottom] = 0.

?

a is located at memory address 10, b is at 20, c is at 30. REG is initially 0. Write your code below.

?

load?? ????? 20

push

load ??????? 30

ALU.Nand

store ????? 10

?

轉(zhuǎn)載于:https://www.cnblogs.com/nanashi/p/6661603.html

總結(jié)

以上是生活随笔為你收集整理的Computer Organization and Design--计组作业习题(1)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。