0% found this document useful (0 votes)
26 views3 pages

Lista1 Oac

Uploaded by

Iasmin Cristina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Lista1 Oac

Uploaded by

Iasmin Cristina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lista 1 – Fazer os exercícios do livro:

1) In this exercise, you will evaluate the performance difference between two CPU
architectures, CSIC (complex instruction set computing) and RISC (reduced instruction set
computing). Generally speaking, CISC CPUs have more complex instructions than RISC
CPUs and therefore need fewer instructions to perform the same tasks. However, typically
one CISC instruction, since it is more complex, takes more time to complete than a RISC
instruction. Assume that a certain task needs P CISC instructions and 2P RISC instructions,
and that one CISC instruction takes 8T ns to complete, and one RISC instruction takes 2T
ns. Under this assumption, which one has the better performance?

RESPOSTA: A arquitetura RISC executa na metade do tempo da arquitetura CISC e, portanto,


tem a melhor performance.

2) Sometimes software optimization can dramatically improve the performance of a


computer system. Assume that a CPU can perform a multiplication (*) operation in 10 ns,
and a subtraction operation in 1ns. How long will it take for the CPU to calculate the
result d = a*b – a*c? Could you optimize the equation above so that it will take less time?

RESPOSTA:

multiplicação = 10ns e a subtração = 1ns d = a*b – a*c ->


(a*b) 10ns + (a*c) 10ns + (-) 1ns = 21ns
A CPU levará 21ns para calcular a expressão

A expressão otimizada seria: d = a * (b – c), que leva 11ns: (b – c) 1ns + (a *) 10ns

3) Why doesn't MIPS have a subtract immediate (subi) instruction?

RESPOSTA: Porque é possível realizar a operação de subtração somando o número negativo.

4) Add comments to the following MIPS code describe in one sentence what it computes.
Assume that $a0 and $a1 are used for the input and both initially contain the integers a
and b, respectively. Assume that $v0 used for the output.
COMENTARIOS:

add $t0, $zero, $zero t0 = 0

loop: beq $a1, $zero, finish if(b ==0) goto finish

add $t0, $t0, $a0 t0 = t0 + a

addi $a1, $a1, -1 b = b-1


j loop jump pro loop

finish: addi $t0, $t0, 100 t0 = t0+100

add $v0, $t0, $zero v0 = t0+0

O código soma o valor de “a” “b” vezes e depois soma o resultado final com 100.

5) Exercícios 2.26.1 , 2.26.2 , 2.26.3 do livro RESPOSTA:

2.26.1) $t1 = 10 -> $s2 = 20

2.26.2)

2.26.3) 5N + 2

6) The following program tries to copy words from the address in register $a0 to the address
in register $a1, counting the number of words copied in register $v0. The program stops
copying when it finds a word equal to 0. You do not have to preserve the contents of
registers $v1, $a0 and $a1. This terminating word should be copied but not counted.

addi $v0, $zero, 0


loop: lw, $v1, 0($a0) sw
$v1, 0($a1) addi
$a0, $a0, 4 addi
$a1, $a1, 4 beq $v1,
$zero, loop
RESPOSTA:

addi $v0, $zero, 0


loop: lw, $v1, 0($a0) sw
$v1, 0($a1) beq $v1,
$zero, finish addi
$a0, $a0, 4 addi $a1,
$a1, 4 addi $v0, $v0,
1 j loop
finish:
There are multiple bugs in this MIPS program; fix them and turn in a bug-free version.

7) Exercício 2.27 do livro

RESPOSTA:

8) Exercício 2.34 do livro RESPOSTA:

You might also like