Compile Study Notes for beginners (13)-External interruptions

Source: Internet
Author: User

Getting started with crazy summer vacation Study Notes (13th)-out-of-band interruption


Reference: Chapter 15th of Assembly Language


1. External interruption Information


External interruptions can be divided into shielded interruptions and unshielded interruptions.


Blocked interruptions

First, let's take a look at the interrupt process caused by internal interruption:

(1) is the interrupt type N.

(2) Mark Register into Stack, set if = 0, TF = 0.

(3) Cs and IP address

(4) (IP) = (N * 4), (CS) = (N * 4 + 2)


The interruption process that can block the interruption is different from that caused by the internal interruption. The first step is different. The interruption process can be shielded. The CPU should first check the if value. If if = 0, the operation will not be interrupted. If if = 1, the operation will be interrupted.


Unblocked interruption

Unblocking interruption is the CPU must be interrupted accordingly. There are very few unblocked interruptions, so the interrupt type is fixed to 2. Do you need to take the interrupt type during the interruption process?

The process of interruption that cannot be blocked:

(1) Mark Register into Stack, set if = 0, TF = 0.

(2) Cs and IP address

(3) (IP) = (8), (CS) = (0ah)


2. PC keyboard handling process


When we press the next key, the chip on the keyboard generates a scan code. Does scan show that the keyboard key is at the keyboard position. Scan is sent to the register of the related interface chip on the motherboard. The port of this register is 60 h. Is a scan by pressing a key usually called a pass, a scan by releasing a key is called a code break, a 7th-Bit 0, and a code break of 7th-bit 1, that is, a code break = a pass + 80 h

Does the Keyboard Scan reach 60 h? Yes, the related chip will send the interrupt type to the CPU? Is it 9, which can shield the interrupt information.

Int 9 interrupt routines mainly work:

(1) read the 60 h port scan?

(2) if it is a scan of the character key, will the scan and its corresponding characters (ASCII?) be sent to the BIOS Keyboard Buffer in the memory; if it is a scan of the control key (such as CTRL) and switch key (such as capslock), it will be converted to the status byte (using a binary bit to record the control key and switch key status byte) status byte units stored in memory

(3) control the keyboard system. For example, related chips send response information.


3. Modify int 9 interrupt


First, display 'A' ~ in the middle of the screen '~ The 'Z' character requires a delay to achieve the display interval. It is delayed by a large number of cycles.

Implementation Code:

Assume Cs: codecode segmentstart: mov ax, 0b800hmov es, axmov Al, 'A' S: mov ES: [160*12 + 40*2], alcall delay; 10000000 cycles, used to delay Inc alcmp Al, 'z' JNA smov ax, 4c00hint 21 h; delay: Push axpush dxmov dx, 1000 h; outer loop 1000h, inner loop 100000h mov ax, 0s1: sub ax, 1sbb dx, 0cmp ax, 0jne s1cmp dx, 0jne s1pop dxpop axretcode endsend start


Press the ESC key to change the color of the displayed characters.

Assume Cs: codestack segmentdb 128 DUP (0) stack endsdata segmentdw 0 0 Data endscode segmentstart: mov ax, stackmov SS, axmov sp, 128mov ax, datamov ds, axmov ax, 0mov es, axpush ES: [9*4] Pop DS: [0]; Save the entry of the original int 9 Interrupt Routine to DS: 0 and DS: 2. Push ES: [9*4 + 2] Pop DS: [2] mov word ptr es: [9*4], offset int9; set the entry address of the new int 9*4 Interrupt Routine in the interrupt vector table mov ES: [9*4 + 2], csmov ax, 0b800hmov es, axmov Al, 'A's: mov ES: [160*12 + 40*2], alcall delay; loop 10000000 times, used to delay Inc alcmp Al, 'z' JNA smov ax, 0mov es, axpush DS: [0] Pop ES: [9*4] push ds: [2] Pop ES: [9*4 + 2] mov ax, 4c00hint 21 h; delay: Push axpush dxmov dx, 1000 h; outer loop H, inner loop H mov ax, 0s1: sub ax, 1sbb dx, 0cmp ax, 0jne s1cmp dx, 0jne s1pop dxpop axretint9: Push axpush bxpush Esin Al, 60 hpushf pushfpop bxand BH, 11111110b; set if = 0.tf= 0 push bxpopfcall dword ptr ds: [0]; simulate calling the original int 9*4 Interrupt Routine CMP Al, 1; 1 is the ESC Keyboard Scan code JNE int9retmov ax, 0b800hmov es, axinc byte ptr es: [160*12 + 40*2 + 1]; Press ESC key plus 1 each time to change the color attribute int9ret: Pop ESPOP bxpop axiretcode endsend start






Compile Study Notes for beginners (13)-External interruptions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.