计导第七次作业

10205102406 edited 3 年,4 月前

对所有编程的题目, 请同学们把你的代码拷贝到你的报告word中,并将程序的运行结果截图粘贴到代码下方。有问题可以问TA或其他同学。请有编程经验的同学多帮助别人,但是不是让他们直接拷贝程序。

1、 10 points 请自己上网学习。Based on IEEE 754 floating point representation, for 32-bit words, show us how to represent the following floating point numbers: (A) -0.0125; (B)256.875

10111100010011001100110011001100

01000011100000000111000000000000

2、 (每题5 points3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6

3.2.1:

mov

3.2.2:

从内存中地址1200处取出元素存入寄存器R2

3.2.3:

shiftl R3,R1,4

3.2.4:

shiftl R1,R1,2

shiftl R3,R1,1

add R3,R3,R1

3.2.5:

load R1,(600)

load R2,(604)

sub R1,R1,R2

store (600),R1

3.2.6:

算术右移用于有符号整数的除法运算

3、 30 pointsLet ID=your student ID. Then, let k=ID %2. So k can be 0 or 1. Based on the value of your ID, you get value of k. Please tell us your k value.

If k==0: 做习题3.3, 3.5, 3.7, 3.9, 3.11, 3.13
If k==1:
做习题 **3.2, 3.4, 3.6, 3.8, 3.10, 3.12

**

3.3:

20

3.5:

sle R0,R1,R2

beqz R0,L1

add R3,R1,R2

goto L2

L1:

mov R3,R2

L2:

3.7:

mov R1,02h

shiftl R2,R1,1

shiftl R3,R2,2

add R4,R3,R2

R1:2

R2:4

R3:16

R4:20

将R1中的值乘10存入R4中

3.9:

20

3.11:

load R1,(1000)

load R2,(1008)

shiftr R3,R1,R2

store (1024),R3

3.13:

会,原本输出为

30

30

修改后输出为

30

10

4、 20 points)装上我们的SEAL(教学用的汇编语言模拟器)写出正确的汇编语言程序。输入:三个整数,用_data 1,[a,b,c]表示,计算出最大数放入寄存器R1中,打印。请不要用函数调用。

请在注释中写出你的Python对应代码,把你的全部代码拷贝到word报告中,并将程序的运行结果截图粘贴到报告中。

#L = [1,2,3]

#a = L[0]

#b = L[1]

#if not a>=b:

# a = b

#b = L[2]

#if not a>=b:

# a = b

#print(a)

_data 1,[1,2,3]

load R1,(1)

load R2,(2)

slt R3,R1,R2

beqz R3,L1

mov R1,R2

L1:

load R2,(3)

slt R3,R1,R2

beqz R3,L2

mov R1,R2

L2:

_pr R1

5、 20 points)请用SEAL写出和执行汇编语言程序。输入一个个字符串表示二进制数,以_data的形式输入,此数组中的第一个数代表字符串的长度,然后是01ASCII码:字符048,字符 149.。例如,“101”是用_data 0, [3, 49, 48, 49].是请用最简单的方式计算出它有多少个”1”,将结果放在R1中,并打印。例如,这个例子有2个“1”。

请在注释中写出你的Python对应代码,把你的全部代码拷贝到word报告中,并将程序的运行结果截图粘贴到报告中。

#L = [3,49,48,49]

#a = L[0]

#b = 1

#c = 48

#count = 0

#while b<=a:

# d = L[a]

# if c<d:

# count += 1

# a-=1

#printf(count)

_data 0, [3, 49, 48, 49]

load R0,00(0)

mov R1,1

mov R2,48

mov R3,0

L1:

sle R4,R1,R0

beqz R4,L3

load R5,00(R0)

slt R6,R2,R5

beqz R6,L2

add R3,R3,1

L2:

sub R0,R0,1

goto L1

L3:

_pr R3

编辑者:姜博远
仅供参考

Past Versions

Comments