Bài giảng Kiến trúc máy tính: Chương II (tt)
Số trang: 36
Loại file: pptx
Dung lượng: 1.77 MB
Lượt xem: 31
Lượt tải: 0
Xem trước 4 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Bài giảng Kiến trúc máy tính - Chương II (tt): Kiến trúc tập lệnh 2, trình bày các nội dung: biên dịch mã máy, các định dạng lệnh, các hằng số lớn, các thủ tục gọi, tập các thanh ghi, bộ nhớ ngăn xếp, các ISA khác.
Nội dung trích xuất từ tài liệu:
Bài giảng Kiến trúc máy tính: Chương II (tt) Kiến trúc tập lệnh 2 Nội dung ¡ Biên dịch mã máy – Các định dạng lệnh – Các hằng số lớn ¡ Các thủ tục gọi – Tập các thanh ghi – Bộ nhớ ngăn xếp ¡ Các ISA khác Một số vấn đề không có trong bài giảng Đọc từ sách – Sign extension for two’s complement numbers (2.4) – Logical operations (2.6) – Assembler, linker, and loader (2.12) You will need 2.4 and 2.6 for this lecture. (2.12 will be on the exam.) The book has excellent descriptions of these topics. Please read the book before watching this lecture. Biên dịch thành mã máy Mã hóa và các định dạng Định dạng lệnh (mã máy) Ngôn ngữ máy – Máy tính không hiểu được chuỗi ký tự sau “add R8, R17, R18” – Các lệnh phải được chuyển đổi thành ngôn ngữ máy(1s and 0s) Ví dụ: add R8, R17, R18 → 00000010 00110010 01000000 00100000 Các trường lệnh MIPS • opcode mã lệnh xác định phép toán (e.g., “add” “lw”) • rs chỉ số thanh ghi chứa toán hạng nguồn 1 trong tệp thanh ghi • rt chỉ số thanh ghi chưa toán hạng nguồn 2 trong tệp thanh ghi • rd chỉ số thanh ghi lưu kết quả • shamt Số lượng dịch • funct mã chức năng thêm cho phần mã lệnh (add = 32, sub =34) Hằng số (tức thời – trực tiếp) How many bits Các hằng số nhỏ (tức thì) được sử dụng ở hầu hết các đoạn needed to choose mã (~50%) ví dụ : If (a==b) c=1; else c=2; from all those • How can we support this in the processor? registers? – Put the “typical constants” in memory and load them (slow) – Create hard‐wired registers (like R0) for them (how many?) • MIPS does something in between: – Some instructions can have constants inside the instruction Store the constant – The control logic then sends the constants to the ALU data in the – addi R29, R29, 4 ← value 4 is inside the instruction instruction, not the • But there’s a problem: register file. – Instructions have only 32 bits. Need some for opcode and registers. How do we tradeoff space for constants and instructions? Định dạng lệnh MIPS Câu hỏi: Lệnh cộng tức thời (addi) cần bao nhiêu bit? • MIPS có 3 dạng chỉ thị : Trả lời: I-format: – R: operation 3 registers no immediate 5+5+6 bits – I: operation 2 registers short immediate = 16 bits. 2’s complement – J: jump 0 registers long immediate -32,768 to +32767 Tải các giá trị tức thì (hằng số) Control tells the ALU to take one operand from the Register File and the other from the Instruction. Các hằng số lớn và lệnh rẽ nhánh Tải các giá trị lớn • Trường lệnh trực tiếp giới hạn trong 16 bits (-32,768 to Question: Is the +32,767) immediate sign‐ – Làm thế nào để tải được các giá trị lớn? extended for ori? • Sử dụng 2 lệnh để tải Answer: – Load Upper Immediate (lui): Loads upper 16 bits No. If it was we would – Or Immediate (ori): Loads lower 16bits end up with all 1s in • Example: 10101010 10101010 11110000 11110000 the top bits. (See the MIPS reference data in the book.) Đánh địa chỉ có lệnh rẽ nhánh và lệnh nhảy Question: Các lệnh rẽ nhánh How far can you – bne/beq I-format 16 bit immediate jump with –j J-format 26 bit immediate bne/beq? Answer: Địa chỉ là 32 bits! How do we handle this? 32,767 to – Treat bne/beq as relative offsets (add to current PC) +32,768 – Treat j as an absolute value (replace 26 bits of the PC) instructions from the current instruction Nhảy đến địa chỉ lệnh: loops Why do relative branches work? Question: What is “Int” and “FP”? Answer: Integer and Floating Point programs. Most branches don’t go very far! What kind of branches are common? Summary: machine code and immediate Instructions have different encodings to store different types of data (3 register vs. immediate) MIPS has 3 types, for different uses Encodings limit how much data we can have These are tradeoffs in design: – Optimize for the common case (short immediate) – Support the general case (long immediate) Thủ tục gọi hàm Các thủ tục gọi hàm Procedures (functions/subroutines) are needed for structured programming This procedure is likely not in your main( ) { for ( j=0; jMore specifically: Caller: main() Callee: update() main( ) { for ( j=0; jCaller context Example procedure: f(g,h,i,j)=(g+h) – (i+j) Problems: • The callee does not know add R1, R4, R5 ; g=R4, h=R5 which registers the caller is add R2, R6, R7 ; i=R6, j=R7 using! (It could have multiple sub R3, R1, R2 different callers) • The caller does not know If the caller (e.g., main()) uses R1, R2 or which re ...
Nội dung trích xuất từ tài liệu:
Bài giảng Kiến trúc máy tính: Chương II (tt) Kiến trúc tập lệnh 2 Nội dung ¡ Biên dịch mã máy – Các định dạng lệnh – Các hằng số lớn ¡ Các thủ tục gọi – Tập các thanh ghi – Bộ nhớ ngăn xếp ¡ Các ISA khác Một số vấn đề không có trong bài giảng Đọc từ sách – Sign extension for two’s complement numbers (2.4) – Logical operations (2.6) – Assembler, linker, and loader (2.12) You will need 2.4 and 2.6 for this lecture. (2.12 will be on the exam.) The book has excellent descriptions of these topics. Please read the book before watching this lecture. Biên dịch thành mã máy Mã hóa và các định dạng Định dạng lệnh (mã máy) Ngôn ngữ máy – Máy tính không hiểu được chuỗi ký tự sau “add R8, R17, R18” – Các lệnh phải được chuyển đổi thành ngôn ngữ máy(1s and 0s) Ví dụ: add R8, R17, R18 → 00000010 00110010 01000000 00100000 Các trường lệnh MIPS • opcode mã lệnh xác định phép toán (e.g., “add” “lw”) • rs chỉ số thanh ghi chứa toán hạng nguồn 1 trong tệp thanh ghi • rt chỉ số thanh ghi chưa toán hạng nguồn 2 trong tệp thanh ghi • rd chỉ số thanh ghi lưu kết quả • shamt Số lượng dịch • funct mã chức năng thêm cho phần mã lệnh (add = 32, sub =34) Hằng số (tức thời – trực tiếp) How many bits Các hằng số nhỏ (tức thì) được sử dụng ở hầu hết các đoạn needed to choose mã (~50%) ví dụ : If (a==b) c=1; else c=2; from all those • How can we support this in the processor? registers? – Put the “typical constants” in memory and load them (slow) – Create hard‐wired registers (like R0) for them (how many?) • MIPS does something in between: – Some instructions can have constants inside the instruction Store the constant – The control logic then sends the constants to the ALU data in the – addi R29, R29, 4 ← value 4 is inside the instruction instruction, not the • But there’s a problem: register file. – Instructions have only 32 bits. Need some for opcode and registers. How do we tradeoff space for constants and instructions? Định dạng lệnh MIPS Câu hỏi: Lệnh cộng tức thời (addi) cần bao nhiêu bit? • MIPS có 3 dạng chỉ thị : Trả lời: I-format: – R: operation 3 registers no immediate 5+5+6 bits – I: operation 2 registers short immediate = 16 bits. 2’s complement – J: jump 0 registers long immediate -32,768 to +32767 Tải các giá trị tức thì (hằng số) Control tells the ALU to take one operand from the Register File and the other from the Instruction. Các hằng số lớn và lệnh rẽ nhánh Tải các giá trị lớn • Trường lệnh trực tiếp giới hạn trong 16 bits (-32,768 to Question: Is the +32,767) immediate sign‐ – Làm thế nào để tải được các giá trị lớn? extended for ori? • Sử dụng 2 lệnh để tải Answer: – Load Upper Immediate (lui): Loads upper 16 bits No. If it was we would – Or Immediate (ori): Loads lower 16bits end up with all 1s in • Example: 10101010 10101010 11110000 11110000 the top bits. (See the MIPS reference data in the book.) Đánh địa chỉ có lệnh rẽ nhánh và lệnh nhảy Question: Các lệnh rẽ nhánh How far can you – bne/beq I-format 16 bit immediate jump with –j J-format 26 bit immediate bne/beq? Answer: Địa chỉ là 32 bits! How do we handle this? 32,767 to – Treat bne/beq as relative offsets (add to current PC) +32,768 – Treat j as an absolute value (replace 26 bits of the PC) instructions from the current instruction Nhảy đến địa chỉ lệnh: loops Why do relative branches work? Question: What is “Int” and “FP”? Answer: Integer and Floating Point programs. Most branches don’t go very far! What kind of branches are common? Summary: machine code and immediate Instructions have different encodings to store different types of data (3 register vs. immediate) MIPS has 3 types, for different uses Encodings limit how much data we can have These are tradeoffs in design: – Optimize for the common case (short immediate) – Support the general case (long immediate) Thủ tục gọi hàm Các thủ tục gọi hàm Procedures (functions/subroutines) are needed for structured programming This procedure is likely not in your main( ) { for ( j=0; jMore specifically: Caller: main() Callee: update() main( ) { for ( j=0; jCaller context Example procedure: f(g,h,i,j)=(g+h) – (i+j) Problems: • The callee does not know add R1, R4, R5 ; g=R4, h=R5 which registers the caller is add R2, R6, R7 ; i=R6, j=R7 using! (It could have multiple sub R3, R1, R2 different callers) • The caller does not know If the caller (e.g., main()) uses R1, R2 or which re ...
Tìm kiếm theo từ khóa liên quan:
Bài giảng Kiến trúc máy tính Chương II Kiến trúc máy tính Kiến trúc tập lệnh Biên dịch mã máy Các định dạng lệnh Các hằng số lớnGợi ý tài liệu liên quan:
-
67 trang 300 1 0
-
Giáo trình Kiến trúc máy tính và quản lý hệ thống máy tính: Phần 1 - Trường ĐH Thái Bình
119 trang 235 0 0 -
105 trang 204 0 0
-
84 trang 201 2 0
-
Giải thuật và cấu trúc dữ liệu
305 trang 161 0 0 -
142 trang 146 0 0
-
Thuyết trình môn kiến trúc máy tính: CPU
20 trang 146 0 0 -
Bài giảng Lắp ráp cài đặt máy tính 1: Bài 2 - Kiến trúc máy tính
56 trang 104 0 0 -
4 trang 97 0 0
-
Giáo trình kiến trúc máy tính - ĐH Cần Thơ
95 trang 87 1 0