Ch.3 - Participation Activities study test
with a complete guide
An instruction set is a particular program provided in the language of a computer. (T/F) -
ANSFalse
The instruction set is the language itself, not a particular program. The language is like
English, whereas a program is like a particular book written in English.
The instruction sets of different computers are quite similar to one another. (T/F) -
ANSTrue
Instruction sets are similar because computers are constructed from hardware
technologies based on similar underlying principles, and because all computers must
provide several basic operations.
Instructions, as well as data, can be stored in memory as numbers. (T/F) - ANSTrue
Instructions can be represented as just 0's and 1's, leading to the basic concept of the
"stored-program": Both instructions and data can be stored in memory as numbers.
A LEGv8 add instruction that computes: z = x + y - ANSADD z, x, y
A LEGv8 add instruction that computes: a = a + b - ANSADD a, a, b
Assembly instructions to calculate the expression: a = b + c + d - e - ANS1. ADD t0, b, c
2. ADD t1, t0, d
3. SUB a, t1, e
Which instruction is incorrect for calculating a = b + c + d - e?
- ADD t0, c, d
- ADD t0, t0, b
- SUB a, e, t0 - ANSSUB a, e, t0
t0 and e are reversed. The instruction computes e - t0, so e - (b + c + d). The instruction
should have been: SUB a, t0, e.
,Which programming language likely takes the most lines of source code? Put in order 1
(requires most lines) to 3 (requires fewest lines)
Options: LEGv8, C, Java - ANS1. LEGv8 - Because assembly instructions are rigid, a
single expression might require several instructions.
2. C - C allows a user to write higher-level expressions using a single line.
3. Java - Java is newer than C and thus contains even more high-level constructs that
results in fewer lines of Java. Each such line may compile to numerous assembly
instructions.
Indicate whether each is a valid LEGv8 instruction.
ADD X1, X2, X3 - ANSValid
Computes X1 = X2 + X3
Indicate whether each is a valid LEGv8 instruction.
ADDI X1, X2, 50 - ANSValid
Computes X1 = X2 + 50. The "i" in ADDI refers to the "immediate" value of 50, which is
not referring to a register. So if X2 contains 9, then the instruction will put 59 into X1.
Indicate whether each is a valid LEGv8 instruction.
LDUR X1, [X35, 20] - ANSNot Valid
The instruction's form is correct, but X35 is not a LEGv8 register (X30 is the
highest-numbered X register). The LDUR instruction's behavior is described later.
Indicate whether each is a valid LEGv8 instruction.
BRANCH 2500 - ANSNot Valid
The correct form is: B 2500. The branch instruction's behavior is described later.
In the instruction below, a, b, and c are operands. In such an arithmetic instruction, each
operand comes from special hardware called a _____.
ADD a, b, c - ANSRegister
Registers can be thought of as the bricks of computer construction.
In the LEGv8 architecture, each register is _____ bits wide. - ANS64 bits
, 64 is a common register width in computer architectures. Some architectures for
embedded systems use 8 or 16 bits. 64 bits is becoming common in some
high-performance architectures like those used in servers.
More registers may benefit an assembly program, but may lead to a _____ clock
frequency.
Type: slower, faster, broken. - ANSSlower
More registers may mean the clock frequency must be slowed to ensure the clock signal
has time to reach every register, thus slowing every instruction. Hence the principle of
"Smaller is faster." Of course, too few registers may mean many more instructions must
execute, which is slower, so hardware designers seek a good balance.
Arithmetic with Registers:
Compute: X17 = X18 + X19 - ANSADD X17, X18, X19
Arithmetic with Registers:
Compute: X4 = X5 + X6 + X7 - ANSADD X8, X5, X6
ADD X4, X8, X7
Arithmetic with Registers:
Compute: X4 = X5 + (X6 - X7) - ANSSUB X8, X6, X7
ADD X4, X5, X8
Arithmetic with Registers:
Compute: X10 = (X11 + X12) - (X13 + X14) - ANSADD X15, X11, X12
ADD X16, X13, X14
SUB X10, X15, X16
Arithmetic with Registers:
Compute: a = b + c + d
Assume: a is X4, b is X5, c is X6, d is X7 - ANSADD X8, X5, X6
ADD X4, X8, X7
Assume X22 has 5000, and doublewords addressed 5000..5002 have the data shown:
5000: 99
5001: 77
5002: 323
What value will be put in X10 by: LDUR X10, [X22, #2] - ANS323
[X22, #2] will compute the address 2 + 5000, or 5002. The value in the doubleword at
address 5002 is 323. Thus, 323 will be put in X10.