Computer system concept

Data operations
-integer arithmetic operations, floating-point arithmetic operations
-bitwise, logical, shift, bit expansion, and bit truncation
Operations
involved in the instruction set -fixed-point operations involved
Arithmetic operations
1. Signed integer operations: Take negative / sign extension / add / subtract / multiply / divide / arithmetic shift
2. Unsigned integer operation: 0 extension / addition / subtraction / multiplication / division
Logic operation
1. Logic operation: AND / OR / NO ...
2. Shift operation: logical shift left / logic shift right
involves operations involving floating point numbers: addition, subtraction, multiplication and division, without shift operations and expansion operations.
ALU design of basic arithmetic components
Arithmetic operations:
addition, subtraction, multiplication and division of unsigned numbers, signed integers, and floating point numbers.
Bitwise operation
1. Use
to implement mask operation or corresponding other processing on the bit string
(mainly used for processing multimedia data or status / control information)
2. Operation
"|", "&", "~", "^ "
Logical Operation
Purpose: for the operation of relational expressions
Operation:
1. || means OR operation
2. && means AND operation
3. | means NOT operation
and bitwise operation difference
1. The sign means different.
2. The calculation process is different.
3. Different types of results.
Shift operation:
extract some information
Increase or decrease the value by 2, 4, 8 ... times.
Operation:
1. Left shift: x << k; right shift x >> k
2. Does not distinguish between logical shift and arithmetic shift, determined by the type of x.
3. Unsigned number: logical shift left, logical shift right
High (low) shift out, low (high) bit is filled with 0, may overflow
If high shift is 1, then overflow occurs when left shift
Signed integer: arithmetic left shift , Arithmetic shift
right, shift left, high shift out, low bit complement 0, may overflow.
Overrun judgment, if the shifted out bit is not equal to the new sign bit, then overflow.
Right shift: low shift out, high-bit complement, data loss of significant bits may occur
Bit expansion and bit truncation operations
Uses: Type conversion may require data expansion and truncation
operations There is no special operation operator, according to the length of the data before and after type conversion Bit extension is still truncated.
Extension: Short turn long
unsigned: 0 extension, leading zero
signed integers: sign extension, breaks up the front
cut: Long Short turn
forcibly discarded high, overflow may occur
summarized: C language basic data types and the basic Operation type
Basic data types:
unsigned, signed, floating point, bit string, character (string)
Basic operation types:
arithmetic, bitwise, logic, shift, expand and truncate, match.
Computer implements instructions in high-level languages:
compiles (converts) various expressions into instruction sequences.
Computers directly execute instructions to complete operations.
Complementary addition and subtraction formulas
[A + B]Fill = [A] Complement + [B] Complement (mod2 n- )
[AB] Complement = [A] Complement + [- B] Complement (mod2 n- )
using the flags with the adder, the adder-subtractor may be configured, the following operations :
Unsigned integer addition, unsigned integer subtraction
Signed integer addition, signed integer subtraction
is based on the basic length of the integer addition / subtraction unit, plus registers, shifters, and control logic, ALU, multiplication / division Operation and floating point operation circuit.
Insert picture description here
When Sub is 1, do subtraction. When Sub is 0, add.
ZF: Zero flag
SF: Symbol flag
OF: Overflow flag
CF = Co⊕Sub: Enter / misalignment flag
Arithmetic logic unit ALU:
Perform basic logic operations and basic arithmetic operations
1. Unsigned integer addition and subtraction
2. Signed integer addition and subtraction
3. Logic operation such as NOR, XOR, etc.
Integer addition and subtraction unit
output in core circuit In addition to sum / difference, there is also flag information.
There is an operation control terminal (ALUop), used to determine the processing functions performed by the ALU. The number k of ALUop determines the type of operation. For example, when the number of bits k = 3, the ALU only has at most 3 3 = 8 operations.
Insert picture description here
Insert picture description here
Pointers, addresses, etc. are usually described as unsigned integers. Therefore, when performing pointer or address operations, addition and subtraction of unsigned integers are required.
Unsigned integer and signed integer addition and subtraction circuits are exactly the same. This operation is called an integer addition and subtraction unit and is based on a signed adder.
The most basic adder, only n bits, is a modulo 2 n computing system.
The n-bit adder cannot be used to add two n-bit signed numbers (complements) and cannot determine whether it overflows.
It is often necessary to compare the size in the program, and the flag information is obtained by subtraction (in the adder) to determine the
Insert picture description here
overflow flag OF
OF = V N ⊕C n-1
symbol flag SF
SF = F n-1
zero flag ZF = 1 When F = 0;
carry / misalignment flag CF:
CF = Count⊕Cin
All arithmetic operations are implemented based on the adder. The
adder does not know whether the operation is signed or unsigned.
The adder does not judge right or wrong, takes the lower n bits as the result, and generates flag information.

Published 74 original articles · won 15 · views 4094

Guess you like

Origin blog.csdn.net/V2636011127/article/details/105295689