1 / 23

บทที่ 4

บทที่ 4. Macro Language and the Macro Processor. จุดประสงค์การเรียนการสอน. 4. แมคโคร 41 เข้าใจความรู้พื้นฐานเกี่ยวกับแมคโคร 411 เขียนโปรแกรม โดยใช้แมคโคร 412 เขียนโปรแกรมเรียกแมคโคร จากแมคโครภายใน. จุดประสงค์การเรียนการสอน (ต่อ).

erol
Download Presentation

บทที่ 4

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. บทที่ 4 Macro Language and the Macro Processor Macro Language and the Macro Language

  2. จุดประสงค์การเรียนการสอนจุดประสงค์การเรียนการสอน 4. แมคโคร 41 เข้าใจความรู้พื้นฐานเกี่ยวกับแมคโคร 411 เขียนโปรแกรม โดยใช้แมคโคร 412 เขียนโปรแกรมเรียกแมคโคร จากแมคโครภายใน Macro Language and the Macro Language

  3. จุดประสงค์การเรียนการสอน (ต่อ) 42 มีทักษะในการออกแบบตัวแอสเซมเบลอร์ ที่สามารถใช้ชุดคำสั่ง แมคโคร 421 อธิบายขั้นตอนการออกแบบแมคโครแอสเซมเบลอร์ 422 อธิบายข้อกำหนดของปัญหาของแมคโครแอสเซมเบลอร์ 423 อธิบายโครงสร้างข้อมูลของแมคโครแอสเซมเบลอร์ 424 อธิบายฐานข้อมูลของแมคโครแอสเซมเบลอร์ 425 อธิบายซิมโบลเทเบิ้ลของแมคโครแอสเซมเบลอร์ 426 อธิบายแมคโครแอสเซมเบลอร์ ในส่วน พาส -วัน 427 อธิบายแมคโครแอสเซมเบลอร์ ในส่วน พาส-ทู Macro Language and the Macro Language

  4. คำสั่งแมโครMacro Instructions (หรือเรียกสั้นๆ Macro) • คำสั่งเดียว ใช้แทนคำสั่งกลุ่มหนึ่งหรือชุดหนึ่ง • โดยปกติ จะประกอบด้วยคำสั่ง หลาย ๆ คำสั่ง ที่ผู้ทำโปรแกรมนำมารวมไว้ คำสั่งแมโครนี้จะมีการกำหนดเป็นชื่อคำสั่งไว้ในตอนต้นโปรแกรม เมื่อใดก็ตามที่มีการเรียกชื่อคำสั่งที่กำหนดไว้นี้ ก็จะเป็นการเรียกใช้กลุ่มคำสั่งที่ประกอบด้วยคำสั่งทั้งชุดนั้น • คำสั่งแมโครนี้ เราสามารถเรียกใช้ได้ตลอดเวลาที่เรียกใช้โปรแกรมนั้นอยู่ หรือทุกแห่งที่ต้องการเรียกใช้คำสั่งกลุ่มนั้น Macro Language and the Macro Language

  5. ตัวแปลแมโคร macro assembler • เป็นโปรแกรมคอมพิวเตอร์ที่ใช้งานในการสร้างโปรแกรมแมโคร • มีหน้าที่แปลภาษาที่ใช้ในแมโคร ให้เป็นภาษาแอสเซมบลี (assembly language) • แต่ละข้อคำสั่งในโปรแกรมภาษาแอสเซมบลีนั้นใช้แทนคำสั่งภาษาเครื่อง (machine language) หลายคำสั่งได้ ฉะนั้นถ้าเขียนแมโครเก็บไว้ เมื่อเรียกมาใช้ก็จะทำให้สะดวก ไม่ต้องพิมพ์คำสั่งยาว ๆ Macro Language and the Macro Language

  6. 4.1 คำสั่ง Macro : A 1, DATA A 2, DATA A 3, DATA : A 1, DATA A 2, DATA A 3, DATA : DATA DC F’5’ : ซ้ำกัน สามารถทำเป็น Macro หนเดียวด้วยชื่อย่อ แล้วเรียกใช้ได้หลายหน Macro Language and the Macro Language

  7. 4.1 คำสั่ง Macro (ต่อ) Macro Instruction Definition Format MACRO Start of definition [ ] Macro name ------------ ------------ Sequence to be ------------ abbreviated MEND End of definition Macro Language and the Macro Language

  8. ตัวอย่างภาษาแอสเซมลี้ที่เขียนซ้ำตัวอย่างที่ 1 : A 1, DATA A 2, DATA A 3, DATA : A 1, DATA A 2, DATA A 3, DATA : DATA DC F’5’ : ซ้ำกัน สามารถทำเป็น Macro หนเดียวด้วยชื่อย่อ แล้วเรียกใช้ได้หลายหน Macro Language and the Macro Language

  9. เขียนโดยใช้ Macro Macro Language and the Macro Language

  10. 4.2 Features of aMacroFacility • ตัวอย่างที่แล้ว ยังไม่มีประสิทธิภาพพอ กรณีข้อมูลมีหลายชุด ที่แอดเดรสแตกต่างกัน Macro Language and the Macro Language

  11. 4.2.1 Macro Instruction Arguments • เพิ่ม Macro dummy arguments Macro Language and the Macro Language

  12. ตัวอย่างที่ 2 : A 1, DATA1 A 2, DATA1 A 3, DATA1 : A 1, DATA2 A 2, DATA2 A 3, DATA2 : DATA1 DC F’5’ DATA2 DC F’10’ : คล้าย แต่ไม่เหมือน Macro Language and the Macro Language

  13. เขียนโดยใช้ Macro Macro Language and the Macro Language

  14. ตัวอย่างที่ 3 : LOOP1 A 1, DATA1 A 2, DATA2 A 3, DATA3 : LOOP2 A 1, DATA3 A 2, DATA2 A 3, DATA1 : DATA1 DC F’5’ DATA2 DC F’10’ DATA3 DC F’15’ : คล้าย แต่ไม่เหมือน Macro Language and the Macro Language

  15. เขียนโดยใช้ Macro Argument ตรงตำแหน่ง Macro Language and the Macro Language

  16. เขียนโดยใช้ Macro อีกรูปแบบ Macro Language and the Macro Language

  17. 4.2.2 การใช้คำสั่งเงื่อนไขในแมโคร • 2 คำสั่งที่สำคัญคือ AIF และ AGO • AIF เป็นคำสั่ง กระโดดไปทำ แบบมีเงื่อนไข • AGO เป็นคำสั่ง กระโดดไปทำ แบบไม่มีเงื่อนไข • .LABELNAME เป็นแอดเดรสที่คำสั่ง AIF และ AGO กระโดดไปทำ Macro Language and the Macro Language

  18. ตัวอย่างที่ 4 การใช้คำสั่งเงื่อนไขในแมโคร : LOOP1 A 1, DATA1 A 2, DATA2 A 3, DATA3 : LOOP2 A 1, DATA3 A 2, DATA2 : LOOP3 A 1, DATA1 : DATA1 DC F’5’ DATA2 DC F’10’ DATA3 DC F’15’ : Macro Language and the Macro Language

  19. เขียนโดยใช้ Macro Macro Language and the Macro Language

  20. 4.2.3 การใช้แมโครย่อย ในแมโครหลัก เพราะว่าคำสั่งแมโคร คือคำสั่งเดียว ที่ใช้แทน กลุ่มคำสั่งหลายคำสั่ง ดังนั้นเราจึงสามารถใช้คำสั่งแมโคร ในตัวกำหนดแมโครได้ MACRO ADD1 &ARG L 1, &ARG A 1,=F’1’ ST 1,&ARG MEND MACRO ADDS &ARG1,&ARG2,&ARG3 ADD1 &ARG1 ADD1 &ARG2 ADD1 &ARG3 MEND Macro Language and the Macro Language

  21. Macro Language and the Macro Language

  22. 4.2.4 คำสั่งแมโครที่ใช้นิยามแมโคร Macro Language and the Macro Language

  23. การใช้งาน เรียกแมโครนี้ด้วยคำสั่ง เพื่อนิยามแมโครชื่อ COS DEFINE COS COS จะถูกขยายเป็นแมโครตัวใหม่คือ COS AR จากนั้นจะผลิตกลุ่มคำสั่งออกมาเป็น BALR 1,*+8 DC A(AR) address of AR L 15,=V(COS) V denotes address of external symbol BALR 14,15 Macro Language and the Macro Language

More Related