TAILIEUCHUNG - 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 .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.