1 / 10

แมคโคร (Macros)

แมคโคร (Macros). กลุ่มชุดคำสั่งที่สามารถเรียกใช้ได้หลายครั้ง. การกำหนดแมคโคร. macro_name MACRO d1,d2,…dn statements ENDM d1,d2,…dn เป็นพารามิเตอร์ที่ส่งผ่านเข้าไปในแมคโคร เรียกว่า dummy parameters.

huslu
Télécharger la présentation

แมคโคร (Macros)

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. แมคโคร (Macros) กลุ่มชุดคำสั่งที่สามารถเรียกใช้ได้หลายครั้ง

  2. การกำหนดแมคโคร macro_name MACRO d1,d2,…dn statements ENDM d1,d2,…dn เป็นพารามิเตอร์ที่ส่งผ่านเข้าไปในแมคโคร เรียกว่า dummy parameters

  3. .CODE MAIN PROC …….. MOV DL , ‘A’ PUTCHAR MOV DL , ‘B’ PUTCHAR ………….. ตัวอย่าง PUTCHAR MACRO MOV AH , 2 INT 21H ENDM

  4. ตัวอย่าง จงเขียนแมคโครในการย้ายข้อมูลเวิร์ดหนึ่งไปยังอีกเวิร์ดหนึ่ง MOVW MACRO WORD1 , WORD2 PUSH WORD2 POP WORD1 ENDM

  5. เขียนแทรกได้ หลายแมคโคร • ตัวอย่างโปรแกรมการใช้แมคโคร .MODEL SMALL SEND_MSG MACRO STRING LEA DX , STRING MOV AH , 9 INT 21H ENDM .STACK 100H .DATA STRING_1 DB “เก่งแล้วไม่ต้องทำ Lab $” .CODE ……. SEND_MSG STRING_1

  6. การใช้คำสั่งเทียม LOCAL เป็นคำสั่งที่ใช้กำหนดตำแหน่งในแมคโคร การใช้งานจะมีรูปแบบดังนี้ LOCAL list_of_labeles

  7. ตัวอย่าง จงเขียนโปรแกรมเปรียบเทียบข้อมูลสองเวิร์ดว่าค่าใดมากกว่า GET_BIG MACRO WORD1 , WORD2 LOCAL EXIT MOV AX , WORD1 CMP AX , WORD2 JG EXIT MOV AX , WORD2 EXIT: ENDM

  8. การใช้คำสั่งเทียม EXTRN และ PUBLIC • EXTRN บอกว่าโพซีเยอร์ที่ตามมาอยู่คนละไฟล์ของโปรแกรม • PUBLIC บอกว่าโพซีเยอร์สามารถให้โปรแกรมอื่นเรียกได้

  9. .MODEL SMALL .CODE EXTRN DISPBIN:FAR .STARTUP ……. CALL DISPBIN ……. .EXIT END ตัวอย่าง .MODEL SMALL .CODE .PUBLIC DISPBIN DISPBIN PROC FAR ……….. RET DISPBIN ENDP LINK TESTBIN + DISPBIN,,;

  10. คำสั่ง การทำงาน AX CL AND CL , 0FH;เปลี่ยนค่า CL เป็น 09 0035 09 AND AL , 0FH ;เปลี่ยนค่า AL เป็น 05 0005 09 MUL CL ;คูณ AL กับ CL 002D 09 AAM ;เปลี่ยนค่าใน AX เป็น BCD 0405 OR AX , 3030H ;เปลี่ยนค่าใน AX เป็น ASCII 3435 การทำงานของคำสั่งจะหารค่าใน AL ด้วย 10 และเก็บผลลัพธ์ใน AH เศษเก็บใน AL

More Related