[Principles of Computer Composition] General Review Notes (Part 2)

Special statement:
This article is for reference only. Part of the content of this article comes from AI summary, Internet collection and personal practice. If any information contains errors, readers are welcome to criticize and correct them. This article is only for learning and communication, not for any commercial purposes.

Article directory

Chapter 5 Computer Operation Methods

1. Two’s complement representation

  • Compute the smallest integer of two's complement
  • Complement form and truth value conversion
    In this question, the following professional terms are involved:
  1. Two's complement: Two's complement is a binary number representation used to represent signed integers. In two's complement code, the binary representation of a positive integer is the same as its original code, while the representation of a negative integer is based on its original code, inverting all bits (0 to 1, 1 to 0), and then adding 1. This representation helps simplify addition and subtraction operations while avoiding problems with positive and negative zeros.

  2. Sign bit: In binary numbers, the sign bit is the highest bit (the leftmost bit) and is used to indicate the sign of the number. Usually, 0 represents a positive number and 1 represents a negative number.

  3. Truth value: In two's complement notation, the truth value is the actual integer value obtained by interpreting the binary number. For negative numbers, the calculation of the true value needs to be carried out according to the two's complement rule.

  4. Negation: In binary numbers, negation refers to the operation of changing each bit of 0 into 1 and 1 into 0.

  5. Add 1 to the last bit: In two's complement, in order to get the true value of a negative number, 1 needs to be added to the end after inversion. This is because the complement of a negative number is the negation plus 1.

These technical terms help us understand how to represent and calculate integer values ​​in two's complement.

2. Data representation of von Neumann structure

  • The reason for binary encoding
  • Simplified binary arithmetic rules
  • Logic gate circuits implement arithmetic operations
    . In this question, the following professional terms are involved:
  1. Von Neumann structure: The von Neumann structure is a computer architecture, which includes five main components: memory, arithmetic unit, controller, input device and output device. Among them, the memory is used to store data and instructions, and programs and data are stored in the memory in the form of binary encoding. The key feature of this structure is that programs and data are stored in the same memory, and a specific set of instructions that can be controlled by the computer itself is used to manipulate the data in the memory.

  2. Binary encoding: Binary encoding is an encoding method that uses 0 and 1 to represent numerical values. In the computer field, all data, instructions, addresses and other information are stored and processed in the form of binary encoding. This is because the electronic components inside the computer can represent and process binary signals more easily.

  3. Logic gate circuit: A logic gate circuit is a circuit composed of logic gates, which are basic electronic components used to perform logical operations such as AND, OR, and NOT. In computers, logic gate circuits are used to perform various logical operations to implement arithmetic and logical operations.

These technical terms help us understand why data is represented by binary encoding in von Neumann architecture computers. This includes the simplicity of binary operations, the ease of manufacturing physical devices, and the ease with which logic gates can perform arithmetic operations.

3. Complement representation and variable comparison

  • Two's complement representation of signed integers
  • Comparing two's complement values ​​of signed integers
    In this question, we touched on some concepts involving two's complement representation:
  1. Signed integers are represented using two's complement: The one's complement representation of signed integers is a binary encoding used to represent positive and negative numbers. In two's complement representation, the highest bit is the sign bit, 0 represents a positive number and 1 represents a negative number. For negative numbers, the two's complement form is used. Typically, the two's complement representation of a negative number is to invert each bit in the corresponding positive number's complement (0 becomes 1, 1 becomes 0), and then adds 1.

  2. Unsigned integers: Unsigned integers represent only non-negative integers, so there is no sign bit and all bits are used to represent the numeric value.

Against this background, let us look at the conclusion:

  • If x, y and z are unsigned integers, then x > y > z. Therefore, options A and B are incorrect.

  • If x, y and z are signed integers, z is positive and x and y are negative. By comparing x and y, we know that x > y. Therefore, option D is correct.

4. Complementary integer range

  • n-bit complement integer represents the range

Two's complement is a binary number encoding method commonly used in computers to represent signed integers. In two's complement notation, the binary representation of a positive integer is the same as an unsigned integer, while the representation of a negative integer is in the two's complement form of its absolute value.

For a given number of bits (e.g. 32 bits), the rules for two's complement representation are as follows:

  1. For a positive integer, its complement is the same as the binary representation of an unsigned integer.
  2. For a negative integer, first find the binary representation of its absolute value, then invert the representation (0 becomes 1, 1 becomes 0), and finally add 1.

One's complement representation has many advantages, one of which is that it has only one zero, which simplifies operations and logical judgments. In computers, one's complement is widely used to represent integers, especially when performing arithmetic operations, because it simplifies the implementation of addition and subtraction.

5. Conversion of data types in C language programs

  • Storage and operation rules for different data types
  • Conversion issues between data types

Data hazard: In the pipeline, when there is data dependency between two or more instructions, the latter instruction cannot be executed immediately and needs to wait for the completion of the previous instruction. Data risks include read-after-write related situations, write-after-write related situations, and write-after-read related situations.

Casting: In programming languages, casting refers to the operation of converting a value of one data type to another data type. In the question, converting short type data to int type involves sign bit expansion, that is, extending the sign bit of short type data to match the int type.

Two's complement form: Two's complement is a binary encoding used to represent signed integers. In the two's complement representation, the binary representation of a positive integer is the same as its original code, and the complement representation of a negative integer is the inversion of all bits of the original code except the sign bit, plus 1.

Data dependence: Data dependence refers to the dependence on data during instruction execution, including read-after-write (RAW, Read After Write), write-after-write (WAW, Write After Write) and write-after-read (WAR, Write). After Read) etc. Data correlation is a key factor affecting the execution sequence and efficiency of the pipeline.

Sign bit extension: Sign bit extension is the process of copying and filling the sign bit (highest bit) of a number to higher bits. It is usually used to keep the sign of the value unchanged when converting a low-bit data type to a high-bit data type. In the question, extending a short type value to an int type involves sign bit expansion.

6. Overflow in two’s complement arithmetic

  • Overflow phenomenon under two's complement arithmetic rules

Two's complement: Two's complement is a binary encoding used to represent signed integers. In the two's complement representation, the binary representation of a positive integer is the same as its original code, and the complement representation of a negative integer is the inversion of all bits of the original code except the sign bit, plus 1.

