📄 vm51_intr.c
字号:
/*
Name: VM51_intr
Copyright: 2005
Author: rockins
Date: 15-08-05 21:39
Description: check whether interrupt occupy or not
*/
#include "VM51.h"
#include <stdio.h>
#include <stdlib.h>
static int int0_intr(void);
static int int1_intr(void);
static int t0_intr(void);
static int t1_intr(void);
static int s_intr(void);
/*****************************
INTR PRECEDENCE ORDER:
EX0 --IE0
T0 --TF0
EX1 --IE1
T1 --TF1
SERIES --RI or TI
*******************************/
int VM51_intr(void)
{
if (!GET_EA) // close intr,just return
return;
// FIRST LEVEL INTR
if (GET_EX0 && GET_PX0 && GET_IE0){
int0_intr();
return 0;
}
else if (GET_ET0 && GET_PT0 && GET_IT0){
t0_intr();
return 0;
}
else if (GET_EX1 && GET_PX1 && GET_IE1){
int1_intr();
return 0;
}
else if (GET_ET1 && GET_PT1 && GET_IT1){
t1_intr();
return 0;
}
else if (GET_ES && GET_PS && (GET_TI || GET_RI)){
s_intr();
return 0;
}
// SECONDARY LEVEL INTR,IGNORE PRECEDENCE BIT
if (GET_EX0 && !GET_PX0 && GET_IE0){
int0_intr();
return 0;
}
else if(GET_ET0 && !GET_PT0 && GET_IT0){
t0_intr();
return 0;
}
else if(GET_EX1 && !GET_PX1 && GET_IE1){
int1_intr();
return 0;
}
else if(GET_ET1 && !GET_PT1 && GET_IT1){
t1_intr();
return 0;
}
else if(GET_ES && !GET_PS && (GET_TI || GET_RI)){
s_intr();
return 0;
}
}
static int int0_intr(void)
{
U8 temp;
temp = (U8)(PC&0x00FF);
SP += 1;
RAM[SP] = temp;
temp = (U8)(PC&0xFF00);
SP += 1;
RAM[SP] =temp;
PC = (U16)0x0003;
}
static int int1_intr(void)
{
U8 temp;
temp = (U8)(PC&0x00FF);
SP += 1;
RAM[SP] = temp;
temp = (U8)(PC&0xFF00);
SP += 1;
RAM[SP] =temp;
PC = (U16)0x0013;
}
static int t0_intr(void)
{
U8 temp;
temp = (U8)(PC&0x00FF);
SP += 1;
RAM[SP] = temp;
temp = (U8)(PC&0xFF00);
SP += 1;
RAM[SP] =temp;
PC = (U16)0x000B;
}
static int t1_intr(void)
{
U8 temp;
temp = (U8)(PC&0x00FF);
SP += 1;
RAM[SP] = temp;
temp = (U8)(PC&0xFF00);
SP += 1;
RAM[SP] =temp;
PC = (U16)0x001B;
}
static int s_intr(void)
{
U8 temp;
temp = (U8)(PC&0x00FF);
SP += 1;
RAM[SP] = temp;
temp = (U8)(PC&0xFF00);
SP += 1;
RAM[SP] =temp;
PC = (U16)0x0023;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -