1 / 36

หลักการภาษาชุดคำสั่ง

หลักการภาษาชุดคำสั่ง. Introduction. มหาวิทยาลัยเนชั่น http:// www. nation. ac.th. บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 18 กรกฎาคม 2556. คำอธิบายรายวิชา.

jovanna
Télécharger la présentation

หลักการภาษาชุดคำสั่ง

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. หลักการภาษาชุดคำสั่ง Introduction มหาวิทยาลัยเนชั่น http://www.nation.ac.th บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 18 กรกฎาคม 2556

  2. คำอธิบายรายวิชา ทฤษฎีของการออกแบบ และสร้างภาษา แนวคิดเกี่ยวกับภาษาฟอร์มัล รูปแบบ และคุณลักษณะทางไวยากรณ์เบื้องต้น ชนิด และโครงสร้างของข้อมูล โครงสร้างของการควบคุม และการเคลื่อนที่ของข้อมูล การพิจารณาเวลาในการประมวลผล อัลกอริทึมแบบขนาน การออพติไมซ์ การออกแบบ และสร้างลักษณะต่าง ๆ ของภาษา ลักษณะเฉพาะของภาษาแบบโครงสร้างบล๊อก แบบมอดูลาร์ แบบเชิงวัตถุ ประเภทของภาษาชุดคำสั่ง แบบกำหนดกระบวนการ และแบบไม่กำหนดกระบวนการ การวิเคราะห์ประโยคคำสั่งของภาษาคอมพิวเตอร์ ฝึกปฏิบัติการเขียน และทดสอบโปรแกรมด้วยภาษาปาสคาล ภาษาซี หรือภาษาระดับสูงอื่น ๆ

  3. วิวัฒนาการ และประวัติของแต่ละภาษา http://www.levenez.com/lang/ *** http://www.thaiall.com/programming/indexo.html http://www.thaiall.com/article/teachpro.htm http://www.thaiall.com/vb http://www.thaiall.com/php http://www.thaiall.com/assembly http://www.thaiall.com/asp http://www.thaiall.com/basic http://www.thaiall.com/cobol http://www.thaiall.com/pascal

  4. กระบวนการแปลภาษา กระบวนการแปลภาษา (Compilation Process) 1. เลกซิคัล อนาไลเซอร์ (Lexical Analyzer) 2. ซินแทกซ์ อนาไลเซอร์ (Syntax Analyzer) 3. ซีแมนติก อนาไลเซอร์ (Semantic Analyzer) 4. โค้ด ออฟติไมเซอร์ (Code Optimizer) 5. โค้ด เจนเนอเรเตอร์ (Code Generator) ข้อมูลจาก http://web.cecs.pdx.edu/~apt/cs321/ ***

  5. Compilation Process Diagram ข้อมูลจาก http://web.cecs.pdx.edu/~apt/cs321/ ***

  6. เลกซิคัล อนาไลเซอร์ (Lexical Analyzer)(1/5) ขั้นตอนแรก ทำหน้าที่ อ่าน Source Code แล้วแยกอักขระออกตามลักษณะ และหน้าที่ เช่น คำสั่ง ตัวแปร ค่าคงที่ เป็นต้น รวมถึงการขจัด ส่วนหมายเหตุ(Comment) ช่องว่างขาว(White space) เช่น blank, tab และ new line เป็นต้น ผลของขั้นตอนนี้จะแยกทุกสิ่งที่ควรแยกออกจากกัน เพื่อนำไปตรวจสอบในขั้นต่อไป

  7. ซินแทกซ์ อนาไลเซอร์ (Syntax Analyzer)(2/5) ขั้นตอนที่สอง ทำหน้าที่ ตรวจสอบความสัมพันธ์ การจัดเรียง และความถูกต้องของแต่ละคำ แต่ละประโยค ซึ่งมีวิธีตรวจสอบหลายวิธี เช่น ตรวจสอบ parse tree ว่ามีไวยากรณ์ถูกต้องตามที่กำหนดไว้หรือไม่

  8. ซีแมนติก อนาไลเซอร์ (Semantic Analyzer)(3/5) ขั้นตอนที่สาม ทำหน้าที่ ตรวจสอบความหมายของภาษา และสร้างรหัสของชุดคำสั่งที่ผ่านการตรวจสอบความถูกต้องของโครงสร้างแล้ว ให้อยู่ในรูปแบบ หรือขั้นตอนที่ใกล้เคียงกับภาษาเครื่อง ซึ่งเป็นภาษากลางที่ง่ายต่อการปรับปรุง หรือนำไปแปลงเป็นภาษาเครื่องต่อไป ขั้นตอนนี้อาจนำไปรวมกับ Code Generator แล้วสร้างภาษาเครื่องก็ได้

  9. โค้ด ออฟติไมเซอร์ (Code Optimizer)(4/5) ขั้นตอนที่สี่ ทำหน้าที่ ปรับปรุง code ที่ได้ให้มีประสิทธิภาพในการทำงาน ใน compiler บางตัวอย่างไม่มีขั้นตอนนี้ หรือมีขั้นตอนนี้ ที่ละเอียดกว่านี้ก็ได้

  10. โค้ด เจนเนอเรเตอร์ (Code Generator) (5/5) ขั้นตอนที่ห้า ทำหน้าที่ เปลี่ยนรหัสที่ได้ให้เป็นภาษาแอสเซมบลี หรือภาษาเครื่อง ซึ่ง code ที่ได้มีลักษณะขึ้นอยู่กับเครื่อง ที่ให้บริการ หน่วยความจำ และ register ที่แตกต่างกันไป แต่ภาษาใหม่ เช่น Java และ .NET จะแปลงเป็น Byte code แทน

  11. ทฤษฎีของการออกแบบ และ การแสดงแบบซอฟต์แวร์ • การพิมพ์โปรแกรมต้นฉบับ(Source listing) • ผังงาน(Flowchart) • ผังงานโปรแกรมโครงสร้าง(Structured flowchart) • ผังงานแบบ Nassi-Shneiderman • ผังงานแบบ HIPO (Hierarchy plus input-process-output) • ผังงานแจ็คสัน(Jackson Diagram) • ผังงานแบบวาร์นิเอร์-ออร์(Warnier-Orr Diagram) • ผังงานโครงสร้าง(Structure chart) • คำสั่งลำลอง(Pseudo code) • ตารางการตัดสินใจ(Decision table)

  12. Flowchart Diagram (1/2) ผังงาน (Flowchart) คือ รูปภาพ (Image) หรือสัญลักษณ์(Symbol) ที่ใช้เขียนแทนขั้นตอน คำอธิบาย ข้อความ หรือคำพูด ที่ใช้ในอัลกอริทึม (Algorithm) เพราะการนำเสนอขั้นตอนของงานให้เข้าใจตรงกัน ระหว่างผู้เกี่ยวข้อง ด้วยคำพูด หรือข้อความ ทำได้ยากกว่าเมื่อใช้รูปภาพ หรือสัญลักษณ์ ข้อมูลจาก http://www.thaiall.com/flowchart/

  13. Flowchart Diagram (2/2) ข้อมูลจาก http://www.thaiall.com/flowchart ข้อมูลจาก http://www.yourdon.com/strucanalysis/wiki/index.php?title=Chapter_15

  14. HIPO Diagram (1/2) HIPO (Hierarchy plus Input-Process-Output) ถูกพัฒนาโดยบริษัท IBM เมื่อ 2517 เพื่อเป็นเครื่องมือที่ช่วยในการออกแบบ และแสดงแบบซอฟต์แวร์ โดยใช้ผังงานแบบเดิม แต่เพิ่มผังงานสำหรับอธิบายส่วนนำข้อมูลเข้า ส่วนประมวลผล และส่วนส่งออก ซึ่ง HIPO ประกอบด้วยผังงาน 3 ประเภท คือ1)ผังงานลำดับความสำคัญของกิจกรรม (Hierarchy Diagram หรือ Visual Table of Contents) 2) ผังภาพรวม IPO (Overview IPO Diagram) 3) ผังภาพรายละเอียด IPO (Detailed IPO Diagram)

  15. HIPO Diagram (2/2) ข้อมูลจาก http://www.shk-dplc.com/cfo/articles/litigate.htm ข้อมูลจาก http://www.yourdon.com/strucanalysis/wiki/index.php?title=Chapter_15

  16. Nassi-Shneiderman diagram (NSD) (1/3) A Nassi-Shneiderman diagram (or NSD) is a graphical design representation for structured programming. Developed in 1972 by Isaac Nassi and Ben Shneiderman, these diagrams are also called structograms, as they show a program's structures. ข้อมูลจาก http://en.wikipedia.org/wiki/Nassi-Shneiderman_diagramข้อมูลจาก http://www.cs.umd.edu/hcil/members/bshneiderman/nsd/

  17. Nassi-Shneiderman diagram (NSD) (2/3) ไดอะแกรมนี้แสดงการโปรแกรมโครงสร้างอย่างเป็นระเบียบด้วยสี่เหลี่ยม และใช้เส้นทะแยงแยกซ้ายขวาสำหรับการตัดสินใจ ใช้บล็อกตามแนวตั้งคุมการทำซ้ำทั้งแบบ while และ repeat โดยทั้งหมดอยู่ในกรอบสี่เหลี่ยมเดียวกัน ข้อมูลจาก http://en.wikipedia.org/wiki/Nassi-Shneiderman_diagramข้อมูลจาก http://www.cs.umd.edu/hcil/members/bshneiderman/nsd/

  18. Nassi-Shneiderman diagram (NSD) (3/3) ข้อมูลจาก http://www.yourdon.com/strucanalysis/wiki/index.php?title=Chapter_15

  19. Jackson Diagram (1/3) Jackson Structured Programming (JSP) is a method for structured programming based on correspondences between data stream structure and program structure. The method is closely related in concept to creating a parser for a regular expression that describes the data stream structure, but tries to build a program structure that matches more than one data stream and provides guidance and techniques to compensate the limited lookahead and the clashes between the structures of the different data streams. JSP was originally developed in the 1970s by IT consultant Michael A. Jackson and documented in his 1975 book Principles of Program Design. Jackson's aim was to improve the general standard of COBOL programming, but the method is still useful when coding with modern programming languages such as C and Perl. ข้อมูลจาก http://www.smartdraw.com/resources/tutorials/jackson-system-development-diagrams/ข้อมูลจาก http://en.wikipedia.org/wiki/Jackson_Structured_Programming

  20. Jackson Diagram (2/3) ไดอะแกรมนี้แสดงความสัมพันธ์ของข้อมูล (Entity) และกิจกรรม (Action) ว่าแต่ละตารางมีกิจกรรมอะไรบ้าง มีสัญลักษณ์ Circle เล็กมุมบนขวาแสดงกิจกรรมเลือก สัญลักษณ์ asterisk แสดงการทำซ้ำ ส่วนโครงสร้างไดอะแรกคล้ายกับ Organization Chart จากบนลงล่าง ข้อมูลจาก http://www.smartdraw.com/resources/tutorials/jackson-system-development-diagrams/ข้อมูลจาก http://en.wikipedia.org/wiki/Jackson_Structured_Programming

  21. Jackson Diagram (3/3) ข้อมูลจาก http://www.smartdraw.com/resources/tutorials/jackson-system-development-diagrams/

  22. Warnier-orr Diagram (1/2) Warnier/Orr diagrams are a kind of hierarchical flowchart that allows us to describe the organization of data and procedures. There are four basic constructs used on Warnier/Orr diagrams: hierarchy, sequence, repetition, and alternation. There are also two slightly more advanced concepts that are occasionally needed: concurrency and recursion. Each of these six diagramming constructs are illustrated in the sections that follow.

  23. Warnier-orr Diagram (2/2) 1. Hierarchy is the most fundamental of all of the Warnier/Orr constructs. It is simply a nested group of sets and subsets shown as a set of nested brackets. 2. Sequence is the simplest structure to show on a Warnier/Orr diagram. Within one level of hierarchy, the features listed are shown in the order in which they occur. 3. Repetition is the representation of a classic "loop" in programming terms. It occurs whenever the same set of data occurs over and over again (for a data structure) or whenever the same group of actions is to occur over and over again (for a processing structure). 4. Alternation or selection, is the traditional "decision" process whereby a determination is made to execute one process or another. 5. Concurrency is one of the two advanced constructs used in the methodology. It is used whenever sequence is unimportant. 6. Recursion is the least used of the constructs. It is used to indicate that a set contains an earlier or a less ordered version of itself

  24. Structure Chart แผนผังโครงสร้าง (Structure Chart) หมายถึง เป็นเครื่องมือที่อธิบายถึงการแบ่งการทำงานของระบบออกเป็นส่วนย่อย หรือโมดูล โดยแสดงโมดูลเป็นลำดับขั้นตามการเรียกใช้ข้อมูล พร้อมทั้งแสดงถึงความสัมพันธ์ระหว่างโมดูล

  25. Decision Tree Decision tables are a precise yet compact way to model complicated logic. Decision tables, like if-then-else and switch-case statements, associate conditions with actions to perform. But, unlike the control structures found in traditional programming languages, decision tables can associate many independent conditions with several actions in an elegant way.

  26. USE CASE in UML Use Case Diagram เป็น Diagram ที่ทำหน้าที่ Capture requirement

  27. Compiler & Interpreter Interpreter จะแปลคำสั่งทีละบรรทัด และทำงานไปทีละบรรทัด เมื่อพบข้อผิดพลาดก็จะหยุดการทำงานทันที ตัวอย่างภาษาที่ทำงานแบบนี้คือ GW-Basic Compiler จะแปลคำสั่งทั้งหมด และสร้างเป็น Object File หากพบข้อผิดพลาดจะแจ้งให้ทราบ และไม่สร้าง Object File จนกว่าจะไม่พบข้อผิดพลาด เช่น Java หรือ Cobol

  28. การออกแบบ และสร้างลักษณะต่าง ๆ ของภาษา • แนวคิดเกี่ยวกับภาษาฟอร์มัล • รูปแบบ และคุณลักษณะทางไวยากรณ์เบื้องต้น • ชนิด และโครงสร้างของข้อมูล • โครงสร้างของการควบคุม และการเคลื่อนที่ของข้อมูล • การพิจารณาเวลาในการประมวลผล • อัลกอริทึมแบบบขนาน การออพติไมซ์

  29. ประเภทของภาษาชุดคำสั่งประเภทของภาษาชุดคำสั่ง • แบบกำหนดกระบวนการ (Procedural Programming) • แบบไม่กำหนดกระบวนการ(UnProcedural Programming) ข้อมูลจาก http://en.wikipedia.org/wiki/Procedural_programming ข้อมูลจาก http://en.wikipedia.org/wiki/Unstructured_programming

  30. ภาษาชุดคำสั่งแบบกำหนดกระบวนการภาษาชุดคำสั่งแบบกำหนดกระบวนการ Procedural programming is sometimes used as a synonym for imperative programming (specifying the steps the program must take to reach the desired state), but can also refer (as in this article) to a programming paradigm based upon the concept of the procedure call. Procedures, also known as routines, subroutines, methods, or functions (not to be confused with mathematical functions, but similar to those used in functional programming) simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. ข้อมูลจาก http://en.wikipedia.org/wiki/Procedural_programming

  31. ภาษาชุดคำสั่งแบบไม่กำหนดกระบวนการภาษาชุดคำสั่งแบบไม่กำหนดกระบวนการ UnProcedural programmingor unstructured programming is a programming paradigm where all code is contained in a single continuous block. This is contrary to structured programming, where programmatic tasks are split into smaller sections (known as functions or subroutines) that can be called whenever they are required. Unstructured programming languages have to rely on execution flow statements such as Goto, used in many languages to jump to a specified section of code. ข้อมูลจาก http://en.wikipedia.org/wiki/Unstructured_programming

  32. โครงสร้างภาษาแบบต่าง ๆ • แบบโครงสร้างบล๊อก (Block Structure) • แบบมอดูลาร์ (Module Structure) • แบบเชิงวัตถุ (Object-Oriented Structure) ข้อมูลจาก http://en.wikipedia.org/wiki/Statement_block ข้อมูลจาก http://en.wikipedia.org/wiki/Module_%28programming%29 ข้อมูลจาก http://en.wikipedia.org/wiki/Object-oriented_programming

  33. โครงสร้างภาษาแบบโครงสร้างบล๊อก (Block Structure) A statement block (or code block) is a section of code which is grouped together, much like a paragraph; such blocks consist of one, or more, statements. Statement blocks help make code more readable by breaking up programs into logical work units. statement blocks are enclosed by braces { ... } ข้อมูลจาก http://en.wikipedia.org/wiki/Statement_block

  34. โครงสร้างภาษาแบบมอดูลาร์ (Module Structure) A module is a software entity that groups a set of (typically cohesive) subprograms and data structures. Modules are units that can be compiled separately, which makes them reusable and allows multiple programmers to work on different modules simultaneously. Modules also promote modularity and encapsulation (i.e. information hiding), both of which can make complex programs easier to understand. ข้อมูลจาก http://en.wikipedia.org/wiki/Module_%28programming%29

  35. โครงสร้างภาษาแบบเชิงวัตถุ (Object-Oriented Structure) Object-oriented programming (OOP) is a programming paradigm that uses "objects" to design applications and computer programs. It can use several techniques from previously established paradigms, including inheritance, modularity, polymorphism, and encapsulation. It was not commonly used in mainstream software application development until the 1990s, though many modern programming languages support OOP. ข้อมูลจาก http://en.wikipedia.org/wiki/Object-oriented_programming

  36. แนวคิดภาษาโปรแกรมเชิงวัตถุแนวคิดภาษาโปรแกรมเชิงวัตถุ 1. การปกป้อง (Encapsulation) 2. การสืบทอด (Inheritance) 3. หลายรูป (Polymorphism) - ต่างตัวแปร (Overloading) - เขียนทับ (Overriding)

More Related