Overflow: Overflow means that when performing an arithmetic operation, the result exceeds the range that can be represented by the representation method used (such as a finite number of two's complement). In computers, overflow can cause inaccuracies and produce erroneous calculation results.

Operation overflow: Operation overflow means that when performing arithmetic operations such as addition, subtraction, multiplication, etc., the result obtained exceeds the range of the representation used, resulting in an overflow error.

In this question, by converting four 8-bit complements into decimal numbers and performing multiplication operations, we obtain r2×r3 = 1568. Since the range of 8's complement representation is -128 to +127, 1568 exceeds this range, so an arithmetic overflow occurs.

7. Memory addressing method and data storage

  • memory byte addressing
  • Store data in little endian mode
  • The order in which structures are stored in memory

Store data in little-endian mode: In little-endian mode, the low byte of data is stored at the starting address, and the high byte is stored at the address after the starting address. In this question, the data is stored in little-endian format.

Boundary alignment: Boundary alignment means that when allocating variable space in memory, the starting address of the variable should be a multiple of a certain value. This value is usually determined based on the size of the variable type.

Member structure (struct): In C language, a structure is a composite data type that allows different types of data to be combined together. The members of the structure are stored sequentially in memory, but padding bytes may exist due to alignment rules.

In this question, the structure recordcontains three members, each inttype occupies 4 bytes, and recordthe entire structure occupies 8 bytes. The data is stored in little-endian mode record.aat the address 0xC008of .record.c0xC00E

The specific storage conditions are as follows:

  • record.a0xC008The content of the address is 0x11.
  • record.c0xC00EThe content of the address is 0x00.
  • record.c0xC00FThe content of the address is 0x00.

Therefore, 0xC008the contents of the address and record.cthe address of are respectively 0x11and 0xC00E. So the answer is option D.

8. Data type conversion and filling high bits

  • Conversion of data types with different digits
  • High bit filling rules
  1. Compiler: A compiler is a program that converts high-level programming language code into computer executable code. It is responsible for translating high-level language code written by programmers into machine language or intermediate code so that the computer can execute it. Here, the compiler specifies the length of different data types, such as the number of bits in int and short.

  2. Unsigned Number: An unsigned number is an integer representation that does not contain signs. They can only represent non-negative integers, so there is no concept of negative numbers. In C language, unsignedkeywords are used to declare unsigned numbers, such as unsigned shortto represent an unsigned short integer.

  3. Machine Number: A machine number is a binary code used to represent numbers in computers. It can be an integer or a floating point number, in different encodings. Here, the machine number of y refers to the binary representation of the variable y in the computer.

  4. Overflow: Overflow means that when performing arithmetic operations in a computer, the result exceeds the range that the data type can represent. Overflow can cause incorrect calculations because the computer cannot correctly represent numbers that exceed its digit limit.

  5. Process of Elimination: Process of Elimination is a problem-solving method that gradually eliminates impossible options to determine the correct answer. Here, a process of elimination is used to determine the number of machines for y, by first eliminating obviously impossible options and then choosing the most appropriate answer.

Understanding these terms helps to understand data representation in computer programs and type conversion during compilation.

9. Overflow in fixed-point complement arithmetic

  • Overflow conditions for fixed-point complement arithmetic
  1. Word Length: Word length is an important term in computers, referring to the number of binary digits that the CPU can process at one time. Usually expressed in units of bits. For example, an 8-bit word length means that the CPU can process 8-bit binary numbers at the same time.

  2. Machine Number: A machine number is a binary code used to represent numbers in computers. It can be an integer or a floating point number, in different encodings. In the question, [x] complement and [y] complement represent the complement forms of x and y. The complement code is a binary encoding method used to represent signed integers.

  3. Arithmetic left shift and arithmetic right shift:

    • Arithmetic left shift: Performing an arithmetic left shift on a binary number is equivalent to multiplying the number by a specified power of 2. In the question, [x] is shifted one bit to the left to represent the operation of (2x).
    • Arithmetic right shift: Performing an arithmetic right shift on a binary number is equivalent to dividing the number by the specified power of 2 and rounding down. In the question, [y] is shifted one position to the right to represent the operation of (y/2).
  4. Overflow: In computers, overflow occurs when the result of an operation exceeds the range that the system can represent. Overflow can cause incorrect calculations because the computer cannot correctly represent numbers that exceed its digit limit.

These terms are frequently used in the fields of computer architecture and digital logic. Understanding these terms helps analyze and understand the details of computer programs and operations.

10. Unsigned conversion of signed integers

  • The effect of converting signed numbers to unsigned numbers on values
  1. 8-bit fixed-point two's complement arithmetic: Fixed-point representation is a method used to represent integers and decimals in which the position of the decimal point is fixed. Two's complement is a binary encoding way of representing signed integers. 8-bit fixed-point complement operation refers to calculation using fixed-point representation and complement operation in an 8-bit binary system.

  2. Overflow: Overflow means that when performing arithmetic operations in a computer, the result exceeds the range that the data type can represent. Here, if the operation result exceeds the range of 8-bit fixed-point complement representation (-128 to 127), an overflow will occur.

  3. Sign bit: In two's complement representation, the highest bit (leftmost bit) is usually used to represent the sign of a number. 0 represents a positive number and 1 represents a negative number. The overflow of the sign bit indicates that the sign of the calculation result cannot be represented correctly, resulting in overflow.

  4. Operators: Here, addition (+) and subtraction (-) are involved. In 8-bit fixed-point complement operations, the impact of operators and the possibility of overflow need to be considered.

Understanding these technical terms helps you understand what may happen when using fixed-point representation and two's complement arithmetic in computers, especially when there are a limited number of bits.

11. Complement representation and unsigned number conversion

  • Numerical change of two's complement conversion to unsigned number
  1. C language program segment: This refers to a part of the program in C language, usually a group of related statements used to complete a specific task or operation.

  2. short: In C language, shortit is an integer data type that usually occupies a small memory space and is used to represent integer values. Its scope and size depend on the compiler and system implementation.

  3. unsigned short: unsigned short is an unsigned integer data type in C language, used to represent non-negative integer values. It does not contain negative numbers, and the range and size are also compiler and system dependent.

  4. Two's complement representation: One's complement is a binary encoding used to represent signed integers. In two's complement, positive and unsigned integers are represented the same way, while negative numbers are represented slightly differently. In computers, signed integers are usually represented using two's complement.

  5. Sign bit: In the binary representation of a signed integer, the highest bit is usually used to represent the sign. 0 represents a positive number and 1 represents a negative number. In two's complement representation, the sign bit participates in the operation.

  6. Unsigned number: An unsigned number refers to a number that has no sign bit and only represents non-negative integers. In C language, unsignedkeyword is used to declare unsigned integer types.

In the above C language program segment, a variable of type short si = -32767;is initialized and then assigned to . In this process, when the negative number is converted into an unsigned number, its value changes, resulting in the value of .shortsiunsigned short usi-32767usi32769

12. Analysis of data in storage unit

  • The storage order of data in big endian and little endian modes
  1. Word Size: The word size is the number of binary bits used in computers to represent integers, pointers, and other data types. Usually in bits, such as 8-bit, 16-bit, 32-bit, 64-bit, etc. The size of the word length affects the amount of data and address range that the computer can process at one time.

  2. Byte addressing: Indicates that the basic unit when addressing computer memory is bytes. Byte addressing means that each memory address corresponds to a byte, rather than some other larger unit. This is one of the basic principles of computer memory addressing.

  3. Little-endian mode: Little-endian storage mode refers to a multi-byte data type storage space in which the low-order byte is stored at the starting address and the high-order byte is stored at the end address. For example, for 32-bit integers 0x11223344, in little-endian mode, the storage order is 44 33 22 11.

  4. Double type: double It is a floating-point data type in C language, used to represent double-precision floating-point numbers. Usually occupies 64 bits (8 bytes) of memory space and can represent floating point numbers with a larger range and higher precision.

  5. Machine Number Representation: Machine numbers are the binary form used to represent numbers in computers. Within the computer, both integers and floating-point numbers are stored and operated on as machine numbers.

  6. Continuous storage unit: Continuous storage unit refers to adjacent storage units in the memory, which can be bytes, words, etc. Data in memory is usually stored continuously according to address.

In this problem, the computer word length is 32 bits, and data is stored in little endian mode. doubleThe machine number of a type variable 0000 8040His stored continuously starting from . According to the little-endian method, 0000 8046Hthe content in the storage unit can be found as 22H.

13. Overflow judgment in complement operation

  • Judgment that the result of two's complement operation exceeds the representation range
  1. Signed integer: Signed integer is an integer data type that can represent positive numbers, negative numbers, and zero. In computers, signed integers are usually represented using two's complement notation. In two's complement, the highest bit (leftmost bit) is the sign bit, 0 represents a positive number and 1 represents a negative number.

  2. Two's complement representation: One's complement is a binary number encoding used to represent signed integers. For a positive integer, the complement is the same as its original code; for a negative integer, the complement is the sign bit of the original code inverted and then added by one. One advantage of complement is that it simplifies the operations of addition and subtraction because it allows the same addition circuit to be used for the operations.

  3. Machine numbers: Machine numbers are numbers represented in binary in computers. For signed integers, machine numbers are usually represented in two's complement format. Machine numbers contain a binary bit for the sign bit and the remaining bits used to represent the numerical value.

  4. Original code: The original code is a binary number encoding method used to represent signed integers. Its highest bit is the sign bit, 0 represents a positive number and 1 represents a negative number. The operation rules of the original code are relatively simple, but they are not commonly used in computer internal storage and operation.

In this problem, the machine numbers of two int type variables x and y are given using two's complement notation. Calculate their corresponding values ​​according to the rules of complement. Then, calculate the number of machines for x - y. Finally, compare the calculation results with the options and choose the correct answer. The answer is C.

14. Machine code corresponding to the instruction

  • Machine code encoding rules for different statements
  1. Byte addressing: Byte addressing is a method of computer memory addressing in which each memory unit is assigned a unique address, and each address represents a byte. In byte addressing, memory addresses are in byte increments, and each byte has a unique address.

  2. Little endian: Little endian is a data storage method in which the least significant byte of multi-byte data is stored at the lowest memory address, and the most significant byte is stored at the highest memory address. In little-endian mode, low-order data is stored at low addresses and high-order data is stored at high addresses.

  3. Machine code: Machine code is a binary instruction that a computer can directly execute. Each machine instruction corresponds to a specific opcode and is used to perform a basic operation of the computer. Machine code is the content in the executable file generated by a computer program after compilation.

In this question, the machine code corresponding to a statement "int i = 0;" is given, and it is required to determine the machine code of another statement "int i = -64;" according to the little-endian method. According to the question description and the rules of little-endian mode, choose the correct answer, that is, store the complement of -64 in bytes in the corresponding address. The answer is A.

15. The difference between logical right shift and arithmetic right shift

  • Logical and Arithmetic Shifting Rules and Results
    No problem, let me start with question 16 and create an outline for you step by step.
  1. Logical right shift: Logical right shift is a right shift operation of binary numbers, in which all bits are shifted to the right by a specified number of digits, and the highest bit is filled with 0. In logical right shift, all bits (including the sign bit) participate in the right shift, and the sign bit is not distinguished.

  2. Arithmetic right shift: Arithmetic right shift is a right shift operation on binary numbers, in which all bits are shifted to the right by a specified number of bits, and the highest bit is supplemented with the sign bit. In arithmetic right shift, the highest bit is the sign bit. When the sign bit is 1, the right shift fills the empty bit with 1. When the sign bit is 0, the right shift fills the empty bit with 0.

In this problem, the machine number of the integer x is given as 1101 1000, which requires logical right shift and arithmetic right shift operations. According to the rules, when the logical right shift is performed, all bits participate in the right shift, and the highest bit is filled with 0; when the arithmetic right shift is performed, the highest bit is the sign bit, and when the right shift is performed, the sign bit is supplemented. According to these rules, the results obtained are:

  • Logical shift right by 1 bit: 0110 1100
  • Arithmetic shift right by 1 bit: 1110 1100

Therefore, the correct answer is B.

16. Subtraction instructions

  • Function description: Perform subtraction operation and generate carry/borrow flag CF and overflow flag OF.
  • Command example:sub R1, R2, R3
  • Function implementation:(R1) - (R2) → R3
  • Instruction execution result analysis:
    • Register value: (R1) = FFFF FFFFH, (R2) = FFFF FFF0H
    • Result analysis: The values ​​of CF and OF are ()
    • Answer analysis: Determine the values ​​of CF and OF through complement operation.
  1. Carry flag (CF): The carry flag is a bit in the processor flags register that identifies whether a carry has occurred during an unsigned addition or subtraction operation. When performing an addition operation, if a carry occurs from the highest bit, the carry flag is set to 1; during a subtraction operation, if a borrow does not occur, the carry flag is set to 1. The carry flag plays a role in assisting judgment in some arithmetic operations.

  2. Overflow flag (OF): The overflow flag is a bit in the processor flags register and is used to identify whether an overflow has occurred during the addition or subtraction of signed numbers. When adding or subtracting signed numbers, the overflow flag is set to 1 if the result exceeds the representation range of signed numbers. The overflow flag is used in signed number operations to detect whether the result is out of bounds.

In this problem, the subtraction instruction "sub R1, R2, R3" is given, where the value of (R1) is FFFF FFFFH and the value of (R2) is FFFF FFF0H. According to the rules of complement subtraction, the calculation is performed and the carry flag (CF) and overflow flag (OF) are judged.

  • The result is 10H, that is, [-R2] complement = 00000010H.
  • The carry flag (CF) is 0 because no borrow occurred during the subtraction.
  • The overflow flag (OF) is 0, because in signed number subtraction, the condition for overflow is that subtraction of the same sign produces a result of different signs, and here, the subtraction of negative numbers does not cross the boundary.

Therefore, the correct answer is A.

17. Variable values ​​after execution of C language code

  • Inspection content: type conversion, numerical range
  • code segment:
    unsigned short usi = 65535;
    short si = usi;
    
  • Analyze sithe value of variable .
  1. Unsigned short (unsigned short): Unsigned short is one of the data types in the C language and is used to store positive integers. It usually occupies 2 bytes of storage space and represents a range from 0 to 65535 (2^16 - 1). Unsigned shorts do not allow negative numbers to be stored, so all bits are used to represent numeric values.

  2. Short integer (short): Short integer is one of the data types in C language and is used to store integers. It usually occupies 2 bytes of storage space, and the representable range is -32768 to 32767. On machines using two's complement representation, the most significant bit is used to represent the sign bit.

In this question, the given C language code is unsigned short usi = 65535;, where usiis assigned the value 65535. Then convert it to a signed short short si. Because usithe value of is 65535, which exceeds the representation range of the signed short integer, truncation occurs during the conversion.

  • The binary representation of 65535 is 1111 1111 1111 1111.
  • When it is converted into a signed short integer, it is expressed in two's complement, and the highest bit is the sign bit. Since the highest bit is 1, which represents a negative number, the sivalue of is -1.

Therefore, the correct answer is A.

18. Storage allocation of C language structures in memory

  • Structure description:struct record { short x1; int x2; } a;
  • Memory address allocation and member variable storage: first address, storage address of member variable x2.
  1. Byte Addressable: Indicates that the basic addressing unit of computer memory is bytes. Each byte has a unique address through which the data stored in memory can be accessed and manipulated.

  2. Little Endian: It is a way of storing multi-byte data, in which the lower address stores the least significant byte (LSB) of the data, and the higher address stores the most significant byte (MSB) of the data. In little-endian mode, the byte order of multi-byte data is from the least significant byte to the most significant byte.

  3. Alignment by boundary (Alignment): In computer architecture, in order to improve access speed, data is usually arranged at a specific address in the memory so that its address is an integer multiple of the data size. This is called aligning by boundary. In structures or other data types, the addresses of member variables are usually aligned by their size.

In this problem, a structure is given recordcontaining two member variables x1(short type) and x2(int type). The computer is byte-addressed in little-endian format and uses boundary alignment. The first address of the structure ais 2020 FE00H.

  • x1It is a short type, occupies 2 bytes, and is aligned according to the boundary, so x1the address is 2020 FE00H.
  • x2It is of type int, occupies 4 bytes, and is aligned according to the boundary, so x2the address is 2020 FE02H.

According to the little-endian method, x2the number of machines is 1234 0000H, of which 34H is located in the least significant byte position. Therefore, the address of the memory unit where 34H is located is 2020 FE06H.

Therefore, the correct answer is D.

19. Integer operations and register allocation

  • C language program segment analysis: operation expressions, register allocation.
  • Register content analysis: What are the contents of R1, R5 and R6 (expressed in hexadecimal).
  • Calculate the values ​​of variables m and k1 (in decimal notation).
  • Application of addition and subtraction auxiliary circuit and overflow judgment principle.
  1. Signed Integer: The integer representation contains positive numbers, negative numbers and zero. Signed integers use one binary bit as the sign bit to represent the sign bit, while the other bits represent the numeric portion. The highest bit (sign bit) is 0 for positive numbers and 1 for negative numbers.

  2. Two's Complement: Two's complement is a binary encoding used to represent signed integers. For negative numbers, the complement is the one's complement of its absolute value plus 1. The complement code solves the sign processing problem when adding and subtracting in computers, so that the adder does not need to distinguish between positive and negative numbers.

  3. Adder: In a computer, a circuit or component used to perform addition operations. Adders can be in the form of half adders, full adders, etc., and are used to perform integer addition operations in the arithmetic logic unit (ALU) of the computer.

  4. Carry Flag (CF): In computers, the carry flag is a flag used to identify whether a carry occurs during an addition operation. A carry occurs if the result of adding two unsigned integers exceeds the representable range.

  5. Overflow Flag (Overflow Flag, OF): In computers, the overflow flag is a flag bit used to identify whether an overflow occurs in a signed integer addition or subtraction operation. Overflow means that the calculation result exceeds the representation range of signed integers.

  6. Boundary alignment (Alignment): In computer architecture, the storage location of data in memory is aligned according to specific boundaries. Boundary alignment can improve the efficiency of memory access and reduce access time.

  7. Machine Number: In computers, machine numbers refer to numbers in the computer represented in binary. It can be an unsigned integer, a signed integer, a floating point number, etc.

  8. Carry: In addition operations, when the result of adding two binary bits exceeds the representable range, the extra bit generated is called a carry. This carry is passed to the high-order bit, affecting higher-order operations.

20. C language multiplication function

  • Function description: umuland imulimplement unsigned and signed integer multiplication respectively.
  • Computer instruction set and ALU functions.
  • Methods to implement multiplication instructions and the role of control logic.
  • The impact of multiplication instructions on running time and the conditions for determining result overflow.
  1. ALU (Arithmetic Logic Unit): Arithmetic Logic Unit, which is the part of the computer that performs arithmetic and logical operations. The ALU contains circuits for operations such as addition, subtraction, logical AND, or NOT.

  2. Control Logic: Control logic is the circuit or module in the computer that is responsible for coordinating and controlling the operation of various components. It determines when to start, stop, or switch various functional components based on instructions and clock signals.

  3. Shifter: A shifter is a circuit in a computer that is used to perform displacement operations on data. Bit shift operations can implement functions such as multiplication, division, and logical shifts.

  4. Array multiplier (Multiplier Array): A hardware multiplier structure that improves the speed of multiplication operations by decomposing the multiplication operation into multiple addition and displacement operations and performing parallel calculations in the form of an array.

  5. Loop Code Segment: In a computer program, a section of code is repeatedly executed through a loop structure. Loop code segments can be used to implement multiplication operations, simulating multiplication through multiple additions and shift operations.

  6. Signed Integer: Represents a positive or negative integer. In computers, signed integers use the highest bit as the sign bit and the remaining bits represent the numeric value.

  7. Unsigned Integer: Represents an integer with only positive numbers or zero. In computers, all bits of an unsigned integer are used to represent a numerical value, and there is no sign bit.

  8. Overflow: In computers, overflow refers to the situation where the result of an operation exceeds the range that the data type can represent, resulting in the result being unable to be represented correctly.

  9. Clock Cycle: The time period of the basic clock pulse in a computer, used to synchronize the operation of various components. The length of the clock cycle is directly related to the running speed of the computer.

  10. 64-bit Product: In computers, it represents the result of multiplying two 64-bit integers. 64-bit products are typically used to hold the results of large range integer multiplication operations.

21. Floating point addition operation

  • Floating point description: X = 2^7 * 29/32, Y = 2^5 * 5/8.
  • Analysis of steps for adding floating point numbers.
  • Calculation of final results and judgment of overflow conditions.
  1. Floating Point Number: A way of representing real numbers in computers. It consists of an exponent and a mantissa. It can represent very large or very small numbers and provide a certain degree of accuracy.

  2. Two's Complement Representation: Two's complement is a binary encoding method used to represent signed integers. Negative integers are represented by inverting the binary representation of positive integers and adding 1.

  3. Exponent: The binary number used to represent the exponent part of a floating point number. It determines the order of magnitude of floating point numbers.

  4. Mantissa (Fraction/Mantissa): The binary number used to represent the decimal part of a floating point number. The mantissa determines the precision of floating point numbers.

  5. Floating Point Addition: The addition operation between floating point numbers, involving steps such as order alignment, mantissa operation, normalization, rounding and overflow determination.

  6. Normalization: In floating-point operations, the mantissa is adjusted to a specified form, usually by setting the highest bit of the mantissa to 1.

  7. Rounding: In floating-point operations, due to the limited number of mantissa digits, the result needs to be rounded to adapt to the precision of floating-point number representation.

  8. Overflow: In floating-point operations, the result exceeds the range of floating-point numbers. Overflows need to be detected and handled to ensure correct calculations.

  9. Sign Bit: A binary bit used to represent positive and negative in floating point numbers, usually before the exponent code.

  10. Number of Bits: In floating-point numbers, the number of binary digits in the exponent and mantissa determines the representation range and precision of floating-point numbers.

  11. Right Normalize: The process of shifting the mantissas to the right for normalization, usually after adding the mantissas.

  12. Align to the Smaller Exponent: In floating-point addition, the mantissa of the floating-point number with the smaller exponent is shifted to the right to make the exponents of the two floating-point numbers equal.

22. Calculation of relational expressions of different data types

  • Data type conversion: int, float and double types.
  • Judgment of relational expression results.
  • The impact of type conversion on accuracy and the judgment of true or false results.
  1. IEEE 754: A standard for floating-point number representation that defines the binary representation of floating-point numbers, rounding rules, etc., and is widely used in computers.

  2. Two's Complement Representation: Two's complement is a binary encoding method used to represent signed integers. Negative integers are represented by inverting the binary representation of positive integers and adding 1.

  3. 32-bit machine: Indicates that the number of integers and pointers in the computer is 32 bits. This determines the computer's addressing range and data representation accuracy.

  4. IEEE 754 single-precision floating-point number: Single-precision floating-point number format, using 32-bit representation, including sign bit, 8-bit exponent bit and 23-bit mantissa bit, used to represent floating-point numbers.

  5. IEEE 754 double-precision floating-point number: A double-precision floating-point number format that uses 64 bits, including a sign bit, an 11-bit exponent bit, and a 52-bit mantissa bit to represent a double-precision floating point number.

  6. Casting: In programming, the operation of converting one data type to another. In this question, it involves converting an integer to a floating point number, and converting between single and double precision of a floating point number.

  7. 32-bit integer: An integer represented using 32 bits, ranging from -2^31 to 2^31 - 1.

  8. Exponent: The binary number used to represent the exponent part of a floating point number. It determines the order of magnitude of floating point numbers.

  9. Mantissa (Fraction/Mantissa): The binary number used to represent the decimal part in floating point numbers. The mantissa determines the precision of floating point numbers.

  10. Forced type conversion rules: In computers, there are certain rules when converting between different data types, such as rounding, overflow, etc. These rules are very important during type conversion.

  11. Floating-point number operations: Perform operations such as addition, subtraction, multiplication, and division of floating-point numbers in the computer. This involves steps such as order alignment, mantissa operations, normalization, rounding, and overflow judgment.

23. IEEE 754 single-precision floating-point number representation

  • Representation and conversion of floating point number x.
  • Content analysis of the FR1 register: the IEEE 754 standard's way of representing floating-point numbers.
  1. IEEE 754 single-precision format: A floating-point number representation format defined by the IEEE 754 standard, using 32-bit binary to represent a floating-point number. It includes 1 sign bit, 8 exponent bits (exponent part) and 23 mantissa bits (fractional part).

  2. The compiler allocates the float type variable x in a 32-bit floating point register FR1: this means that the variable x is stored in the memory in IEEE 754 single-precision format and occupies a 32-bit register FR1.

  3. x = -8.25: The value of variable x is -8.25.

  4. IEEE 754 single-precision floating-point number representation: Convert floating-point numbers to IEEE 754 single-precision format, including number sign, exponent code and mantissa.

  5. Contents of FR1: The binary content stored in register FR1, which is a representation of IEEE 754 single precision format.

  6. Option A. C104 0000H: The 32-bit hexadecimal representation given in Option A represents the format of an IEEE 754 single-precision floating point number.

  7. Options B. C242 0000H, C. C184 0000H, D. C1C2 0000H: Other options, which may be based on misunderstandings or incorrect calculations.

  8. Exponent code E: The exponent code in IEEE 754, used to determine the exponent part of a floating point number.

  9. Hiding the highest bit 1: In the IEEE 754 single-precision floating point number specification, the highest bit of the mantissa is always implicitly 1, so there is no need to explicitly save this bit during actual storage.

  10. Offset value: The value used to represent the exponent in IEEE 754 is stored by adding an offset value to the actual exponent value so that signed numbers can also be compared as unsigned integers.

This question tests understanding of the IEEE 754 representation of single-precision floating-point numbers and whether the various parts of the floating-point number are correctly considered when calculating register contents.

24. IEEE 754 Maximum positive integer representation of single-precision floating point numbers

  • The range and precision of floating point numbers.
  • IEEE 754 Maximum integer representation of a single-precision floating-point number.
  • Calculation of the largest positive integer value and description of the range of representation.
  1. float type: refers to the IEEE 754 single-precision floating-point number format, which is used to represent single-precision floating-point numbers and occupies 32-bit storage space.

  2. IEEE 754 single-precision floating-point format: A binary standard for representing floating-point numbers, including the sign bit, exponent code, and mantissa, where the most significant bit of the mantissa is usually implicit.

  3. Maximum positive integer representation: In IEEE 754 single-precision floating point numbers, when representing the largest positive integer, the mantissa part will be all ones, so the maximum integer is determined by the maximum value of the mantissa part.

  4. Options A. 2 126-2 103, B. 2 127-2 104, C. 2 127-2 103, D. 2 128-2 104: Each option gives a range, indicating the maximum value that the float type can represent Positive integer.

  5. Correct answer: By understanding the IEEE 754 single-precision floating-point number format, especially that all 1s in the mantissa represent the largest integer, the correct answer can be derived as D. 2 128-2 104.

  6. Calculation of the largest integer: The calculation of the largest integer is by making the mantissa part 2^23-1, and then multiplying by the corresponding power of 2 to obtain 2^(127-127) × (2^23-1) = 2^104 × (2^23-1).

This question requires a clear understanding of the characteristics of the IEEE 754 single-precision floating point format, especially that the mantissa is all 1's to represent the largest integer. Such problems can be solved by becoming familiar with the structure and rules of floating point number formats.

25. IEEE 754 single-precision floating point number representation

  • Floating-point number representation: IEEE 754 single-precision floating-point number format
  • Conversion steps: Convert the hexadecimal number to binary and parse it into number sign, exponent code and mantissa according to IEEE 754 standard
  • Calculated value: Calculate the actual value of the floating point number based on the exponent and mantissa
  1. IEEE 754 single-precision floating-point format: A binary standard for representing floating-point numbers, including the sign bit, exponent code, and mantissa, where the most significant bit of the mantissa is usually implicit.

  2. The given value: C640 0000H is a 32-bit hexadecimal number representing a floating-point number in IEEE 754 single-precision floating-point format.

  3. Parse the given value: C640 0000H converted to binary format is 1100 0110 0100 0000 0000 0000 0000 0000.

  4. IEEE 754 floating-point number format: The first bit in the format represents the sign, the next 8 bits represent the exponent, and the remaining 23 bits represent the mantissa.

  5. Compute exponent and mantissa: Extracts the sign, exponent and mantissa from the given binary format. The sign bit is 1, indicating a negative number. The exponent code is 1000 1100, and the mantissa is 1.1 (implied bit).

  6. Floating point value calculation: Combining the sign, exponent, and mantissa gives a value of -1.5 × 2^13.

  7. Representation of options: Option A. -1.5 × 2^13 is the correct representation.

This question tests the understanding of the IEEE 754 single-precision floating-point number format and how to parse the value of a floating-point number from a binary format. It is very important to be familiar with the storage format and corresponding calculation rules of floating point numbers to correctly answer such questions.

26. Floating point comparison

  • IEEE 754 floating point number representation: number sign, exponent code, mantissa
  • Sign and size comparison: Compare the relationship between two floating point numbers through exponent and mantissa size
  1. IEEE 754 single-precision floating-point format: A binary standard for representing floating-point numbers, including the sign bit, exponent code, and mantissa, where the most significant bit of the mantissa is usually implicit.

  2. Given value: The hexadecimal representation of two floating point numbers is given, which are CC90 0000H and B0C0 0000H.

  3. Parses the given numeric value: Converts the hexadecimal representation of two floating point numbers to binary.

  4. IEEE 754 floating point format: The first bit in the binary format represents the sign, the next 8 bits represent the exponent, and the remaining 23 bits represent the mantissa.

  5. Compute exponent and mantissa: Extracts the sign, exponent and mantissa from the given binary format.

    • For CC90 0000H, the sign bit is 1, the exponent code is 10011001, and the mantissa is 1.001.
    • For B0C0 0000H, the sign bit is 1, the exponent code is 01100001, and the mantissa is 1.1.
  6. Size comparison of floating point numbers: By comparing the exponent and mantissa values, the relative size of two floating point numbers can be determined.

    • Since the signs are the same, compare the absolute values. The absolute value of CC90 0000H is larger than B0C0 0000H.
    • Therefore, the true value of (f1) is smaller than the true value of (f2), that is, x < y.
  7. Sign judgment: Since the sign bits of both numbers are 1, that is, negative numbers, the signs are the same.

  8. Comprehensive: From the above analysis, x < y and the signs are the same, so the answer is option A.

This question tests your understanding of the IEEE 754 single-precision floating-point number format and how to parse and compare the sizes of floating-point numbers. Familiarity with the storage format of floating point numbers and the corresponding comparison rules is critical to correctly answering such questions.

27. Floating point addition and subtraction operations

  • Order operation: does not cause overflow or underflow of the order code
  • Right-hand and mantissa rounding: may cause exponent overflow
  • Left rule: may cause code underflow
  • Mantissa overflow: the result does not necessarily overflow
  1. Order-alignment operation: In floating-point number operations, order-alignment is the operation of aligning the order codes of two floating-point numbers for addition or subtraction.

  2. Code overflow and underflow:

    • Exponent overflow: During an order operation, if the resulting exponent exceeds the floating-point representation range, an exponent overflow will occur.
    • Exponent underflow: If the resulting exponent is less than the lower limit of the floating-point representation range, exponent underflow will occur.
  3. Right-hand and mantissa rounding:

    • Right rule: Adjust the mantissa and exponent of the floating point number to make it comply with the specifications of the floating point number.
    • Mantissa rounding: Round the mantissa to adapt to the representation requirements of floating point numbers.
  4. Left-hand rule: Adjust the exponent and mantissa of a floating point number, usually by shifting the mantissa to the left, which may cause exponent underflow.

  5. Mantissa overflow: Mantissa overflow occurs when the calculation result of the mantissa cannot be fully represented, which may lead to errors.

According to the above explanation, the correct statement is:

  • I. The sequence operation will not cause code overflow or underflow.
  • II. Both right-hand and mantissa rounding may cause exponent overflow.
  • III. Left-hand scrolling may cause code underflow.
  • IV. The result does not necessarily overflow when the mantissa overflows.

Therefore, the correct answer is option D.

28. Minimum normalized positive number

  • IEEE 754 single-precision floating point number specifications: sign bit, exponent bit, mantissa bit
  • Minimum normalized positive number calculation: Calculate the value of the minimum normalized positive number through the normalized range
  1. IEEE 754 single-precision floating point format:

    • Single-precision floating point numbers are represented by 32 bits, which are divided into sign bits, exponent bits and mantissa bits. Among them, 1 bit is the sign bit, 8 bits are the exponent bits, and 23 bits are the mantissa bits.
  2. Representation of the smallest normalized positive number:

    • The minimum normalized positive number refers to the smallest positive number represented in a floating point number, that is, the minimum value of the mantissa, and the exponent is the exponent of the minimum normalized positive number.
    • For IEEE 754 single-precision floating point numbers, the representation of the smallest normalized positive number is [1.0 \times 2^{-126}].
    • The specific composition is: the sign bit is 0 (positive number), the exponent code is 1 (frameshift representation), and the mantissa is 0.
  3. The derivation process:

    • The frameshift value range is 1~254, and we need the minimum normalized positive number, so the minimum frameshift value is 1.
    • The exponent value is frameshift - 127, that is (1 - 127 = -126).
    • The mantissa is all zeros because we want to get the smallest normalized positive number.
  4. final conclusion:

    • Therefore, the IEEE 754 single-precision floating point representation of the smallest normalized positive number is [1.0 \times 2^{-126}].
    • Among the options provided, the one that meets the definition of the smallest normalized positive number is option A, which is [1.0 \times 2^{-126}].

29. Representation of numbers

  • Two's complement representation of signed integers
  • Float data representation under the IEEE 754 standard
  • Numeric conversion: Convert the machine number to the corresponding float or int type value
  1. Sign bit :

    • The sign bit represents the sign of a floating point number, where 0 represents a positive number and 1 represents a negative number.
  2. Code :

    • The exponent code is a part of a floating-point number used to represent the exponent part. It is represented by a frameshift, that is, an offset value is subtracted. In the IEEE 754 standard, the exponent of a double-precision floating point number is 11 bits.
  3. mantissa :

    • The mantissa is the fractional part of a floating point number, and the leading 1 is usually omitted in binary representation. In IEEE 754 double-precision floating point numbers, the mantissa occupies 52 bits.
  4. True value :

    • The true value is the actual value represented by a floating point number, calculated from the sign bit, exponent, and mantissa. The sign bit determines the positive and negative, the exponent code performs exponential operation, and the mantissa represents the decimal part.
  5. Size relationship :

    • Comparing the size of two floating point numbers usually involves comparing the sign bit, exponent, and mantissa. Here, by comparing the sign bit, exponent and mantissa values ​​of X and Y, it can be determined that X is greater than Y.

30. IEEE 754 floating point number representation

  • Accurate representation of values: Examine which values ​​cannot be accurately represented using IEEE 754 floating point format

  • Elimination method: Analyze candidate values ​​to identify values ​​that cannot be accurately represented in the limited-precision IEEE 754 format

  • IEEE 754 floating-point format:
    IEEE 754 is a standard for binary and decimal floating-point number representation. It defines the representation method, operation rules and exception handling of floating-point numbers. It includes both single-precision (32-bit) and double-precision (64-bit) formats for performing floating-point number operations in computer systems. This standard specifies the sign of floating point numbers, the storage method of exponent and mantissa, and the rules for various arithmetic operations.

  • Method of Elimination:
    The method of elimination is a method of problem solving in which incorrect options are eliminated one by one to find the correct answer. In this context, a process of elimination is used to determine which values ​​cannot be accurately represented in IEEE 754 floating-point format. By analyzing each option, eliminating options that can be accurately represented, and ultimately determining values ​​that cannot be accurately represented.

  • Infinitely recurring decimal:
    An infinitely recurring decimal means that the numbers in the decimal part begin to repeat infinitely at a certain position. In this question, point out that the result of converting the decimal fraction 1.2 of option A into binary is an infinitely recurring decimal 1.001100110011…. This means that the value cannot be accurately represented in the limited-precision IEEE 754 floating-point format.

31. Floating point conversion

  • IEEE 754 single-precision floating-point number representation

  • Numeric conversion step: Convert the given numerical value to IEEE 754 single-precision floating point format

  • IEEE 754 single-precision floating-point number:
    IEEE 754 single-precision floating-point number is a binary floating-point number representation that includes a sign bit, an exponent code, and a mantissa, and is used to represent real numbers in computers. Among them, the sign bit represents the sign, the exponent represents the position of the floating point number, and the mantissa represents the significant digit.

  • Infinite loop:
    An infinite loop is when a program falls into a state of executing the same piece of code infinitely. In this question, when n=0, since i and n are unsigned types, the condition "i<=n-1" is always true, resulting in an infinite loop. If i and n are changed to int type, an infinite loop will not occur.

  • Machine number:
    A machine number is a number represented in binary in a computer and can be an integer or a floating point number. In this question, the machine number representation of integers and floating point numbers is involved.

  • IEEE 754 Overflow and Rounding of Floating-Point Number Representations:
    The IEEE 754 floating-point number standard specifies the representation of floating-point numbers, including overflow and rounding rules. In the question, the return values ​​​​of f1(23) and f2(23) are equal, and the return values ​​​​of f1(24) and f2(24) are not equal, which involves rounding and overflow.

  • Maximum representation range:
    In computers, data types have a maximum representation range. For integer data, the maximum range is determined by the number of digits; for floating-point numbers, the IEEE 754 single-precision standard specifies the number of digits in the exponent and mantissa, which determines the range and precision that floating-point numbers can represent. In this question, it involves the discussion of the maximum representation range of f1(n) and f2(n).

  • Infinity and precise representation:
    The IEEE 754 standard uses "all 1s in the exponent code and all 0s in the mantissa" to represent infinity. In the question, the number of machines involved in f2(127) is 7F80 0000H, and the corresponding value is +∞. At the same time, the conditions for making the result of f2(n) not overflow, the maximum value of n, and making the result of f2(n) accurate are discussed.

Chapter 6 Command System

1. Instruction word length calculation

  • The quantitative relationship between three-address instructions and two-address instructions
  • Calculation of operation code digits
  • Minimum instruction word length
    In this question, there are several professional terms worth explaining:
  1. Instruction Word Length: The instruction word length is the number of bits in the binary representation of the instruction in the computer. It determines the number of bits each instruction occupies in the computer's memory. Here, what's involved in the question is the length of the instruction, in bits.

  2. Byte Addressable: This is a computer memory addressing method in which each memory address corresponds to a byte. A byte is the smallest addressable unit of computer storage.

  3. Address Field: In an instruction, the address field is the part used to specify the operand or the address of the operand. In this problem, each address field is 6 bits long.

  4. Three-address instructions and two-address instructions: These are two instruction formats in the instruction set architecture. Three-address instructions contain three address fields and are typically used to perform more complex operations, while two-address instructions contain two address fields and are typically used for simpler operations.

  5. Opcode: The opcode is a part of the instruction that specifies the type of operation. It tells the computer what operation it should perform. In this problem, the number of bits in the opcode determines the size of the instruction set.

Understanding these professional terms will help you understand the design and working principles of computer instruction systems.

2. Instruction Set Architecture (ISA) regulations

  • Instruction word format and instruction type
  • CPU clock cycle
  • Number and number of general-purpose registers
  • Adder carry mode
    In this question, there are several concepts that are involved in the instruction set architecture (ISA):
  1. Instruction Word Format and Instruction Types: The instruction set architecture specifies the format of computer instructions and the supported instruction types. This determines the types and formats of instructions available to programmers.

  2. Number and Bit-width of General Registers: ISA specifies the number of general-purpose registers and the number of bits in each register in the computer architecture. This affects the register-level parallelism of the program and the number of available registers.

  3. Clock Cycle of the CPU: ISA can affect the clock cycle of the CPU to a certain extent, but the clock cycle is more related to the hardware implementation of the computer.

  4. Carry Propagation in the Adder: The carry mode of the adder is a hardware implementation related to the specific arithmetic logic circuit design and is not specified by the ISA.

In the context of this question, the correct answer is B, because the instruction word format and the number and digits of general registers are related to ISA, while the clock cycle of the CPU and the carry method of the adder are more focused on computer hardware design aspect.

3. Command system design

  • Fixed length instruction word format design
  • Opcode extension encoding method
  • Address code number and command format
  • The relationship between the number of zero-address, one-address, and two-address instructions
    . In this question, there are several concepts worth explaining:
  1. Fixed-Length Instruction Word Format: This means that all instructions have the same length in memory, which is 16 bits. This format helps simplify the decoding and execution of instructions.

  2. Extended Encoding: This is a representation of opcodes, usually used to increase the number of opcodes. It allows using more bits to represent more different operations.

  3. Instructions in zero address, one address, and two address formats: This refers to the addressing mode of the operands in the instruction. Zero-address instructions require no operands, one-address instructions have one operand, and two-address instructions have two operands.

In the context of this question, the correct answer is D, there are at most 128 zero address instructions. This is done by calculating that among the remaining 16-bit instructions, excluding the space occupied by one-address instructions and two-address instructions, the rest can be used for zero-address instructions. The calculation method is: 2 16 − 254 × 2 6 − 12 × 2 6 = 2 10 − 254 − 12 × 2 6 = 128 × 2 6 = 128 × 64 = 8192 2^{16} - 254 \times 2^6 - 12 \times 2^6 = 2^{10} - 254 - 12 \times 2^6 = 128 \times 2^6 = 128 \times 64 = 8192216254×2612×26=21025412×26=128×26=128×64=8192

4. Transfer instruction design and relative addressing

  • Word length and byte addressing
  • Relative addressing mode
  • The impact of PC automatically increasing by 1 on transfer instructions
  • Target Address Calculation of Branch Instructions
    In this question, there are several concepts that need to be explained:
  1. Machine Word Length: This refers to the number of bits that the computer can process in one operation. Here, the machine word length is 16 bits, that is, each operation processes 16 bits of data.

  2. Main memory is byte addressable (Byte Addressable Memory): This means that the addressing of main memory is in bytes. Each storage unit has a unique address through which data can be read and written.

  3. Relative Addressing: This is an addressing method in which the address is a displacement relative to a reference point. Here, the relative displacement field is used to calculate the target address.

  4. PC (Program Counter): This is a register that stores the address of the instruction currently being executed. Each time an instruction is fetched, the PC is automatically incremented and points to the next instruction.

In the context of this question, the correct answer is C and the target address is 2008H. This is calculated by calculating the relative addressing formula EA=(PC)+A, where the value of PC after fetching is 2002H, and the content of the relative displacement field is 06H, so EA=2002H+06H=2008H. In this process, it is necessary to consider that the PC value will automatically increase every time a byte is taken.

5. Addressing method

  • offset addressing
  • Indirect addressing
  • base addressing
  • relative addressing
  • Indexed Addressing
    In this question, there are several concepts involved in addressing modes:
  1. Offset Addressing: This is an addressing method in which the contents of a register are added to the formal address to generate an effective address. This makes it easy to reference different locations in memory.

  2. Indirect Addressing: This is an addressing method in which the formal address contains another address, and the effective address is obtained by accessing this address. Here, indirect addressing does not involve offsetting the contents of the register.

  3. Base Addressing: This is an offset addressing method, where the offset is the contents of the register, and the effective address is obtained by adding the base address and the contents of the register.

  4. Relative Addressing: This is also an offset addressing method, where the offset is the displacement relative to a certain reference point, and the effective address is obtained by adding the relative address and the contents of the register.

  5. Indexed Addressing: This is also an offset addressing method, where the offset is the contents of the register, and the effective address is obtained by adding the contents of the index register to the formal address.

In this context, the correct answer is A, indirect addressing. Because indirect addressing does not involve offsetting the contents of a register, but directly using another address contained in the formal address.

6. Flag register and conditional transfer instructions

  • Each flag bit in the flag register (CF, ZF, SF, OF)
  • Calculation of transfer conditions of conditional transfer instructions
    In this question, there are several concepts of flag registers and comparison conditions of conditional transfer instructions:
  1. Flag register: This is a register specifically used to store processor status information. Here, the flag register contains the carry/borrow flag CF, zero flag ZF, sign flag SF and overflow flag OF.

  2. Conditional jump instruction: This is a machine instruction whose execution depends on whether a specific condition is true or not. Here, the bgt instruction is used to compare unsigned integers, and the condition is to perform a branch when the first operand is greater than the second operand.

In this context, the correct answer is C, which is CF + ZF = 1. Because the bgt instruction performs an unsigned integer comparison, when the first operand A is greater than the second operand B, A - B will not produce a carry/borrow (CF = 0), and the result will not be 0 ( ZF = 0). Therefore, CF + ZF = 0 + 1 = 1. Neither SF nor OF in the other options apply to unsigned integer comparisons.

7. Indexed addressing mode

  • The concept of index register
  • Effective address calculation for indexed addressing
    In this question, there are several professional terms related to computer architecture and addressing methods:
  1. Index Register: An index register is a register in a computer, usually used to store an address or an offset relative to an address. Here, the content of index register R is 1000H.

  2. Formal Address (Effective Address): The formal address is the address contained in the instruction, usually a relative address or an absolute address. Here, the formal address in the instruction is 2000H.

  3. Effective Address: The actual address is an address calculated based on the addressing method. It is the result of certain calculations of the formal address. Here, through the index addressing method, the contents of the index register are added to the formal address to obtain the actual address of the operand, which is 3000H.

  4. Addressing Mode: Addressing mode describes how to calculate the actual address of an operand. Here, the indexed addressing mode is involved, in which the contents of the index register are added to the formal address.

  5. Operand (Operand): The operand is the data in the instruction. It can be a source operand, destination operand, or both. Here, after we calculate the actual address, the content obtained from the memory address 3000H is the operand 4000H.

These professional terms help to understand the computer's addressing mechanism and the execution process of instructions.

8. Register addressing and offset calculation

  • Number and bits of general-purpose registers
  • Register addressing mode
  • Calculation of offset value range
    In this question, there are several professional terms related to computer architecture and addressing methods:
  1. General Register: A general register is a register that can store data and is usually used to store intermediate results and temporary data. Here, the computer has 16 general purpose registers.

  2. Fixed-Length Instruction Word: This means that the length of each instruction in the computer instructions is fixed. Here, the length of the instruction word is 32 bits.

  3. Opcode Field: The opcode field is the part of the instruction that specifies the type of operation. Here, the opcode field contains 8 bits.

  4. Register Direct Addressing: This is an addressing mode in which the address of the operand points directly to the register. Here, the source operand of the Store instruction uses register direct addressing.

  5. Base Addressing: This is an addressing mode in which the address of the operand is obtained by adding the contents of a base register to an offset. Here, the destination operand of the Store instruction is addressed using base address.

  6. Offset: The offset is the value used in base addressing, usually a displacement relative to the base address.

  7. Two's Complement Representation: Two's complement is a method of representing signed integers, in which the complement of a positive number is the same as its original code, and the complement of a negative number is the inversion of its original code and adding 1.

In this context, the correct answer is A, which is -32768~+32767. This is obtained by calculating the number of bits (16 bits) that can be used for the offset, and the range of values ​​represented by the two's complement representation.

9. Addressing mode in instruction format

  • Calculation of operand effective address in indexed addressing mode
  • Addressing method of indexing first and indirect addressing
    In this question, there are several professional terms related to computer instruction format and addressing mode:
  1. Instruction Format: Instruction format refers to the structure of the binary representation of a machine instruction in memory. Here, the format of an instruction is given, including addressing mode M, index register number I and formal address D.

  2. Addressing Mode: Addressing mode describes how to calculate the actual address of an operand. Here, two addressing methods, indexed addressing and indirect addressing, are involved.

  3. Indexed Addressing: This is an addressing mode in which the contents of a register are added to the formal address to generate the actual address. Here, the form of indexed addressing is (I)+D.

  4. Indirect Addressing: This is an addressing method in which the formal address contains another address, and the effective address is obtained by accessing this address. Here, the formal address of the instruction is (D).

  5. Effective Address: The effective address is the calculated actual address of an operand, which is obtained through some calculation in the addressing mode.

In this context, the correct answer is C, which is ((I)+D). Because the addressing mode of index first and then indirect address is adopted, the effective address is equal to the sum of the contents of the index register I and the formal address D, that is, ((I)+D).

10. Optimal addressing method for accessing array elements

  • Comparison of relative addressing, register addressing, direct addressing, and indexed addressing
  • The addressing method that is most suitable for accessing one-dimensional array elements in subscript order
    . In this question, there are several professional terms related to addressing methods:
  1. Relative Addressing: This is an addressing method in which the address is a displacement relative to a reference point. Here, relative addressing uses PC as the base address and the address in the instruction as the offset to determine the effective address.

  2. Register Addressing: This is an addressing mode in which the address of the operand points directly to a register. Here, register addressing indicates in the instruction which register needs to be used.

  3. Direct Addressing: This is an addressing mode in which the address field of the instruction directly points to the effective address of the operand.

  4. Indexed Addressing: This is an addressing mode in which the contents of a register are added to the formal address to generate the actual address. Here, indexed addressing is suitable for accessing the elements of a one-dimensional array in subscript order because the individual elements of the array can be accessed sequentially by continuously increasing the value of the index register.

In this context, the correct answer is D, which is indexed addressing. Because when accessing one-dimensional array elements in subscript order, indexed addressing allows each element in the array to be located by incrementing the value of the index register, which is more efficient.

11. Indexed addressing and array access

  • Machine number calculation for indexed addressing mode
  • The relationship between index value and array subscript
    In this question, there are several professional terms related to computer addressing and array access:
  1. Byte Addressing: This is a memory addressing method in which each address unit corresponds to a byte. Here, the computer is byte-addressed, that is, each address unit corresponds to a byte.

  2. Double Type Array: This is an array in which the data type of each element is double (double-precision floating point number).

  3. Base Address: This is the starting address of the array in memory. Here, the first address of double array A is 2000H.

  4. Indexed Addressing: This is an addressing mode in which the contents of a register are added to the formal address to generate the actual address. Here, indexed addressing is used to access the elements of array A.

  5. sizeof(): This is an operator that returns the size of a data type or object in bytes. Here, sizeof(double) returns the size of double type, usually 8 bytes.

In this context, the correct answer is B, which is 32. Because according to the formula of indexed addressing EA = (IX) + A EA = (IX) + AEA=(IX)+A , of whichAAA is the offset address,A = 2100 H − 2000 H = 100 H = 256 A = 2100H - 2000H = 100H = 256A=2100H2000H=100H=256 s i z e o f ( d o u b l e ) = 8 sizeof(double) = 8 sizeof(double)=8 , so the subscript of the array is256 / 8 = 32 256 / 8 = 32256/8=32 . This means that when entering this cycle, the content of the index register is 32.

12. Big-endian addressing and operand address calculation

  • Big-endian byte storage rules
  • Example of operand address calculation
    In this question, there are several professional terms related to computer memory addressing methods and byte order:
  1. Big Endian: Big Endian is a byte ordering method in which the most significant byte (MSB) of the data is stored at the lowest memory address, and the least significant byte (LSB) is stored at the highest memory address. address. Here, the computer works in big-endian fashion.

  2. Byte Addressing: This is a memory addressing method in which each address unit corresponds to a byte. Here, the computer is addressed by bytes.

  3. Base Addressing: This is an addressing mode in which the address of the operand is obtained by adding the contents of a base register to an offset. Here, the operand adopts base addressing mode, that is, EA = (BR) + A EA = (BR) + AEA=(BR)+A

  4. Formal Address (Effective Address): The formal address is the address contained in the instruction, which needs to be added to the base address to generate an effective address. Here, the formal address is expressed as FF12H in two's complement.

  5. LSB (Least Significant Byte): LSB refers to the least significant byte of data, that is, the rightmost byte of data.

In this context, the correct answer is D, which is EFFF FF15H. Because the computer uses big-endian mode, the address where the LSB is located is the address of the highest byte of the formal address EFFF FF12H, that is, EFFF FF15H.

13. Addressable range of fixed-length instruction words and addressing modes

  • Instruction word format design
  • Addressing mode bit calculation
  • Addressable range of direct addressing mode

In this question, there are several professional terms related to computer instruction formats and addressing methods:

  1. Fixed-Length Instruction Word format (Fixed-Length Instruction Word): This means that the length of each instruction in the computer instructions is fixed. Here, the length of the instruction word is 16 bits.

  2. Opcode Field: The opcode field is the part of the instruction that specifies the type of operation. Here, 48 instructions require a 6-bit opcode field.

  3. Addressing Mode: Addressing mode describes how to calculate the actual address of an operand. Here, four addressing modes are supported: direct, indirect, immediate, and relative.

  4. Direct Addressing: This is an addressing mode in which the address of the operand points directly to a location in memory. Here, the addressable range of direct addressing mode is discussed in the question.

In this context, the correct answer is A, which is 0~255. Because 48 instructions require a 6-bit opcode field and 4 addressing modes require 2-bit addressing flags, the remaining 8 bits are used as address codes. The addressable range of direct addressing mode is 0 2 8 − 1 0~2^8-10 281 , that is,0 255 0~2550 255  . It should be noted that the main memory address cannot be negative.

14. Computer command system

14.1 Overview of the command system
  • The word length of the instruction system is 16 bits
  • The main memory address space size is 128KB, word-addressed
14.2 Instruction field definition
  • Transfer instructions use relative addressing mode
  • Addressing modes include register direct, register indirect, register indirect increment and relative addressing
14.3 Answers to questions
  1. Instruction set and registers

    • The instruction system defines up to 16 instructions
    • 8 general purpose registers
    • MAR must be at least 16 digits, MDR must be at least 16 digits
  2. The target address range of the branch instruction

    • Target address range: 0000H~FFFFH
  3. Machine code and execution process of addition operation

    • Machine code: 2315H
    • After execution, R5=5679H, the content of storage unit 5678H becomes 68ACH
  • Word Length: Word length refers to the number of binary digits contained in a word in a computer. Here, the word length is 16 bits, meaning each word contains 16 binary bits.

  • Main Memory Address Space: The main memory address space is the addressable memory size of the computer. Here, the main memory address space size is 128KB, which means that the size of the memory space that the computer can address is 128 kilobytes.

  • Word Addressing: Word addressing means that each address unit corresponds to a word. Here, word addressing means that each address unit corresponds to a 16-bit word, that is, two bytes.

  • Single-Word Instruction Format: Single-Word Instruction Format means that each instruction occupies one word. Here, the length of the instruction is 16 bits, which is two bytes.

  • Branch Instruction: Branch instruction is a type of instruction used to change the sequence execution flow of the program. Here, the transfer instruction uses relative addressing, and the relative offset is expressed in complement.

  • Relative Offset: Relative offset is the offset in relative addressing mode, usually expressed in complement. Here, the relative offset is used to calculate the branch target address.

  • General Register: A general register is a register in a computer used to store temporary data. Here, the computer has up to 8 general purpose registers, each register is 16 bits in length.

  • Memory Address Register (MAR): The memory address register is used to store the memory address to be accessed. Here, the MAR needs to be at least 16 bits to fit in the size of the main memory address space.

  • Memory Data Register (MDR): The memory data register is used to store data read from or written to memory. Here, the MDR requires at least 16 bits to accommodate the word length.

  • Machine Code: Machine code is a binary form of instructions that a computer can directly execute. Here, after the assembly statement is processed by the assembler, the corresponding machine code is generated, expressed in hexadecimal.

  • Hexadecimal Representation: Hexadecimal is a mathematical counting system that uses 0-9 and AF (or af) to represent 16 numbers. Here, the machine code is represented in hexadecimal for easy human reading and understanding.

15. Computer conditional jump instructions

15.1 Command format
  • 16-bit fixed-length instruction word
  • Conditional transfer instruction format definition
15.2 Answers to questions
  1. Computer Memory Addressing and Conditional Branches

    • The instruction system defines up to 2^4=16 instructions.
    • The transfer instruction can jump up to 127 instructions.
    • MAR is at least 20 bits, and the instruction word length is 16 bits.
  2. Instruction execution and target address calculation

    • The PC value during execution is 1FD4H (CF=0, ZF=0, NF=1)
    • The PC value during execution is 200EH (CF=1, ZF=0, NF=0)
  3. Instructions to branch when an unsigned number is less than or equal to

    • C=1, Z=1, N=0
  4. Control signals and data paths

    • OP=0, Ms=mova, Md=left
  • Byte addressing or word addressing: refers to the addressing method of memory units in a computer. Here, the instruction length is 16 bits, and the address of the next instruction is (PC)+2, indicating that the computer memory is byte-addressed.

  • Relative Offset: Relative offset refers to the offset value used to calculate the target address in the transfer instruction, expressed in complement. Here, the offset is 8 bits, representing a range of -128 to 127, and is used to specify the relative position of the transfer.

  • Conditional Branch Instruction: A conditional branch instruction is an instruction that changes the order of program execution based on specific conditions. Here, whether to make a transfer is decided based on the status of CF, ZF, and NF in the flag register.

  • PC (Program Counter): Program counter, used to store the address of the instruction currently being executed. Here, PC+2 represents the address of the next instruction.

  • Offset range: refers to the effective range of relative offset, that is, the maximum and minimum number of items that can be jumped. Here, the relative offset is 8 bits, which means the range is -128 to 127, so up to 127 instructions can be jumped.

  • CF (Carry Flag), ZF (Zero Flag), NF (Negative Flag): represent the carry/borrow flag, zero flag and sign flag in the flag register respectively. Here, the conditional jump instruction checks these flags to determine whether to perform the jump.

  • Machine Code: Machine code is a binary form of instructions that a computer can directly execute. Here, the machine code of the conditional jump instruction generates different jump addresses based on different flag states.

  • Multiplexer: A multiplexer is used to select one of the outputs based on the input control signal. Here, it is used to determine the address of the next instruction based on the status of CF, ZF, and NF.

  • Adder: Adder is used to add two numbers. Here, it is used to add PC+2 and 2×OFFSET to calculate the jump target address.

  • Shift Register: A shift register is used to shift the bits in the register to the left or right. Here, it is used to shift one bit to the left to implement the operation of multiplying the relative offset by 2.

16. Computer instruction execution process control signal

16.1 Instruction execution process
  • Opcode bits and instruction definitions
  • Functions and operations corresponding to machine code
16.2 Answers to questions
  1. Instruction set and opcode bits

    • Define up to 2^4=16 instructions
    • The machine codes of inc, shl, and sub are 0240H, 0488H, and 06EAH respectively.
  2. Control signals and data paths

    • Shift Register and Adder Functions
  • Instruction Set: refers to the set of all instructions that a computer can execute. Here, it refers to the set of all instructions supported by the machine, the size of which is determined by the number of opcodes.

  • Opcode: A binary encoding used to identify and distinguish instructions. Here, it refers to the 7-bit opcode in the instruction format, which is used to represent different operations.

  • Machine Code: An instruction code in binary form that can be directly executed in a computer. Here, it refers to the machine code corresponding to different instructions, which consists of operation codes and other fields.

  • Register direct and register indirect addressing modes: Register direct addressing mode means that the operands in the instruction come directly from the contents of the register, while register indirect addressing mode means that the address of the operands in the instruction is stored in a register. Here, it refers to the two addressing modes supported by the machine, which are distinguished by the addressing mode bits.

  • Control Signal: A signal used to control the work of various components in the computer. Here, it refers to the control signals of various components involved in the process of executing instructions, such as input and output control signals Xin, Xout and memory control signal MEMop.

  • Clock Cycle: The basic timing unit in computers, which refers to a complete cycle of a clock pulse. Here, it refers to the time unit of instruction execution, and the clock cycles required for the execution phase are used to measure the speed of instruction execution.

  • Machine clock cycle: refers to the clock cycle used in the computer to synchronize the work of various components. Here, it refers to the machine clock cycle that controls the execution of instructions, which is the basic unit of timing.

  • PCout: Represents the output control signal of the program counter (PC). Here, it refers to the control signal output by the PC to the bus, indicating that the contents of the PC are sent to the bus.

  • Address Bus: A bus used to transmit address information. Here, it refers to the address information output by the PC to the bus.

  • Read/Write Operation: refers to the reading and writing operations of memory. Here, it refers to the MEMop signal used to control memory reading and writing.

  • Shift Register: A register used to shift the bits in the register left or right. Here, it refers to the shift register used to shift left when executing instructions, performing a left shift operation of one bit.

  • Adder: A circuit used to add two numbers. Here, it refers to the adder used to calculate the addition of addresses when executing instructions.

  • SRout: Represents the output control signal of the shift register (Shift Register). Here, it refers to the output signal of the shift register.

17. Computer instruction format and addressing methods

17.1 Command format
  • 16-bit fixed-length instruction word
  • Opcode and register number definitions
17.2 Answers to questions
  1. ALU width and addressing mode

    • ALU width is 16 bits
    • The addressable main memory space size is 2^20 bytes
    • MAR has 20 digits and MDR has 8 digits
  2. Operation definitions and machine code

    • When opl is 0010 and 0011, they represent signed integer subtraction and multiplication respectively.
    • The function of instruction 01B2H is R[3]←R[1]-R[2]
  3. Sign extension and unconditional branching

    • Sign-extend imm during address calculation
    • Unconditional transfer can be in J-type format
  • ALU (Arithmetic Logic Unit): Arithmetic Logic Unit is a component in a computer that performs arithmetic operations and logical operations. Its width is usually the same as the computer's word length.

  • System Bus: A set of electronic pathways that connect major components (such as CPU, memory, and I/O devices) in a computer, including address lines, data lines, and control lines.

  • Fixed-Length Instruction Word: The length of each instruction in the instruction word is fixed. Unlike variable-length instruction words, this design can simplify the parsing and execution of instructions.

  • Main Memory: Also called memory or RAM (Random Access Memory), it is used to store computer programs and data. It is a memory that the CPU can directly access.

  • Opcode: Binary code used to indicate specific operations performed in the computer. Each operation corresponds to an instruction.

  • General Register: A register used to store temporary data and intermediate results, which can be used flexibly by programmers.

  • Shift Register: A register used to shift the bits in the register left or right.

  • Machine Code: The encoding form of machine language is a binary instruction that can be directly executed by the computer.

  • Clock Cycle: The smallest operating time unit in a computer, consisting of one pulse of the computer clock.

  • PCout (Program Counter Output): Represents the output control signal of the program counter (PC), which refers to the control signal that the contents of the PC are output to the bus.

  • Address Bus: A bus that transmits address information and is used to indicate the location of memory or I/O devices.

  • Read/Write Operation: Memory read and write operations, used to read data from or write data to the memory.

  • Instruction Register: Used to store the instructions currently being executed. It is a register in the CPU.

  • Main memory address register (Memory Address Register, MAR): stores the main memory address that the CPU wants to access.

  • Main memory data register (Memory Data Register, MDR): stores data read or written from main memory.

  • R-type format, I-type format, J-type format: refers to different formats of instructions. The R-type format is mainly used for register-register operations, the I-type format is mainly used for operations with immediate numbers, and the J-type format is mainly used for jumps. Transfer command.

  • Machine clock cycle: The clock cycle used to synchronize the work of various components of the computer.

  • No overflow: In calculation, it refers to the situation where the calculation result does not exceed the range represented by the data type, and no data overflow occurs.

18. Computer instruction execution and data type conversion

18.1 Data type conversion
  • Convert int to float in source program
  • The execution process of instructions in machine-level code
18.2 Answers to questions
  1. ALU width and main memory address

    • ALU width is 16 bits
    • The main memory address is 32 bits
  2. Instruction execution process and data type conversion

    • When executing the instruction, the machine code and operation used to convert int to float
    • The content at address 0x1234 in main memory stores the floating point number 2.5
  • RISC (Reduced Instruction Set Computing): Reduced Instruction Set Computer. RISC architecture computers use a small set of simple and basic instructions. Each instruction completes a basic operation, making the execution of instructions faster.

  • CISC (Complex Instruction Set Computing): Complex instruction set computer. CISC architecture computers have a complex and diverse set of instructions, each of which can perform multiple low-level operations and provide higher-level instructions and functions.

  • Virtual Address: In the virtual storage system, the address generated by the program. Virtual addresses need to be converted into physical addresses through address mapping before they can be accessed on actual hardware.

  • Machine Instruction: Binary instructions that the computer can directly execute, including opcodes and operands.

  • Assembly Instruction: A mnemonic that corresponds one-to-one to machine instructions. It uses human-readable symbols to represent machine instructions, making it easier for programmers to write programs.

  • CMP instruction (Compare Instruction): Computer instruction used to perform comparison operations, usually implemented through subtraction, and set the corresponding flag bits, such as the carry/borrow flag (CF).

  • CF (Carry Flag): Carry/borrow flag is a flag register bit in the computer processor, used to indicate whether unsigned integer operations produce a carry.

  • SHL instruction (Shift Left): Left shift instruction, moves each bit of a binary number to the left, which is equivalent to multiplying by 2.

  • Two's Complement: A binary number encoding method used to represent signed integers. It is a form of representing negative numbers.

  • CF=1: In computer processors, CF=1 means that the carry flag is 1, usually due to a carry caused by some arithmetic operation, such as a carry in unsigned integer addition.

  • Address calculation: In computers, when instructions are executed or data is accessed, the process of calculating the final physical address usually includes steps such as base address plus offset.

  • Data overflow: When performing arithmetic operations, the result exceeds the range that the data type can represent, resulting in overflow. In integer arithmetic, either positive or negative overflow can occur.

  • Byte Addressing: Each byte in computer memory has a unique address, and the memory is accessed through these addresses. Byte addressing is a method of memory addressing.

  • Floating Point Number: A numerical system used to represent real numbers in which the decimal point position can float to accommodate values ​​of different orders of magnitude.

  • ALU (Arithmetic Logic Unit): Arithmetic logic unit, which is a component in the computer that performs arithmetic operations and logical operations.

19. Input and output system

19.1 Input and output interface
  • Port address and device connection
  • Input and output instructions and formats
19.2 Answers to questions
  1. Input and output interfaces and device connections

    • Port address range: 0x80~0xFF
    • Device 1 is connected to port 0xA0, device 2 is connected to port 0xB0
  2. Input and output instructions and data transmission

    • The machine code of the input instruction is 0xD0, and the machine code of the output instruction is 0xE0
    • After the input instruction is executed, the data is stored in register R2
  3. Device interrupts and program handling

    • The interrupt vector number of device 1 is 0x08, and the interrupt vector number of device 2 is 0x09.
    • After the interrupt service routine is executed, the value of PC is 0x2000
  • Conditional Branch Instruction: The instruction determines the execution flow of the program based on whether a certain condition is met, that is, whether to jump to another instruction. Make a transition when a given condition is true.

  • Relative Addressing Mode: A type of addressing mode. The address is relative to the address of the current instruction. Relative addresses are usually calculated by adding the current address to an offset.

  • Signed Integer (Signed Integer): Integer representation contains a positive and negative sign, that is, it can represent positive numbers, zero and negative numbers. In computers, signed integers are usually represented using two's complement representation.

  • Big Endian and Little Endian: These two refer to the way multi-byte data is stored in memory. Big endian stores the most significant byte at the lowest memory address, while little endian stores the least significant byte at the lowest memory address.

  • Overflow Flag (Overflow Flag, OF): A processor flag register bit used to indicate whether signed integer operations have overflowed. Overflow occurs when the result cannot fit into the limited number of bits in the destination register.

  • Trap Instruction: An instruction that causes an exception or interrupt and transfers control to the exception handler. In some cases, overflow trap instructions can be used to detect and handle overflows.

These terms cover concepts of computer architecture, assembly language, and low-level machine-level programming.

20. Memory hierarchy

20.1 Memory hierarchy and access speed
  • The relationship between cache and main memory
  • Optimization of memory hierarchy
  1. Memory hierarchy and access speed

    • L1 cache is accessed faster than main memory
    • Main memory access time is 200ns, L1 cache is 20ns
  2. Cache mapping and replacement algorithms

    • The cache size for a fully associative map is 16KB
    • How the LRU replacement algorithm works
  3. Virtual memory and paging

    • The page size is 4KB and the virtual address space is 2^32 bytes
    • Page scheduling uses FIFO algorithm
20.2 Answers to questions
  1. Virtual page number : In paging storage management, the virtual page number is used to identify different pages in virtual memory, usually the high-order part of the virtual address.

  2. Group-associative mapping : A cache mapping strategy that divides main memory addresses into groups. Each group contains multiple lines. The mapping of cache lines and main memory blocks is a many-to-one relationship.

  3. Cache group number : In group-associative mapping, the Cache group number is used to identify different groups and determine the location where cache lines are stored.

  4. Intra-block address : In the set-associative mapping method, the intra-block address represents the offset within the main memory block and is used to determine the specific location within the cache line.

  5. Tag information : In a set-associative mapping, tag information is part of the matching relationship between a cache line and a main memory block and is usually stored in the cache.

21. Interrupt and exception handling

21.1 The difference between interrupts and exceptions
  • Sources and handling procedures of interruptions
  • Exception triggering conditions and handling mechanisms
21.2 Answers to questions
  1. Interrupt triggers and interrupt vectors

    • Trigger conditions for external device interrupts
    • The device corresponding to the interrupt with interrupt vector number 0x10
  2. Exception handling and interrupt service routines

    • Arithmetic overflow exception handling flow
    • Return instruction after execution of interrupt service routine
  3. Interrupt controller and interrupt masking

    • Programmable interrupt controller supports up to 8 interrupt sources
    • How to set the interrupt mask register
  • RISC : Reduced Instruction Set Computing, the abbreviation of reduced instruction set computer. RISC is a computer architecture design paradigm characterized by a relatively small number of instructions in the instruction system and a relatively short execution time for each instruction. The goal of RISC design is to increase the execution speed of instructions by adding general-purpose registers and simplifying the instruction set. RISC processors typically use hardwired logic, reducing reliance on microprogrammed control.

22. System bus and I/O bus

22.1 Definition of system bus and I/O bus
  • System bus and I/O bus functions

  • Bus transmission methods and timing requirements

  • Instruction Pipelining : This is the way a computer executes instructions in which different instructions are divided into stages in the processor, with each stage executing a portion of the instructions. In this way, multiple instructions can be executed at different stages at the same time, thereby improving instruction execution efficiency. In a pipeline, different stages are designed to be independent of each other, allowing the processor to execute different stages of multiple instructions simultaneously. With reasonable design, the instruction pipeline can significantly improve the throughput of the processor.

  • Load/Store instruction : This is a design concept in computer instruction set architecture. In this architecture, only Load and Store instructions can directly access data in memory, while other operations need to be completed through operations between registers. This design is conducive to simplifying the execution process of instructions and provides convenience for the implementation of technologies such as pipelines.

Chapter 7-9 Central Processing Unit

Chapter 7-9 Central Processing Unit

1. Registers and Assembly Language

  • Register visible to assembly language programmers: Program Counter (PC)
  • Understand that assembly language programmers set the value of a PC by specifying an address

1. Programmer-Visible Registers

Explanation of professional terms:

  • Visible registers: refer to registers that programmers can directly access and use in assembly language programming. These registers are typically used to store critical program and control information, such as instruction addresses, data, program counters, etc. Programmers can manipulate these registers through appropriate instructions or assembly statements to control the execution flow and data operations of the program.

related information:

  • Program Counter (PC): The program counter is a visible register that stores the address of the currently executing instruction. Programmers can set the value of the program counter to implement jumps, loops and other control flow operations.

  • Memory Address Register (MAR): The memory address register is an invisible register that stores the address of the memory cell to be read or written. Programmers usually do not need to manipulate MAR directly.

  • Memory Data Register (MDR): The memory data register is an invisible register used to store data read from memory or data to be written to memory. Programmers usually do not need to directly manipulate the MDR.

  • Instruction Register (IR): The instruction register is an invisible register that stores the machine instructions currently being executed. The programmer does not need to access the IR directly as it is primarily used by the CPU internal control unit.

  • Status Register (SR): Also known as the flag register or condition code register, it contains a set of bits used to store status information generated after the processor executes instructions, such as the zero flag, carry flag, etc. Programmers can determine and influence program execution by checking or setting bits in the status register.

In the given options, Program Counter (PC) is a visible register as the programmer can manipulate it through assembly language while the other registers (MAR, MDR, IR) are mainly used for the internal workings of the CPU and are not useful to the programmer. is invisible.

2. Instruction format and program counter

  • Relationship between instruction format and word length: calculation of number of bits in program counter (PC) and instruction register (IR)
  • Instruction Cycle and Instruction Cycle: Understand the concepts of instruction cycle and execution cycle
  1. Program Counter (PC):

    • The program counter is a register that stores the memory address of the next instruction. When a computer executes a program, the PC indicates the location of the instructions to be executed. Its number of bits represents the size of the memory space it can address.
  2. Instruction Register (IR):

    • The instruction register is a register that stores the instruction currently being executed. During a computer's instruction cycle, instructions are read from memory into the instruction register, then decoded and executed. The number of bits represents the length of a complete instruction that can be stored.
  3. Word Length:

    • Word length refers to the number of bits of binary data that a computer can process at one time. In this context, a word length of 32 bits means that the computer is capable of processing 32 bits of binary data at a time, usually related to the width of the registers and data bus.
  4. Word Alignment:

    • Word boundary alignment refers to the way data is stored in memory at addresses that are multiples of its word length. In this problem, instructions are stored aligned on word boundaries, which means that the starting address of each instruction in memory is an integer multiple of a 32-bit word.
  5. Address Line:

    • Address lines are circuit lines used in computers to transmit memory address information. The number of address lines determines the amount of memory the computer can address, usually expressed as a power of 2.
  6. Memory Address:

    • The memory access address refers to the address of the memory unit that the computer accesses when executing instructions. The program counter (PC) outputs the memory access address of the next instruction.
  7. Memory Word:

    • A memory word is the smallest addressable storage unit in a computer and usually consists of several bits. In this problem, the memory word width is 32 bits, i.e. one word consists of 32 bits of binary data.

3. Von Neumann Computer

  • Instructions and data are stored in binary form in memory
  • The CPU distinguishes instructions and data according to different stages of the instruction cycle.
    Von Neumann Architecture:
  • A von Neumann computer is a computer architecture named after mathematician John von Neumann. Its characteristic is that the memory and the central processing unit are separated, and instructions and data are stored in the same memory in binary form. Key features of this architecture include the way instructions and data are stored, the sequential execution of instructions, and the use of a program counter to indicate the next instruction to be executed.

Instruction Cycle:

  • An instruction cycle is the stages a computer goes through to execute an instruction. A typical instruction cycle includes an instruction cycle (Fetch) and an execution cycle (Execute). During the fetch cycle, the computer fetches the instruction from memory, and during the execution cycle, the computer executes the instruction. Switching between these two stages is achieved through control circuits and clock signals.

Instruction operation code (Opcode):

  • The instruction opcode is the part of the instruction that indicates the type of operation. It tells the computer what to do. In a von Neumann computer, the decoding result of the instruction opcode is used to determine the specific operation of the instruction, such as addition, subtraction, multiplication, etc.

Different stages of the instruction cycle:

  • The different stages of the instruction cycle refer to the different operating stages that the computer goes through when executing an instruction, usually including the fetch cycle and the execution cycle. During the fetch cycle, the computer fetches the instruction from memory, and during the execution cycle, the computer executes the instruction. The division into these two stages helps organize and coordinate the computer's workflow.

Memory Unit:

  • A storage unit is the smallest unit in a computer used to store data and instructions. In a von Neumann computer, instructions and data are stored in binary form in memory cells. The address of a memory location is used to uniquely identify and access specific content in memory.

4. Instruction execution and interruption

  • The execution process of no-operation instructions
  • When in the "interrupt on" state, the current program may be interrupted by external interrupts
    Cache (cache):
  • Cache is a type of cache memory used to store frequently accessed data in the computer to improve data access speed. Cache technology is usually used to reduce the time it takes the CPU to access main memory and improve the efficiency of obtaining instructions and data.

Instruction prefetching technology:

  • Instruction prefetching technology is a method of pre-fetching instructions from memory before executing them. This helps reduce the waiting time for instruction acquisition and improves instruction execution efficiency. Instruction prefetching is often used in conjunction with caching.

Open interrupt state:

  • When the computer is in the "interrupt-on" state, it means that the system allows external interrupts to affect the execution of the program. External interrupts may be caused by devices or other programs and will interrupt the current execution flow at any time during program execution.

Instruction Cycle:

  • The instruction cycle is the stage that the computer goes through to execute an instruction, usually including the fetch cycle (Fetch) and the execution cycle (Execute). During the fetch cycle, the computer fetches the instruction from memory, and during the execution cycle, the computer executes the instruction.

Clock Cycle:

  • A clock cycle is the smallest unit of time in a computer and determines the basic operating speed of the computer. The time of each instruction cycle must be greater than or equal to one CPU clock cycle.

No-op instructions:

  • A no-operation instruction is an instruction that does not perform any meaningful operation and is usually used to occupy bits or create delays in the program. Even if it is a no-operation instruction, there may still be some operations during the execution cycle, such as automatically updating the program counter (PC), etc.

External interruption:

  • External interrupts are interrupts caused by computer external devices or other programs that can interrupt the execution of the current program at any time. In the interrupt-enabled state, the current program may be interrupted by external interrupts at the end of each instruction execution.

5. Single-cycle processor

  • Single-cycle processor characteristics: each instruction cycle is one clock cycle
  • Single bus structure and control signals: Understand the role of single bus structure and control signals
    Single-Cycle Processor:
  • A single-cycle processor is a computer processor architecture characterized by the fact that all instructions take equal execution time, one clock cycle. Each instruction is completed within one clock cycle. This structure simplifies the design of the control circuit.

Single bus structure data path:

  • A single-bus datapath is a datapath design in which the inputs and outputs of all registers are connected on a common bus. Only one operation is allowed in one clock cycle. This structure limits concurrent operations and may cause performance bottlenecks.

Processor clock frequency:

  • Processor clock frequency represents the number of clock cycles performed by the processor per second, usually measured in Hertz (Hz). The lower clock frequency may be due to the characteristics of single-cycle processors, where each instruction takes one clock cycle to execute and the clock cycle is long.

CPI(Cycles Per Instruction):

  • CPI is one of the measures of computer performance and represents the number of clock cycles required to execute each instruction. In a single-cycle processor, the CPI of each instruction is 1 because each instruction takes one clock cycle to execute.

Control Signals:

  • Control signals are signals generated by the control unit (CU) based on the operation code of the instruction and are used to control the operation of various elements in the data path. In a single-cycle processor, each instruction takes equal execution time, and control signals remain constant throughout instruction execution.

Multi-cycle processor:

  • A multi-cycle processor means that the execution time of each instruction is different and may require multiple clock cycles to complete. Compared with single-cycle processors, multi-cycle processors are more complex in design but can utilize hardware resources more flexibly.

6.Data path

  • Composition of data path: ALU, registers, etc.
  • The role of control signals: Understand the role of control signals in the data path
    Data Path:
  • The data path is the path that data flows through when executing instructions in a computer, including various logic elements and registers. Combinational logic elements in the data path are responsible for performing various operations, while sequential logic elements are used to store and maintain state.

ALU (Arithmetic Logic Unit):

  • The ALU is a combinational logic element in the data path, responsible for performing arithmetic and logical operations. It can perform operations such as addition, subtraction, logical AND or NOT.

register:

  • Registers are sequential logic elements in the data path that are used to store and maintain data. General-purpose registers are used to store temporary data, and status registers are used to save processor status information.

Abnormal event detection and response circuit:

  • Abnormal event detection and response circuits are usually included in the data path to detect and respond to abnormal events, such as division-by-zero errors, memory access errors, etc. These circuits are responsible for triggering the appropriate exception handlers.

control signal:

  • Control signals are generated by control components and used to control the operation of various elements in the data path. The generation of control signals is determined based on the operation code of the instruction and the needs of the execution phase.

Data flow path:

  • The data flow path in the data path is controlled by control signals. Changes in control signals determine the flow direction and path of data in the data path to ensure correct execution of instructions.

In this context, option C is incorrect because the data path often contains circuitry for abnormal event detection and response.

7. Example of instruction execution process

  • Various stages in the instruction execution process and the application of control signals
  • Information flow of data path: the role of MAR, MDR, IR, ALU, etc.
    Data Path:
  • The data path is the path that data flows through when executing instructions in a computer, including various logic elements and registers. Combinational logic elements in the data path are responsible for performing various operations, while sequential logic elements are used to store and maintain state.

Control Signals:

  • The control signal is a signal generated by the control unit (CU) according to the operation code of the instruction and is used to control the operation of each element in the data path. The generation of control signals is determined based on the function of the instruction and the needs of the execution phase.

Word Length:

  • Word length refers to the number of bits of binary data that a computer can process at one time. In this question, a word length of 16 bits means that the computer can process 16 bits of binary data at a time, usually related to the width of the registers and data bus.

16-bit Fixed-Length Instruction Word structure (16-bit Fixed-Length Instruction Word):

  • The fixed-length instruction word structure means that the length of each instruction is fixed and is 16 bits. In computers, the instruction word structure contains all the information needed to execute the instruction, including opcodes, register addresses, immediate values, etc.

Clock Cycle:

  • A clock cycle is the smallest unit of time in a computer and determines the basic operating speed of the computer. The time of each instruction cycle must be greater than or equal to one CPU clock cycle.

ALU (Arithmetic Logic Unit):

  • The ALU is a combinational logic element in the data path, responsible for performing arithmetic and logical operations. It can perform operations such as addition, subtraction, logical AND or NOT.

MAR(Memory Address Register):

  • MAR is the memory address register and is used to store the memory address to be accessed. In this question, the output of the MAR is always enabled, indicating that its contents are used as memory addresses.

MDR(Memory Data Register):

  • MDR is the memory data register used to store data read from or written to memory. In this problem, MDR plays the role of transmitting data in the data path.

IR(Instruction Register):

  • IR is the instruction register, used to store the instruction currently being executed. In this question, IR is used to store instructions read from memory.

PC(Program Counter):

  • PC is the program counter and is used to store the address of the next instruction to be executed. In this problem, the contents of PC change every clock cycle and represent the address of the next instruction.

8. Data path connection design

  • Understand the endpoints of the data path and design the connections of the data path
  • Understand the direction of data flow in the data path
  1. Programmer-visible registers: General-purpose registers (R0~R3) and program counter (PC) are registers visible to the programmer. The reason for using the temporary register T is to prevent the A and B ports of the ALU from obtaining the same data at the same time under the single bus structure and ensure the normal operation of the data path.

  2. Number of control signal bits: ALU operation control signal ALUop requires at least 3 bits; shift register operation control signal SRop requires at least 2 bits.

  3. SRout control: The signal SRout controls a three-state gate, which is used to control the connection and disconnection of the data path between the shift register and the bus.

  4. Endpoints connected to the output of the control component: ①, ②, ③, ⑤, ⑧ must be connected to the output of the control component.

  5. Clock cycle and control signals: The detailed clock cycle (C5 to C10) and corresponding control signals and necessary endpoint connections are given.

  6. The reason why the MUX input terminal is 2: Each instruction is 16 bits long and byte-addressed. Each instruction occupies 2 memory units, so the address of the next instruction is (PC)+2. Therefore, one input terminal of MUX is 2, which facilitates the operation of (PC)+2.

9. Microprogrammed Controllers and Hardwired Controllers

  • Features of microprogrammed controller: flexible, easy to modify and expand
  • Hardwired controller features: fast, difficult to modify and expand
  1. Logical expression: The logical expression of the symbol flag SF is SF = F15. The logical expression of the overflow flag OF during addition is (OF = A_{15} \cdot B_{15} \cdot \overline{F_{15}} + \overline{A_{15}} \cdot \overline{B_ {15}} \cdot F_{15}), the logical expression of the overflow flag OF during subtraction is (OF = A_{15} \cdot \overline{B_{15}} \cdot \overline{F_{15} } + \overline{A_{15}} \cdot B_{15} \cdot F_{15}).

  2. Temporary registers Y and Z: In a single bus structure, since only one data is valid on the bus at each moment, and the ALU has two input terminals and one output terminal, temporary registers Y and Z are set up for ALU operation. Cache input and output data.

  3. General register group GPRs: GPRs is a general register group, where rs and rd represent the numbers of the general registers to be read and written respectively. GPRs contain up to (2^4 = 16) general purpose registers. rs and rd come from the instruction register IR, rd represents the register number and is connected to the address decoder.

  4. Instruction fetching phase: The control signal sequence in the instruction fetching phase includes Pcout, MARin, Read, MDRout, and IRin, which are used to write the address of the instruction into MAR, read the main memory, write the read data into MDR, and write the contents of MDR. into the instruction register IR.

  5. Control unit CU: The control unit CU generates the control signals in the figure. The output signals of the instruction register IR and the flag register FR are connected to the input terminals of the control unit.

10. Microinstructions and operation control fields

  • Operation control field digit calculation
  • Principle and application of field direct encoding method
  1. Microprogrammed controller: Microprogrammed controller adopts the principle of stored program, and each machine instruction corresponds to a microprogram. It has the characteristics of good flexibility and easy modification and expansion of instruction functions, but the execution of each instruction requires access to the control memory, resulting in a relatively slow execution speed.

  2. Hard-wired controller: Hard-wired controllers are implemented using specialized logic circuits, and the execution speed of instructions mainly depends on the delay of the logic circuit. Compared with microprogrammed controllers, hard-wired controllers have faster execution speeds, but are more difficult to modify and expand instruction functions and have relatively poor flexibility.

11.Microprogrammed controller design

  • The relationship between the number of instructions and the number of microinstructions
  • Determination method and lower address field: the concept of clock cycle and machine frequency
  1. Microprogram control method: Microprogram control method is a method of controlling computer operations, in which each machine instruction corresponds to a microprogram. Microprograms are composed of a series of microcommands used to control various components of the computer. This method has the characteristics of high flexibility, easy modification and expansion.

  2. Field direct encoding method: Field direct encoding method is a microinstruction control method, in which the microinstruction field is divided into several small fields. Mutually exclusive microcommands are grouped in the same field, while compatible microcommands are grouped in different fields. There is also a status left for each field, indicating that this field does not issue any microcommands. This coding method helps organize and manage microcommands and improves the maintainability of microprograms.

12. Clock pulse signal

  • Clock pulse signal source and generation
  • The relationship between clock cycle and machine frequency
  • Determination of clock cycle benchmarks and instruction cycles in pipelined CPUs
  1. Microprogrammed Controller: A microprogrammed controller is a way of controlling computer operations in which each machine instruction corresponds to a microprogram. Microprograms are composed of a series of microinstructions that are used to control various components of the computer. This method has the characteristics of high flexibility, easy modification and expansion.

  2. Assertion method (lower address field method): The assertion method is one of the methods used in microprogrammed controllers to determine the address of the next microinstruction. In this method, the microinstruction memory is addressed using the lower address field to determine the address of the next microinstruction. In a given computer system, a sufficient number of bits are required to represent the address of the next microinstruction to ensure accurate addressing of the microinstruction memory.

13. Main memory and control memory

  • The location and role of main memory and control memory
  • The main memory is implemented by RAM and ROM, and the control memory is implemented by ROM.
  1. Main Memory (MM): Main memory is the place in a computer used to store instructions and data, often referred to as main memory. It is external to the CPU and communicates with the CPU through the address bus and data bus. Main memory is implemented by RAM (Random Access Memory) and ROM (Read Only Memory).

  2. Control memory (CS): Control memory is a memory inside the computer that is used to store all microinstructions that implement the instruction system. It is inside the CPU and is used to provide control signals to guide the operation of various parts of the computer. Usually, the control memory is implemented using ROM, which is a read-only memory.

14. Processor clock pulse signal

  • Understand the source of clock pulse signals and the shaping and frequency division process
  • The concepts of clock cycle, instruction cycle and machine frequency
  • Understand the concept that instruction execution does not always begin on every clock pulse
  1. Clock cycle: The clock cycle refers to the smallest unit of time that the processor works, usually consisting of a complete cycle of the clock pulse signal. The reciprocal of the clock cycle is the machine's main frequency, which is an important indicator of the processor's running speed. Clock cycles are used to synchronize and control the operation of various components within the processor.

  2. Machine main frequency: The machine main frequency refers to the frequency of the processor clock pulse signal, that is, the number of clock pulses sent per second. The reciprocal of the machine's main frequency is the clock cycle, which is used to represent the minimum time unit for the processor to work. The machine's main frequency is an important parameter for evaluating processor performance.

  3. Pipeline technology: Pipeline technology is a technology that divides the instruction execution process into multiple stages and executes different instructions simultaneously in different stages. This helps improve the efficiency of instruction execution, allowing the processor to process different stages of multiple instructions at the same time, thereby improving overall performance.

  4. Adjacent state unit: Adjacent state unit refers to the unit between two adjacent stages or states in the pipeline. The clock cycle is determined based on the maximum delay of the combinational logic circuit between adjacent state units, which helps ensure the normal operation of the pipeline.

15. Component requirements for instruction execution

  • The function of a certain instruction is R[r2] + R[r1] + M[R[r0]], and the two source operands use register and register indirect addressing.
  • General purpose registers (GPRs) and memory (Memory) are required in the fetching stage.
  • The Arithmetic Logic Unit (ALU) is used during the execution phase.
  • The instruction decoder (ID) is not used in the fetch and execution stages.
  1. General purpose register group (GPRs): A general purpose register group is a collection of registers used to store general data. The registers in it can be used by programmers to store any type of data. In this context, GPRs refer to general-purpose registers that store source operands and results.

  2. Arithmetic Logic Unit (ALU): The arithmetic logic unit is the part of the computer responsible for performing arithmetic and logical operations. In this context, the ALU is used to perform the operation of adding two source operands.

  3. Memory: Memory is where a computer stores data and instructions. In this context, memory is used to store the values ​​of the operands of register indirect addressing.

  4. Instruction decoder (ID): The instruction decoder is the component in the computer used to decode instructions. It translates the opcode field into the corresponding control signal. In this context, the instruction decoder is mainly used for the decoding of instructions, providing the control signals required to perform the operation.

16. Registers visible to assembly language programmers

  • The registers visible to the assembly programmer include the base address register (III) and the flag/status register (IV).
  1. Instruction Register: The instruction register is a register used to store the machine instructions currently being executed. From an assembly language programmer's perspective, it stores the currently executed instruction, allowing the programmer to read and understand the contents of the current instruction.

  2. Microinstruction register: The microinstruction register is a register used to store micro-operations and is usually used in microprogrammed controllers. To assembly language programmers, the microinstruction registers are transparent and invisible. It is a component used by hardware designers to control micro-operations within the processor.

  3. Base address register: The base address register is used to implement multi-programming or prepare floating programs. By setting the base address, programmers can change the starting address of the program so that the program can be loaded into different memory areas for execution.

  4. Flag/status register: The flag/status register is used to store the status and flag bits of program operation, such as zero flag, carry flag, etc. These flags can affect program flow control. From an assembly language programmer's perspective, these registers provide information about the state of the program.

  5. Transparent: In this context, "transparent" means invisible to the programmer, i.e. a register that cannot be directly accessed or manipulated by the programmer. The microinstruction register is transparent because it is the component used by the hardware designer for internal microoperation control.

17. Internal exception classification and description

  • Internal exceptions are divided into faults, traps, and aborts.
  • Narrative error: After exception handling, you cannot return to the instruction where the exception occurred to continue execution.
    Internal exception: Internal exception refers to the interrupt generated internally by the CPU, including fault, trap and termination. These exceptions are usually related to the currently executed instruction and can include illegal instructions, illegal addresses, verification errors, page failures, operation overflows, and division by zero.

Fault: A fault is an internal exception type, usually referring to some recoverable errors, which can continue to execute the program after being handled. However, for some faults, it may be necessary to terminate the execution of the program.

Trap: A trap is an internal exception type that is usually used to set breakpoints in programs or cause software interrupts. After handling the trap, program execution can continue.

Abort: Abort is an internal exception type that usually refers to some unrecoverable errors. Handling such exceptions may require terminating the execution of the entire process instead of returning to the instruction where the exception occurred.

CPU Internal Logic: CPU internal logic is the circuitry and logic units inside the processor that are used to perform various operations, including decoding, execution of instructions, and exception handling. In the case of internal exceptions, the CPU internal logic is responsible for detecting the exception and triggering the appropriate exception handler.

18. The difference between interrupts and exceptions

  • Interrupts are requested events from outside the processor.
  • Exceptions are special events that occur inside the processor during instruction execution.
  • Error description: Page missing during memory access is an interruption.
    In this context, the following are explanations of the technical terms involved:
  1. Interrupt: Interrupt refers to a processing mechanism when the processor receives an asynchronous event request from an external device or other processor component. Interrupts can interrupt normal program execution, transfer control to the corresponding interrupt service routine, and then return to the original program execution after handling the interrupt. Examples include I/O end interrupts, etc.

  2. Exception: Exception refers to some special situations that occur during program execution, usually due to program errors, illegal operations, or other problems. Exceptions are generated inside the processor and can trigger some special events or interrupts, such as division by zero.

  3. Page missing during memory access: Page missing means that during memory access, the required page is not in the main memory and needs to be loaded from external memory (usually the hard disk). Page missing during memory access is usually an abnormal situation because the operating system needs to intervene to handle the loading of the page.

  4. Integer division by zero exception: When a program attempts to perform integer division, if the divisor is zero, an integer division by zero exception is thrown. This is a classic exception because it is a mathematically undefined operation.

  5. DMA transfer end interrupt: DMA (direct memory access) is a technology that allows peripherals to directly access memory without going through the CPU. The end of DMA transfer is usually an interrupt, indicating that the DMA controller has completed the transmission of data and can notify the CPU or other components to continue execution.

  6. Storage Protection Fault Exception: A storage protection fault is an exception thrown when trying to access a protected storage area. This is usually an abnormal condition caused by access to an unauthorized area of ​​memory.

The above is a brief explanation of relevant terms. Please let me know if you have further questions or need further explanation.

19. Trap characteristics

  • A trap is a type of internal interrupt event preset by a trap instruction.
  • Breakpoint setting and single-step tracing can be used for program debugging.
  • After trap processing is completed, execution returns to the next instruction following the trap instruction.
    In this context, the following are explanations of the technical terms involved:
  1. Trap: Trap is an internal exception, usually triggered by a special instruction (trap instruction). It is an intentionally raised exception that can be used to implement some special operations, such as breakpoint setting and single-step tracing in program debugging. When executing a self-trap instruction, the CPU will automatically call the corresponding operating system kernel program for execution. After the self-trap processing is completed, the CPU returns to the next instruction execution of the trap instruction.

  2. Trap instructions: Trap instructions are special instructions used to trigger self-traps. It presets a type of internal exception event. When the program executes such an instruction, it will cause a self-trap and lead to the corresponding processing process.

  3. Program debugging: Program debugging refers to checking, testing and modifying the program to find and solve errors or problems in the program during the software development process. Self-trap can be used to set breakpoints in program debugging, causing the program to pause when it reaches a specified location, making it easier for programmers to debug and analyze.

The above is a brief explanation of relevant terms. Please let me know if you have further questions or need further explanation.

20. Exception and interrupt event handling

  • Exception events are detected during the execution of the current instruction, and interrupt requests are detected after the execution of the current instruction.
  • Page deletions require returning to the current instruction and re-executing it.
    In this context, the following are explanations of the technical terms involved:
  1. System call: A system call is a mechanism by which a user program requests the operating system to provide certain services or perform certain privileged operations. When a user program needs to perform operating system-level tasks, such as file operations, process management, etc., it can make requests to the operating system through system calls.

  2. Page missing: Page missing means that in the virtual memory system, the accessed page is not in the main memory and needs to be loaded from auxiliary storage (such as a hard disk) to the main memory. A page miss exception is triggered when a program accesses a page that has not yet been loaded into main memory.

  3. DMA transfer ends: DMA (direct memory access) is a data transfer method that allows peripherals to directly transfer data to main memory without CPU intervention. The DMA transfer end interrupt refers to the interrupt request issued by the DMA controller after completing the data transfer to notify the CPU that the transfer has been completed.

  4. Printer out of paper: Printer out of paper refers to the situation when the printer finds a lack of paper during the printing process. This may trigger an interrupt request, notifying the system or program that action needs to be taken to resolve the paper outage problem.

Among the above options, only "page missing" is detected during the execution of the current instruction, and the handler needs to return to the current instruction and re-execute it after execution. Other events, such as system calls, DMA transfer end and printer paper shortage, are usually detected after the current instruction is executed, and there is no need to return to the current instruction to re-execute after processing.

21. Instruction pipeline CPU cycle calculation

  • In the computer instruction pipeline, the CPU cycle should select the longest execution time in each functional segment to ensure that the function is completed and avoid pipeline stalls.
    In this context, the following are explanations of the technical terms involved:
  1. Instruction Pipelining: Instruction pipelining is a technology that increases the speed of instruction execution by dividing the processor's execution process into multiple stages. Each stage performs different tasks, and multiple instructions can be in different stages at the same time to achieve parallel execution of instructions.

  2. CPU Cycle: A CPU cycle is the time required to execute an instruction. In a pipeline, a CPU cycle is usually divided into multiple stages, with each stage executing part of the instruction execution process. The performance of the pipeline depends on the execution time of the longest stage.

  3. Functional Segments: The different stages of the instruction pipeline are called functional segments. Each functional segment performs a specific task during instruction execution. In this problem, there are four functional segments with execution times of 90ns, 80ns, 70ns, and 60ns.

  4. Clock cycle: The clock cycle is the basic unit of time for the CPU to execute instructions, and is usually driven by the computer's clock signal. In a pipeline, the duration of a clock cycle should be long enough to accommodate the execution time of the slowest functional segment in the pipeline.

According to the information provided in the question, the longest function segment execution time is 90ns, so the CPU cycle should be at least 90ns. So, the correct answer is A.

22. Instruction pipeline blocking factors

  • Data bypass technology can avoid instruction pipeline blocking and directly transfer execution results to prevent pipeline stalls and improve efficiency.
    In this context, the following are explanations of the technical terms involved:
  1. Instruction pipeline blocking: In the instruction pipeline, when the execution of an instruction is affected by the instructions before and after it and cannot be executed smoothly according to the originally planned clock cycle, instruction pipeline blocking occurs. This may be caused by data-related, control-related, resource conflicts, etc.

  2. Data Bypass: Data bypass technology is a method used to solve data-related problems. It does this by passing the execution results directly to the instructions that need the data without having to wait for them to get the data from the registers. This helps avoid pipeline blocking due to data dependencies.

  3. Data dependence: Data dependence means that the execution of an instruction depends on the results of the previous instruction or instructions. If subsequent instructions need to use the results of the previous instruction, and the previous instruction has not yet completed execution, data dependence will occur.

  4. Conditional transfer: A conditional transfer is an instruction that changes the execution order of a program based on specific conditions. In the pipeline, conditional transfer instructions may cause the pipeline to block due to unsatisfied conditions, and wait for the conditions to be met before continuing execution.

  5. Resource conflict: Resource conflict refers to the situation where multiple instructions compete to use the same hardware resources, which may cause pipeline blocking. This is a form of structural correlation.

According to the title, the introduction of data bypass technology aims to solve data-related problems so that the pipeline will not be blocked due to data-related problems. Therefore, the answer is A.

23. CPU pipeline throughput calculation

  • Based on the main frequency, the number of executed instructions and the total number of clock cycles, calculate the CPU throughput rate and understand the system performance.
    This is a question about computing pipeline throughput. When calculating pipeline throughput, key terms used include:
  1. Pipeline: A computer architecture design that divides the execution process of instructions into multiple stages so that each stage can execute different stages of different instructions at the same time, thereby improving the execution efficiency of instructions.

  2. Instruction pipeline stages (Pipeline Stages): Each stage in which instructions are executed in the pipeline. Each stage completes a part of the instruction execution. In this problem, the pipeline has 4 stages.

  3. Clock Cycle: A basic unit of time in a computer system, driven by the computer's clock. In this problem, each pipeline segment takes 1 clock cycle to execute.

  4. Clock Rate: The frequency of the CPU clock, usually in Hertz (Hz), indicating the number of clock cycles per second. In this problem, the CPU is clocked at 1.03GHz, which is 103 million clock cycles per second.

  5. Throughput: In computer architecture, throughput refers to the number of instructions completed per unit time. In this problem, by calculating the throughput of the pipeline, we get the number of instructions executed per second.

These professional terms are common in the field of computer architecture and computer composition principles, and are used to describe the design and performance of computer hardware.

24. Five-stage basic pipeline data adventure

  • Data hazards are related to data in the pipeline. Situations such as write-after-read related situations may cause the order of instruction execution to change and need to be dealt with.
    This is a question about data risks in a five-stage basic pipeline without forwarding mechanism. When explaining the problem, some professional terms need to be extracted and explained:
  1. No Forwarding Mechanism: It means that in the pipeline, there is no mechanism to directly forward the calculated results to subsequent instructions for use. This can lead to data risks.

  2. Five-stage Basic Pipeline: Usually refers to the five basic stages of the computer pipeline, including Instruction Fetch, Decode/Register Read, Execute, and Memory Access ( Memory), write back register (Write Back).

  3. Data Hazard: Also known as data dependence, it refers to the situation where during program execution, it is necessary to wait for the completion of the previous instruction before executing the next instruction. Data risks include read-after-write (RAW, Read After Write).

  4. Write After Read Dependency: A data hazard that occurs when an instruction writes to a register, and then another instruction reads data from the same register.

  5. Execution in the pipeline: refers to the execution and clock cycle of each instruction at each stage of the pipeline.

In this problem, instructions I2 and I3 are related to read-after-write, resulting in data risks. I2 writes the result to the register (R5) at clock 5, but I3 reads the register (R5) at clock 3. Since there is no forwarding mechanism, the result becomes that I3 reads R5 first, and I2 writes R5 later, resulting in data conflict. Therefore, the correct answer is B, which is I2 and I3.

25. Superscalar pipeline characteristics

  • The superscalar pipeline can issue multiple instructions simultaneously in one clock cycle, improving instruction execution parallelism through dynamic scheduling technology.
    This is a question about the properties of superscalar pipelines. When explaining the problem, some professional terms need to be extracted and explained:
  1. Superscalar Pipeline: A computer architecture design characterized by having more than one pipeline in the CPU and capable of completing more than one instruction per clock cycle. This allows multiple instructions to be issued simultaneously, increasing the parallelism of instruction execution.

  2. Pipeline Stage Processing Time: refers to the time required for each stage (functional segment) in the pipeline.

  3. Issue (Issue): refers to the process of sending an instruction from a certain stage of the pipeline to the next stage to start execution.

  4. Dynamic Scheduling: A technology that allows instructions to be dynamically scheduled at runtime based on available execution units and data dependencies to improve instruction execution parallelism.

In this question, the correct narratives are II and III. The superscalar pipeline can issue multiple instructions simultaneously in one clock cycle (II), and combined with dynamic scheduling technology can improve the parallelism of instruction execution (III). Additionally, statement I is wrong because superscalar pipelines do not affect the processing time of functional segments of the pipeline. Therefore, the correct answer is C, which is only II and III.

26. Instruction pipeline data path

  • The data path includes ALU, register group, etc., which is composed of combinational logic circuits and sequential logic circuits, and the control component generates control signals.
  1. Instruction Pipeline: A computer architecture design that divides the instruction execution process into multiple stages to process multiple instructions simultaneously.

  2. Data Path: The path through which data is transmitted between functional components, including components flowing through it, such as program counters, ALUs, general registers, status registers, exception and interrupt handling logic, etc.

  3. Control Unit: A part of the instruction pipeline that is responsible for generating control signals to effectively control various components on the data path.

  4. Arithmetic Logic Unit (ALU, Arithmetic Logic Unit): A component responsible for performing arithmetic and logical operations.

  5. Combinational logic circuits and sequential logic circuits: refer to two basic types of logic circuits used in digital circuits respectively. The output of a combinational logic circuit only depends on the current input, while the output of a sequential logic circuit also depends on past inputs.

27. Instruction pipeline and clock cycle issues

  1. Instruction Pipeline: A computer architecture design that achieves parallel processing of multiple instructions by dividing instruction execution into multiple stages.

  2. Pipeline Register Delay: In the instruction pipeline, the delay introduced by the registers between adjacent pipeline stages is used to synchronize and isolate instructions at different stages.

  3. Functional components A~E: refer to the five sub-functional components required to execute the most complex instructions in the computer. Each component performs different tasks.

  4. CPU clock cycle: A basic unit of time in a computer system, driven by the computer's clock. Each stage of the pipeline usually corresponds to one clock cycle.

In this problem, the time of each pipeline segment is determined by the maximum component time, which is 80ps. In addition, there is a register delay between each pipeline segment, which is 20ps. Therefore, the CPU clock cycle is at least 80ps (maximum component time) + 20ps (register delay) = 100ps. So, the correct answer is D, which is 100ps.

28. The problem of data risks in the pipeline

  1. Data hazard (Data Hazard): refers to the situation during program execution where it is necessary to wait for the completion of the previous instruction before executing the next instruction. Data risks include read-after-write (RAW, Read After Write).

  2. Instruction fetch, decode/fetch, execution, memory access, write back: each stage in the five-stage pipeline represents the different stages of the instruction execution process.

  3. Pipeline execution diagram: Depicts the process of instruction execution in the pipeline, including the time points of each stage.

In this problem, to determine whether there is a data hazard, you need to check whether there is a read-after-write correlation between each pair of instructions. According to the pipeline execution diagram, it can be seen:

  • There is a read-after-write correlation between I1 and I3 (writing of s2 and reading of s2).
  • There is also a read-after-write correlation between I2 and I3 (writing of s3 and reading of s2).
  • There is a read-after-write correlation between I3 and I4 (writing of s2 and reading of s2).

The only ones that do not have data hazards are I2 and I4, because there is no reading or writing of the same register between them. Therefore, the correct answer is C, which is I2 and I4.

29. Issues with different processor types and CPI

  1. CPI (Clocks Per Instruction): Indicates the number of clock cycles required to execute instructions. For a program or a machine, its CPI refers to the average number of clock cycles required to execute all instructions in the program or machine's instruction set.

  2. Single-Cycle CPU: A type of processor in which each instruction is executed in one clock cycle. For single-cycle CPUs, the CPI is 1.

  3. Multi-Cycle CPU: A type of processor in which the execution process of the CPU is divided into several stages, and each stage is completed in one clock cycle. The number of clock cycles used by each instruction can be different, so the CPI is usually greater than 1.

  4. Basic Pipeline CPU: A type of processor in which one stage in the pipeline completes the execution of one instruction per clock cycle. For a basic pipelined CPU under ideal conditions, the CPI is 1.

  5. Superscalar Pipeline CPU: A type of processor that executes multiple independent instructions concurrently per clock cycle. For superscalar pipelined CPUs, CPI is usually less than 1.

30. *SHR command

1) SHR instruction: SHR is an arithmetic right shift instruction, which means performing a right shift operation on the binary number in the register. In this problem, after executing the "SHR R1" instruction, the contents in register R1 are shifted right by 1 bit.

