From 4c423c7acc9cac34998de1c21729dbf3c322b0ba Mon Sep 17 00:00:00 2001 From: Miheev Egor Date: Tue, 10 Sep 2024 23:53:08 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D1=84?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B1=D1=8B=D0=BB=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=88=D0=B8=D1=82=D1=8B=20=D0=BA=20=D0=BE?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE=D0=BC=D1=83=20=D1=88=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BD=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01-asm-basics/main.c | 18 ++++++++++++++---- 01-asm-basics/substitutions.c | 1 + 01-asm-basics/substitutions.h | 9 +++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 01-asm-basics/substitutions.h 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