const unsigned short data_port = 0x0378;
const unsigned short status_port = 0x0379;
const unsigned short control_port = 0x037A;
//const unsigned short data_port = 0x0278;
//const unsigned short status_port = 0x0279;
//const unsigned short control_port = 0x027A;
//const unsigned short data_port = 0x03BC;
//const unsigned short status_port = 0x03BD;
//const unsigned short control_port = 0x03BE;
#define RED_SWITCH 0x80
#define YELLOW_SWITCH 0x40
#define GREEN_SWITCH 0x20
#define SWITCH_MASK 0xE0
#define LED1 0x1E // 1-1110
#define LED2 0x1D // 1-1101
#define LED3 0x1B // 1-1011
#define LED4 0x17 // 1-0111
#define LED5 0x0F // 0-1111
#define LED1_4 0x16 // 1-0110
#define LED2_5 0x0D // 0-1101
#define LED_MASK 0x1F
#define ALL_OFF 0xFF
int main()
{
_outp(control_port, 0xCC); //出力モードにする
_outp(data_port, ALL_OFF);
printf("何かキーを押すと赤色LED1/4、黄色LED2/5が点灯します.");
getch();
printf("\n");
printf("何かキーを押すと終了します.");
for (;;)
{
_outp(data_port, RED_SWITCH|LED1_4);
_outp(data_port, YELLOW_SWITCH|LED2_5);
if (kbhit())
{
getch();
break;
}
}
_outp(data_port, ALL_OFF);
return 0;
}
|