TuongAnhKiet Assessing Exercises of Chapter 12
TuongAnhKiet Assessing Exercises of Chapter 12
Typical elements of a machine instruction include the operation code (opcode), which
specifies the operation to be performed; source operand references, which indicate the input
data for the operation; destination operand references, which specify where the result should
be stored; and, in some cases, next instruction references, which provide information about
the subsequent instruction to execute. These elements together allow the CPU to execute a
variety of operations on different data sets.
12.2 What types of locations can hold source and destination operands?
Source and destination operands can be held in various locations, including registers within
the CPU for fast access, main memory (RAM) for larger data storage, cache for
intermediate-speed access, and immediate or direct values embedded within the instruction
itself. These locations allow flexibility in how data is accessed and manipulated during
program execution.
12.3 If an instruction contains four addresses, what might be the purpose of each address?
In an instruction with four addresses, the addresses might serve the following purposes: the
first address could specify the location of the first operand (source), the second address
could specify the location of the second operand (source), the third address could indicate
the destination for the result, and the fourth address might be used for specifying the
address of the next instruction (often used in branching or looping constructs).
12.4 List and briefly explain five important instruction set design issues.
12.6 What is the relationship between the IRA character code and the packed decimal
representation?
The IRA (International Reference Alphabet) character code represents text characters using
a specific encoding scheme. Packed decimal representation, often used in financial
computations, stores two decimal digits per byte, utilizing a binary-coded decimal (BCD)
format. The relationship lies in how data is encoded and represented in memory, with both
methods converting between human-readable characters and machine-readable formats.
12.7 What is the difference between an arithmetic shift and a logical shift?
An arithmetic shift preserves the sign bit for signed binary numbers, making it suitable for
signed arithmetic operations. In contrast, a logical shift treats all bits uniformly, shifting them
left or right without regard for the sign bit, thus suitable for unsigned numbers and bit
manipulation. Arithmetic shifts are used for multiplication and division, while logical shifts are
used for bitwise operations.
Transfer of control instructions, such as jumps, calls, and branches, are needed to alter the
normal sequential execution flow of a program. They enable the implementation of loops,
conditional execution, function calls, and exception handling, thus providing the flexibility
necessary for complex program structures and logic.
12.9 List and briefly explain two common ways of generating the condition to be tested in a
conditional branch instruction.
Two common ways to generate the condition for a conditional branch instruction are:
1. Status Flags: Use specific bits in a status register (e.g., zero flag, carry flag) that are set or
cleared based on the outcome of previous operations.
2. Comparison Instructions: Directly compare two values and set status flags accordingly,
providing conditions such as equal, not equal, greater than, or less than for branching
decisions.
Nesting of procedures refers to the ability of a procedure (or function) to call another
procedure, which can in turn call yet another procedure, and so on. This hierarchy allows for
modular and organized program structure, enabling complex tasks to be broken down into
simpler, reusable sub-tasks. Each nested call typically involves storing return addresses and
local variables on a stack.
12.11 List three possible places for storing the return address for a procedure return.
Three possible places for storing the return address for a procedure return are:
1. Call Stack: A dedicated stack structure where return addresses are pushed upon
procedure calls and popped upon returns.
2. Registers: Specific registers may be designated to hold return addresses, especially in
systems with register-based calling conventions.
3. Memory: Return addresses can be stored in a fixed or dynamically allocated memory
location, referenced during procedure returns.