Compilation of beginner Study Notes (13)-External interruptions, compilation of Study Notes
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 = 0, the operation will not be interrupted. 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
51 MCU external interrupt (assembly language) Problem
The main program is: the flow lights 0 to 7 light in turn, the flow lights 7 to 0 light in turn, repeated cycle.
The Program for external interruption is: the light is fully on, and the light is completely off three times.
However, the program will not execute if there are no interrupted commands.
START:; Add below:
Setb ea; Total interrupt.
SETB EX0; Enable INT0 interrupt.
CLR IT0; Set INT0 to Level Trigger.
MOVA, #00 H
......
External interruptions can be achieved.
How do I get started with learning assembly languages?
Assembly is the language with the highest execution efficiency.
However, it is also very dependent on hardware, and the basic functions have been implemented by calling interrupt, so you also need to understand
For example, what operations can be performed on registers?
In fact, the simplest thing is to see how the functions are implemented, and you can quickly invest in the application.
In this way, you will soon become a master. It is easier to learn a little change. The most difficult thing is to remember the special processing methods.
And it makes no sense.