1 / 37

บทที่ 2

บทที่ 2. Machine Structure, Machine Language, and Assembly Language. จุดมุ่งหมาย. 2 . โครงสร้างเครื่อง ภาษาเครื่อง และภาษาแอสเซมบลี้ 21 รู้โครงสร้างเครื่องทั่วไป 211 อธิบายหน่วยประมวลผลกลาง 212 อธิบายหน่วยความจำ 213 อธิบายรีจิสเตอร์ 214 อธิบายชุดคำสั่ง

Download Presentation

บทที่ 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. บทที่ 2 Machine Structure, Machine Language, and Assembly Language Machine Structure, Machine Language, and Assembly Language

  2. จุดมุ่งหมาย 2. โครงสร้างเครื่อง ภาษาเครื่อง และภาษาแอสเซมบลี้ 21 รู้โครงสร้างเครื่องทั่วไป 211 อธิบายหน่วยประมวลผลกลาง 212 อธิบายหน่วยความจำ 213 อธิบายรีจิสเตอร์ 214 อธิบายชุดคำสั่ง 22 รู้โครงสร้างของภาษาเครื่อง 221 เขียนโปรแกรมด้วยภาษาเครื่องกรณีไม่มีลูปวน 222 อธิบายการแอดเดรสโดยตรง Machine Structure, Machine Language, and Assembly Language

  3. จุดมุ่งหมาย (ต่อ) 223 อธิบายการแอดเดรส โดยใช้อินเด็กส์รีจิสเตอร์ 224 เขียนโปรแกรมด้วยภาษาเครื่องกรณีมีลูปวน 23 รู้ภาษาแอสเซมบลี้ 232 เขียนโปรแกรม ด้วยภาษาแอสเซมบลี้ Machine Structure, Machine Language, and Assembly Language

  4. โครงสร้างของเครื่อง Machine Structure, Machine Language, and Assembly Language

  5. Instruction Format ตัวอย่าง Instruction Format ของเครื่อง SC-6251 ซึ่งมี 4 Registers Add 2, 176 Machine Structure, Machine Language, and Assembly Language

  6. Instruction Format ตัวอย่าง Instruction Format ของเครื่อง SC-6251 ซึ่งมี 4 Registers Add 2, 176 นำค่าในแอดเดรสที่ 176 + ค่าใน Reg 2 ไปเก็บไว้ใน Reg 2 Machine Structure, Machine Language, and Assembly Language

  7. Machine Structure, Machine Language, and Assembly Language

  8. 2.1.1 เมื่อเปลี่ยนไปใช้เครื่องใหม่ สิ่งที่เราจะต้องรู้เพื่อเป็นข้อมูลสำสำหรับเครื่องใหม่ ที่ใช้ CPU แตกต่างกันไป • หน่วยความจำ (Memory) • รีจิสเตอร์ (Registers) • ข้อมูล (Data) • คำสั่ง (Instructions) • องค์ประกอบอื่นๆ Machine Structure, Machine Language, and Assembly Language

  9. 1. หน่วยความจำ (Memory) • หน่วยของหน่วยความจำคืออะไร? • ขนาดของหน่วยความจำเป็นอย่างไร? และ • รูปแบบการอ้างแอดเดรสของหน่วยความจำเป็นอย่างไร? Machine Structure, Machine Language, and Assembly Language

  10. 2. รีจิสเตอร์ (Registers) • มีรีจิสเตอร์กี่ตัว? • ขนาดและ หน้าที่ของรีจิสเตอร์แต่ละตัว • ความสัมพันธ์ระหว่างกัน Machine Structure, Machine Language, and Assembly Language

  11. 3. ข้อมูล (Data) • ข้อมูลชนิดอะไรบ้าง ที่คอมพิวเตอร์ สามารถใช้งานได้? • สามารถเก็บตัวเลข ตัวอักษร หรือข้อมูลทางตรรกศาสตร์ได้หรือไม่? • ข้อมูลเหล่านี้ มีวิธีการเก็บอย่างไร? Machine Structure, Machine Language, and Assembly Language

  12. 4. คำสั่ง (Instructions) • ชั้น (Classes) ของกลุ่มคำสั่ง มีอะไรบ้าง? • มีคำสั่งคำนวณทางคณิตศาสตร์ และตรรกศาสตร์หรือไม่? • คำสั่งเหล่านี้ มีวิธีการเก็บในหน่วยความจำอย่างไร? Machine Structure, Machine Language, and Assembly Language

  13. 5. องค์ประกอบอื่นๆ • โครงสร้างของ Interrupt เป็นอย่างไร? • มีระบบป้องกัน รักษาความปลอดภัย ของข้อมูล ให้กับผู้ใช้หรือไม่? Machine Structure, Machine Language, and Assembly Language

  14. 2.1.2 โครงสร้างของเครื่อง IBM 360/370 • หน่วยความจำ • Registers • ข้อมูล (Data) • คำสั่ง (Instructions) • ส่วนพิเศษอื่นๆ Machine Structure, Machine Language, and Assembly Language

  15. 1. หน่วยความจำ หน่วยของหน่วยความจำ ไบท์ ความยาวเป็นบิท (Unit of Memory) (Bytes) (Lengt in Bits) Byte 1 8 Halfword 2 16 Word 4 32 Doubleword 8 64 Machine Structure, Machine Language, and Assembly Language

  16. 1. หน่วยความจำ (ต่อ) • หน่วยของหน่วยความจำ ประกอบไปด้วย 4 บิท เรียกว่า นิบเบิ้ล (Nibble) • ขนาด (Size) หน่วยความจำของ IBM 360 คือ 224 ไบท์ (ประมาณ 16 ล้าน) Machine Structure, Machine Language, and Assembly Language

  17. 1. หน่วยความจำ (ต่อ) การอ้างแอดเดรสในหน่วยความจำของ 360 ประกอบด้วย 3 องค์ประกอบคือ อ๊อฟเซท (Offset) รวมกับค่าของ อินเด็กรีจิสเตอร์ (Index Register) และค่าของเบสรีจิสเตอร์ (Base Register) แอดเดรสรวม = ค่าของเบสรีจิสเตอร์ + ค่าของอ๊อฟเซท + ค่าของอินเด็กรีจิสเตอร์ (เราจะนำเสนอตัวอย่าง ในหัวข้อการแอดเดรสถัดไป) Machine Structure, Machine Language, and Assembly Language

  18. 2. Registers • 360 มี รีจิสเตอร์วัตถุประสงค์ทั่วไป (General-Purpose Register) ขนาด 32 บิท จำนวน 16 ตัว • มีรีจิสเตอร์ที่คำนวณทางทศนิยม (Floating-Point Registers) จำนวน 4 ตัว • มี Program Status Word (PSW) ขนาด 64 บิท ที่บรรจุ ค่าของ Location Counter (LC) ข้อมูลที่ถูกป้องกัน และ Interrupt Machine Structure, Machine Language, and Assembly Language

  19. รีจิสเตอร์วัตถุประสงค์ทั่วไป (General-Purpose Register) • สามารถทำการคำนวณทางคณิตศาสตร์ ตรรกศาสตร์ และ • ใช้เป็น Base Register Machine Structure, Machine Language, and Assembly Language

  20. Base Register • Index RegisterBase Register • A 1, 901 (2, 15) • Offset • แอดเดรสรวม = ค่าของเบสรีจิสเตอร์ • + ค่าของอ๊อฟเซท • + ค่าของอินเด็กรีจิสเตอร์ Machine Structure, Machine Language, and Assembly Language

  21. ข้อดี Base Register โปรแกรม 0 49 1) ช่วยในการ โปรเซสในเรื่องของ Relative address (ย้ายโปรแกรมไปมาในหน่วยความจำได้ โดยไม่มีผลกระทบ ต่อการอ้างแอดเดรส ในหน่วยความจำ เพียงแต่เปลี่ยนค่าของ Base register เท่านั้น) Base Reg. = 1000 Base Reg. = 2000 1000 1049 1725 2000 2049 Machine Structure, Machine Language, and Assembly Language

  22. ข้อดี Base Register (ต่อ) 2) ประการสำคัญก็คือ เราสามารถอ้างแอดเดรสได้ตลอดทั้งหน่วยความจำ ยกตัวอย่าง ถ้าต้องการอ้างแอดเดรส ในหน่วยความจำตลอดทั้งย่าน 224(ประมาณ 16 ล้านที่) ถ้าไม่ใช้ Base register เราต้องใช้ที่สำหรับอ้างแอดเดรส 24 บิท ดังนั้น คำสั่งบวกจากตัวอย่างที่แล้ว ก็จะใช้ที่เก็บชุดคำสั่ง 40 บิท Machine Structure, Machine Language, and Assembly Language

  23. ข้อดี Base Register (ต่อ) แต่ถ้าใช้ Base register เราจะใช้ที่เก็บชุดคำสั่งเพียง 32 บิท Machine Structure, Machine Language, and Assembly Language

  24. ข้อเสีย Base Register • การโปรเซสของเครื่องจะช้าลง เพราะต้องคำนวณแอดเดรส • การอ้างแอดเดรส จะทำได้แคบลง เพราะอ๊อฟเซท เหลือเพียงแค่ 12 บิท ทำให้อ้างแอดเดรสได้เพียง 0 – 4095 ดังนั้น ถ้าเราไม่ใช้อินเด็กรีจิสเตอร์ เราจะไม่สามารถอ้างแอดเดรส ได้เกินกว่า 4095 จากค่าของแอดเดรส ที่เก็บใน Base register Machine Structure, Machine Language, and Assembly Language

  25. 3. ข้อมูล (Data) S หมายถึง Sign Bit => 1 bit หรือ 4 bit D หมายถึง Binary Coded Decimal => 4 bits Z หมายถึง Zone Code => 4 bits C หมายถึง Characteristic of Exponent => 7 bits F หมายถึง Fraction of Mantissa => 24 bits or 56 bits Ch หมายถึง 1 character symbol => 8 bits Machine Structure, Machine Language, and Assembly Language

  26. 3. ข้อมูล (Data) (ต่อ) Machine Structure, Machine Language, and Assembly Language

  27. 4. คำสั่ง (Instructions) Machine Structure, Machine Language, and Assembly Language

  28. ตัวอย่าง ของคำสั่ง RR-format • คำสั่ง AR 3,4 Machine Structure, Machine Language, and Assembly Language

  29. Storage operand เลข Fixed-point แบบ Fullword ขนาด 32 บิท ค่า +267 ( 10B ในฐานสิบหก) จะเก็บที่แอดเดรส 1016 ดังรูป Machine Structure, Machine Language, and Assembly Language

  30. แอดเดรสของ Storage operand Address = c(Bi) + c(Xi) + Di (RX format) หรือ c(Bi) + Di (RS, SI, SS format) • โดยที่ c(Bi) และ c(Xi) แสดงข้อมูลที่บรรจุ อยู่ในรีจิสเตอร์ Bi และ Xi ตามลำดับ • ยกเว้นแต่ว่า ถ้า Xi = 0 ดังนั้น c(Xi) จะมีค่าเป็น 0 และ Bi ก็เช่นเดียวกัน Machine Structure, Machine Language, and Assembly Language

  31. ตัวอย่าง ของคำสั่ง RX-format คำสั่ง A 3, 16(0,5) สมมติว่า รีจิสเตอร์ 5 เก็บค่าของ 1000 จะทำให้ค่าของข้อมูลชนิด Word ที่อยู่ที่แอดเดรส = c(B2) + c(X2) + D2 = c(5) + c(0) + 16 = 1000 + c(0) + 16 = 1016 Machine Structure, Machine Language, and Assembly Language

  32. ตัวอย่าง ของคำสั่ง SS-format คำสั่ง MVC 32(79,5),300(5) สมมติว่า รีจิสเตอร์ 5 เก็บค่าของ 1000 Storage operand 1 address = c(B1) + D1 = c(5) + 32 = 1000 + 32 = 1032 Storage operand 2 address = c(B1) + D1 = c(5) + 32 = 1000 + 300 = 1300 Machine Structure, Machine Language, and Assembly Language

  33. คำสั่งของเครื่อง 360/370(ดู Appendix A) กลุ่มที่ 1 Load Instruction และ store Instructions Hexa code MnemonicFormat of Instruction op-code 58 L RX 48 LH RX 98 LM RS 18 LR RR 12 LTR RR 50 ST RX 40 STH RX 90 STM RS Machine Structure, Machine Language, and Assembly Language

  34. กลุ่มที่ 2 คำนวณ Hexa code Mnemonic Format of Instruction op-code 5A A RX 4A AH RX 1A AR RR 59 C RX 49 CH RX 19 CR RR 5D D RX 1D DR RR 5C M RX 1C MR RR 5B S RX 1B SR RR Machine Structure, Machine Language, and Assembly Language

  35. กลุ่มที่ 3 Logical Hexa code Mnemonic Format of Instruction op-code 55 CL RX 15 CLR RR D2 MVC SS 92 MVI SI 8D SLDL RX Machine Structure, Machine Language, and Assembly Language

  36. กลุ่มที่ 4 Branch and Link Hexa code Mnemonic Format of Instruction op-code 47 BC RX 07 BCR RR 45 BAL RX Machine Structure, Machine Language, and Assembly Language

  37. 5. ส่วนพิเศษอื่นๆ • เครื่อง 360 ยังมีส่วน Hardware ที่ช่วยป้องกันข้อมูลเป็น Block ขนาด 2,048 ไบท์ และยังมีระบบ Interrupt อีกด้วย จะกล่าวระเอียด ในบทที่ 9 Machine Structure, Machine Language, and Assembly Language

More Related