전경 핸들러를 호출하는 중앙 루프가 무엇을 제안합니다.
인터럽트 서비스 루틴은 바이트 값을 어딘가에 넣습니다.
전경 핸들러
은 일부 의사 코드를 해당 바이트
전경과 배경 그 바이트와 "통신"(또는 어떤 종류의 구조) 다음
에서
The_Top_Of_This_Loop:
Call Check_What_ISR_01_Did
Call Check_What_ISR_02_Did
Call Check_What_ISR_03_Did
Call Check_What_ISR_04_Did
Call Update_The_Rest_Of_The_System
Jump The_Top_Of_This_Loop
전경을 것 보면 서브 루틴은 이런 식으로 처리 할 것입니다 (다시 말하면, 의사 코드, 당신은 진짜 무엇인가를 씁니다)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Subroutine name: Check_What_ISR_01_Did ;
; ;
; Looks at the indicator from the background and takes ;
; the appropriate action. ;
; ;
; On Entry: Nothing ;
; ;
; On Exit: Reg_00 is messed up, don't believe it ;
; ;
; ;
; ;
; ;
; ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Check_What_ISR_01_Did:
Move Reg_00.Byte, The_ISR_01_Flag ;The ISR Set this if he did anything
Cmp Reg_00.Byte, Nothing_Happened ;Did anything happen since last time ?
Jz We_Are_Done ;No, there's nothing to do
; ;else yes, so examine what to do
; ;and so on
; ; blah
; ; blah
; ; blah
We_Are_Done:
Return ;End of foreground routine
실제 ISR 이런 식으로 뭔가를 할 것입니다
...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Interrupt Service Routine 01 ;
; ;
; Checks to see if a button was pushed. ;
; ;
; On Entry: Nothing ;
; ;
; On Exit: The_ISR_01_Flag is updated to hold ;
; a value which the foreground will ;
; use to make a decision ;
; ;
; ;
; ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ISR_01:
Push {All The Registers And Flags} ;This is the background; leave with no trace
; ;Do whatever
; ; your real
; ; code needs
; ; to do to look
; ; at a button
Move Reg_00.Byte, Nothing_Happened ;This is a defined constant value somewhere
Move The_ISR_01_Flag, Reg_00.Byte ;The foreground routine will see this
Jump We_Are_Done ;There's nothing else to do now
We_Are_Done:
Pop {All The Registers And Flags} ;Don't forget the stack
IntReturn ;End of ISR
다시 말하지만,이 모든 의사 코드는, 그래서 진짜 구문과를 사용합니다.
인터럽트 원본이 무엇인지에 따라 다릅니다. 플랫폼에 일종의 주기적 타이머가 있습니까? – Notlikethat
@ 제목 내부 및 외부 모두 많은 인터럽트 소스가 있습니다. 여러 플랫폼에서 발견되는 인터럽트에 대한 가설적인 사용에 대해 알고 싶습니다. 예를 들어, 우리가 RaspberryPi를 사용하고 있다고 가정 해 봅시다. – penguin4hire
나는 따라 할 수 있을지 모르겠다. 가상의 경우 인터럽트가 발생한다. 당신은 응답으로 물건을합니다. 이러한 인터럽트가 발생할 때, 따라서 실제 시스템과 운영 환경에 따라 유용합니다. 기본적으로 가벼운 RTOS를 설명하는 것 같습니다. 운 좋게 그것들은 벌써 물건이다. – Notlikethat