1 / 11

โครงสร้างคอมพิวเตอร์ และภาษาแอสเซมบลี้

โครงสร้างคอมพิวเตอร์ และภาษาแอสเซมบลี้. อินเทอร์รัพท์ ( Interrupt). ผศ.บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 1 9 ตุลาคม 2555. มหาวิทยาลัยเนชั่น จังหวัดลำปาง http://www. nation.ac.th. ความหมายของอินเทอร์รัพท์. อินเทอร์รัปท์ (Interrupt)

Download Presentation

โครงสร้างคอมพิวเตอร์ และภาษาแอสเซมบลี้

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. โครงสร้างคอมพิวเตอร์ และภาษาแอสเซมบลี้ อินเทอร์รัพท์ (Interrupt) ผศ.บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 19 ตุลาคม 2555 มหาวิทยาลัยเนชั่น จังหวัดลำปาง http://www.nation.ac.th

  2. ความหมายของอินเทอร์รัพท์ความหมายของอินเทอร์รัพท์ อินเทอร์รัปท์ (Interrupt) ทางเข้าโปรแกรมย่อยที่ BIOS หรือ DOS มีไว้บริการ เป็นการเข้าไปขัดจังหวะ เพื่อขอกระทำการบางอย่าง เช่น ขอพิมพ์ ขออ่านข้อมูลบางอย่าง เป็นต้น ผู้รู้บางท่านกล่าวว่า interrupt เหมือน call function ในภาษาคอมพิวเตอร์ คือ เข้าไปเรียกโปรแกรมบางอย่างมาทำงานจนเสร็จ แล้วย้อนกลับมาทำบรรทัดต่อไป อินเทอร์รัพท์เป็นกระบวนการในการส่งสัญญาณบอกให้ซีพียูรับรู้แล้วหยุดงานที่ทำอยู่ และหันมาตอบสนองต่ออินเทอร์รัพที่ร้องขอ เป็นวิธีที่เหมาะสมที่สุด ในการติดต่อระหว่างอุปกรณ์และซีพียู มีลักษณะคล้ายการเรียกใช้ subroutine ข้อมูลจาก http://www.thaiall.com/assembly/interrupt.htm

  3. เทอร์มิเนตโปรแกรม (ah=0+int 21) C:\>debug test.com -a 11BD:0100 mov ah,0 11BD:0102 int 21 11BD:0104 -rcx CX 0000 :4 -w Writing 00004 bytes -q C:\>test.com C:\>

  4. พิมพ์อักษร(ah=2+int 21) DOS> copy con x.scr n x.com a mov ah,02 mov dl,41 int 21h mov ah,02 mov dl,61 int 21h mov ah,02 mov dl,62 int 21h int 20 rcx 0014 w q DOS> debug < x.scr DOS> x.com Aab

  5. รับอักษรจากแป้นพิมพ์ (ah=8+int 21) mov ah,8 int 21 mov ah,2 mov dl,al int 21 mov ah,4c int 21

  6. กำหนดโหมดจอภาพ (ah=0+int 10) ตัวอย่างนี้จะสั่ง Clear Screen(80*25 B/W) mov ah,0 mov al,2 int 10 mov ah,0 int 21

  7. กำหนดขนาดตัวกระพริบ(ah=1+int 10) mov ah,1 mov ch,0 mov cl,7 int 10 mov ah,0 int 21

  8. Assembly Segments 1. เซกเมนต์ข้อมูล (Data segment) 2. เซกเมนต์คำสั่ง (Code segment) 3. เซกเมนต์สแตก (Stack segment) 4. เซกเมนต์พิเศษ (Extra segment) Interrupt บางตัวใช้ใน Debug ไม่ได้ ต้องเขียนเป็นชุดคำสั่งให้ Compiler แปล

  9. Segment แบบใหม่ (ah=2+int 21) .model small .stack 64h .data data1 db 61h .code main proc mov ax,@data mov ds,ax mov dl,data1 mov ah,2 int 21h mov ah,4ch int 21h main endp end main

  10. Segment แบบเก่า (ah=2+int 21) sseg segment db 64 dup(?) sseg ends dseg segment a db 61h dseg ends cseg segment main proc far assume cs:cseg,ds:dseg,ss:sseg mov ax,dseg mov ds,ax mov dl,a mov ah,2 int 21h mov ah,4ch int 21h main endp cseg ends end main

  11. แสดงข้อความ (ah=9+int 21) cseg segment assume cs:cseg,ds:cseg push cs pop ds jmp start msg1 db 'aaa',0ah,0dh,'$' start: mov ah,09h lea dx,msg1 int 21h mov ah,01h ; input char to dl int 21h jmp start cseg ends end

More Related