diff --git a/01-asm-basics/main.c b/01-asm-basics/main.c index 9a8d417..167ca2e 100644 --- a/01-asm-basics/main.c +++ b/01-asm-basics/main.c @@ -2,6 +2,8 @@ #include #include +#include "substitutions.h" + #define PortCan0 0x40 void beep(unsigned iTone, unsigned iDlit); @@ -27,15 +29,18 @@ int main(void) { printf("\n Читаем содержимое порта с адресом 40 с помощью функции Си \n"); printf("\n Для выхода из цикла - нажмите любую клавишу \n"); - while (bioskey(1) == 0) { + set_input_mode(); + while (isKeyPressed() == 0) { printf("\n Порт40 = %d", inp(PortCan0)); delay(500); } + reset_input_mode(); system("pause"); printf("\n Читаем содержимое порта с адресом 40 ассемблером \n"); - while (bioskey(1) == 0) { + set_input_mode(); + while (isKeyPressed() == 0) { asm { push ax in al,0x40 @@ -45,19 +50,23 @@ int main(void) { delay(500); printf("\n Порт40 = %d", Tmm); } + reset_input_mode(); system("pause"); printf("\n Для продолжения - нажмите любую клавишу \n"); system("pause"); long *pTime = (long *)0x46C; - while (bioskey(1) == 0) { + set_input_mode(); + while (isKeyPressed() == 0) { printf("\n %ld", *pTime); delay(1000); } + reset_input_mode(); system("pause"); int Time; - while (bioskey(1) == 0) { + set_input_mode(); + while (isKeyPressed() == 0) { asm push ds asm push si asm mov ax, 40h @@ -71,6 +80,7 @@ int main(void) { printf("\n %d", Time); delay(300); } + reset_input_mode(); beep(400, 200); for (lCnt = 0; lCnt < 1000000; lCnt++) { diff --git a/01-asm-basics/substitutions.c b/01-asm-basics/substitutions.c index c59edcd..d6cb262 100644 --- a/01-asm-basics/substitutions.c +++ b/01-asm-basics/substitutions.c @@ -1,3 +1,4 @@ +#include "substitutions.h" #include #include #include diff --git a/01-asm-basics/substitutions.h b/01-asm-basics/substitutions.h new file mode 100644 index 0000000..8bf31e0 --- /dev/null +++ b/01-asm-basics/substitutions.h @@ -0,0 +1,9 @@ +#ifndef SUBSTITUTIONS_H +#define SUBSTITUTIONS_H + +void reset_input_mode(); +void set_input_mode(); +void delay(unsigned int ms); +char isKeyPressed(); + +#endif