2) Clock cycle: In computer architecture, clock cycle refers to a complete cycle of the clock signal in the computer system. Each clock cycle usually corresponds to a basic operation, such as instruction fetch, execution, writeback, etc. In this problem, the clock cycle is the basic unit of time in the pipeline.

3) Data dependence: Data dependence refers to the situation where there is a dependency on shared data between instructions during program execution, resulting in the need to wait for the previous instruction to complete the operation of the data before the next instruction can be executed.

4) Pipeline: Pipeline is a way of executing computer instructions, which divides the execution process into multiple stages and allows multiple instructions to be executed in different stages at the same time. This can improve the efficiency of instruction execution.

5) Blocking: In the pipeline, blocking refers to a state where a certain stage temporarily stops execution due to waiting for the execution results of the previous stage.

6) Fetching instructions, decoding/reading registers, executing/calculating effective addresses, accessing memory, and writing results back to registers: This is a typical five-segment pipeline division, used to represent different stages in the instruction execution process, including fetching instructions. , decode/read registers, execute/compute effective addresses, access memory and write results back to registers.

7) Forwarding technology: Forwarding technology is a method of processing data in the pipeline. By forwarding the calculated results directly to the instructions that need to use the results, it avoids the time of waiting for the register to be written back and improves the efficiency of the pipeline.

