From 65d5c3f5c3a459a85441aa08690d04aa6926632e Mon Sep 17 00:00:00 2001 From: Miheev Egor Date: Tue, 10 Sep 2024 20:13:01 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D1=81=D0=BC=D0=BE=D0=B3=20=D0=BE=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D0=B8=D1=82=D1=8C=20=D0=BE=D1=82=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B5?= =?UTF-8?q?=D0=B2=20=D0=B8=20=D0=BE=D1=82=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D1=8B=D0=B9=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01-asm-basics/Labv1.cpp | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 01-asm-basics/Labv1.cpp diff --git a/01-asm-basics/Labv1.cpp b/01-asm-basics/Labv1.cpp new file mode 100644 index 0000000..de3204b --- /dev/null +++ b/01-asm-basics/Labv1.cpp @@ -0,0 +1,87 @@ +#include +#include +#include +#include + +#define PortCan0 0x40 + +void beep(unsigned iTone, unsigned iDlit); + +int main(void) { + + long int lCnt = 0; + int iA = 0x1234; + + char *pT = (char *)0x46C; + printf("\n\n"); + for (int i = 0; i < 10; i++) + printf(" \n %d ", *pT); + printf("\n\n"); + getch(); + + printf("\n Читаем содержимое порта с адресом 40 с помощью функции Си \n"); + printf("\n Для выхода из цикла - нажмите любую клавишу \n"); + + while (bioskey(1) == 0) { + printf(" \n Порт40 = %d ", inp(PortCan0)); + delay(500); + } + getch(); + printf("\n Читаем содержимое порта с адресом 40 ассемблером \n"); + + while (bioskey(1) == 0) { + asm { + push ax + in al,0x40 + } + unsigned char Tmm = _AL; + asm pop ax delay(500); + printf(" \n Порт40 = %d ", Tmm); + } + getch(); + printf("\n Для продолжения - нажмите любую клавишу \n "); + getch(); + + long far *pTime = (long *)0x46C; + while (bioskey(1) == 0) { + printf("\n %ld", *pTime); + delay(1000); + } + getch(); + + int Time; + while (bioskey(1) == 0) { + asm push ds asm push si + + asm mov ax, + 40h asm mov ds, ax asm mov si, 0x6C asm mov ax, [ds : si] asm mov Time, + ax asm pop si asm pop ds + + printf("\n %d", Time); + delay(300); + } + + beep(400, 200); + for (lCnt = 0; lCnt < 1000000; lCnt++) { + a1: + asm { mov ax,iA + mov ax,iA + mov ax,iA + mov ax,iA + mov ax,iA + mov ax,iA + mov ax,iA + mov ax,iA + mov ax,iA + a2: + mov ax,iA + } + } + beep(400, 200); +} + +void beep(unsigned iTone, unsigned iDlit) { + sound(iTone); + delay(iDlit); + nosound(); +}