tailieunhanh - Algorithms and Data Structures in C part 3

The sign, an - 1, of A is simply extended into the higher order bits of B. This is known as signextension. Sign extension is illustrated from 8-bit 2’s complement to 32-bit 2’s complement in | satisfies this case. b an - i 1 For this case By noting that The assignment of bk with satisfies the condition. The two cases can be combined into one assignment with bk as The sign an- b of A is simply extended into the higher order bits of B. This is known as signextension. Sign extension is illustrated from 8-bit 2 s complement to 32-bit 2 s complement in Table . Table 2 s Complement Sign Extension 8- Bit 32-Bit 0xff 0xffffffff 0x0f 0x0000000f 0x01 0x00000001 0x80 0xffffff80 0xb0 0xffffffb0 C Program Example This section demonstrates the handling of 16-bit and 32-bit data by two different processors. A simple C source program is shown in Code List . The assembly code generated for the C program is demonstrated for the Intel 80286 and the Motorola 68030 in Code List . A line-byline description follows Line 1 The 68030 executes a movew instruction moving the constant 1 to the address where the variable i is stored. The movew move word instruction indicates the operation is 16 bits. The 80286 executes a mov instruction. The mov instruction is used for 16-bit operations. Line 2 Same as Line 1 with different constants being moved. Line 3 The 68030 moves j into register d0 with the movew instruction. The addw instruction performs a word 16-bit addition storing the result at the address of the variable i. The 80286 executes an add instruction storing the result at the address of the variable i. The instruction does not involve the variable j. The compiler uses the immediate data 2 since the assignment of j to 2 was made on the previous instruction. This is a good example of optimization performed by a compiler. An unoptimizing compiler would execute mov ax WORD PTR bp-4 add WORD PTR bp-2 ax similar to the 68030 example. Line 4 The 68030 executes a moveq quick move of the immediate data 3 to register d0. A long move movel is performed moving the value to the address of the variable k. The long move performs a 32-bit move. The 80286 executes two .

TÀI LIỆU LIÊN QUAN
10    158    1
6    184    1
7    162    1
5    157    1
6    160    1
6    152    1
6    150    1
6    206    1
7    154    1
TÀI LIỆU MỚI ĐĂNG
309    139    0    23-12-2024
3    121    0    23-12-2024
14    147    0    23-12-2024
54    162    0    23-12-2024
19    141    0    23-12-2024
40    112    0    23-12-2024