8) Unsigned integer: In computers, unsigned integer is an integer representation method without sign bit, which represents non-negative integers. In this question, the difference between signed integers and unsigned integers is involved.

31. Memory addressing unit

  1. Memory addressing unit: The memory addressing unit refers to the smallest unit when the computer accesses the memory. In this problem, the memory addressing unit of computer M is bytes.

  2. sll instruction: sll is an instruction in the instruction set architecture, used to implement logical left shift operations. In this question, the sll instruction is used to left shift the value in the register.

  3. bne instruction: bne is a branch instruction in the instruction set, which means "branch not equal" and is used for conditional jumps. In this question, bne instruction is used for loop control.

  4. OFFSET field: The OFFSET field is the part of the instruction used to represent the offset of the jump target address. In this problem, analyzing the OFFSET field of the bne instruction can infer how the jump target address is calculated.

  5. Pipeline blocking: Pipeline blocking means that during the execution of the pipeline, a certain stage cannot continue to execute due to data related or other reasons, thus affecting the execution of the entire pipeline. In this problem, pipeline blocking caused by data correlation is involved.

  6. Control risk: Control risk means that during the execution of the pipeline, due to the unknown conditional judgment result of the branch instruction, the control flow of the pipeline changes, thus affecting the execution of subsequent instructions. In this question, a control hazard involving the bne instruction is involved.

  7. Sequential emission and sequential completion: Sequential emission and sequential completion are a basic execution method of the pipeline, which means that instructions enter the pipeline in sequence according to the program sequence, and are executed in sequence according to the program sequence. In this question, it involves the execution method of the five-level instruction pipeline.

32. Page virtual storage management

  1. Page-based virtual storage management: Page-based virtual storage management is a virtual memory management method that divides main memory and auxiliary memory into fixed-sized pages or boxes, and divides programs and data into pages or boxes of the same size to achieve the goal of Need to be transferred in and out, which improves memory utilization.

  2. Cache: Cache is a type of cache memory used to store recently accessed data and instructions to increase access speed. In this question, the instruction Cache and the data Cache are separated, and the concepts of Cache capacity and hit rate are involved.

  3. Cache missing: Cache missing means that the required data or instructions are not found when accessing the Cache, and the data or instructions need to be loaded from the main memory to the Cache. In this problem, the instruction cache miss occurs once when the program starts executing.

  4. Hit rate: The hit rate of a Cache refers to the probability of successfully finding the required data or instructions when accessing the Cache. In this problem, the hit rate of the instruction cache is calculated.

  5. Overflow exception: Overflow exception means that when performing mathematical operations, the result exceeds the range that the data type can represent, resulting in overflow. In this question, instructions that may cause an overflow exception are involved.

  6. Page missing exception: Page missing exception refers to the situation where the accessed page is not in the main memory and the page needs to be loaded from the auxiliary storage to the main memory. In this problem, instruction 3 may generate a page fault exception because array A is on a page on the disk and has not been loaded into main memory initially.

  7. TLB (Translation Lookaside Buffer): TLB is a high-speed cache that is used to store the mapping relationship between virtual addresses and physical addresses and accelerate the conversion process of virtual addresses. In this question, the calculation of the number of TLB accesses is involved.

33. Related concepts of parallel processing technology:

  1. MIMD structure: MIMD (Multiple Instruction stream, Multiple Data stream) structure refers to a parallel processing structure of multiple instruction streams and multiple data streams. Multi-core processors belong to the MIMD structure because each core can execute a different instruction stream.

  2. SIMD structure: SIMD (Single Instruction stream, Multiple Data stream) structure refers to a parallel processing structure of single instruction stream and multiple data streams. Vector processor belongs to SIMD structure because it can perform the same operation on multiple data at the same time.

  3. Hardware multi-threading technology: Hardware multi-threading technology allows multiple threads to be executed simultaneously in a core. Contrary to option C, hardware multi-threading technology can be used not only on multi-core processors, but also on single-core processors, since its goal is to execute multiple threads concurrently within a core to fully utilize resources.

  4. SMP Structure: SMP (Symmetric Multiprocessing) is a multi-processor architecture in which all processors share a single physical address space. This structure allows any processor to access any location in memory. Therefore, option D is correct.

Guess you like

Origin blog.csdn.net/qq_42531954/article/details/135438206