Lab 1: Основы ассемблера #1
@ -1,33 +1,36 @@
|
|||||||
#include <bios.h>
|
|
||||||
#include <conio.h>
|
|
||||||
#include <dos.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define PortCan0 0x40
|
#define PortCan0 0x40
|
||||||
|
|
||||||
void beep(unsigned iTone, unsigned iDlit);
|
void beep(unsigned iTone, unsigned iDlit);
|
||||||
|
|
||||||
int main(void) {
|
void delay(unsigned int ms)
|
||||||
|
{
|
||||||
|
usleep(ms * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
long int lCnt = 0;
|
long int lCnt = 0;
|
||||||
int iA = 0x1234;
|
int iA = 0x1234;
|
||||||
|
|
||||||
char *pT = (char *)0x46C;
|
char *pT = (char *)0x46C;
|
||||||
printf("\n\n");
|
printf("\nПечатаем 10 раз значение байта с известным адресом\n");
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
printf(" \n %d ", *pT);
|
printf(" \n %d ", *pT);
|
||||||
printf("\n\n");
|
printf("\n Для продолжения нажмите любую клавишу \n");
|
||||||
getch();
|
system("pause"); // Ждем нажатия клавиши
|
||||||
|
|
||||||
printf("\n <EFBFBD><EFBFBD>⠥<EFBFBD> ᮤ<>ন<EFBFBD><E0A6A8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>ᮬ 40 <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>㭪樨 <20><> \n");
|
printf("\n Читаем содержимое порта с адресом 40 с помощью функции Си \n");
|
||||||
printf("\n <EFBFBD><EFBFBD><EFBFBD> <20><>室<EFBFBD> <20><> 横<><E6A8AA> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \n");
|
printf("\n Для выхода из цикла - нажмите любую клавишу \n");
|
||||||
|
|
||||||
while (bioskey(1) == 0) {
|
while (bioskey(1) == 0) {
|
||||||
printf(" \n <EFBFBD><EFBFBD><EFBFBD><EFBFBD>40 = %d ", inp(PortCan0));
|
printf("\n Порт40 = %d", inp(PortCan0));
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
getch();
|
system("pause");
|
||||||
printf("\n <EFBFBD><EFBFBD>⠥<EFBFBD> ᮤ<>ন<EFBFBD><E0A6A8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>ᮬ 40 <20><>ᥬ<EFBFBD><E1A5AC><EFBFBD> \n");
|
printf("\n Читаем содержимое порта с адресом 40 ассемблером \n");
|
||||||
|
|
||||||
while (bioskey(1) == 0) {
|
while (bioskey(1) == 0) {
|
||||||
asm {
|
asm {
|
||||||
@ -35,27 +38,32 @@ int main(void) {
|
|||||||
in al,0x40
|
in al,0x40
|
||||||
}
|
}
|
||||||
unsigned char Tmm = _AL;
|
unsigned char Tmm = _AL;
|
||||||
asm pop ax delay(500);
|
asm pop ax
|
||||||
printf(" \n <20><><EFBFBD><EFBFBD>40 = %d ", Tmm);
|
delay(500);
|
||||||
|
printf("\n Порт40 = %d", Tmm);
|
||||||
}
|
}
|
||||||
getch();
|
system("pause");
|
||||||
printf("\n <EFBFBD><EFBFBD><EFBFBD> <20>த<EFBFBD><E0AEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \n ");
|
printf("\n Для продолжения - нажмите любую клавишу \n");
|
||||||
getch();
|
system("pause");
|
||||||
|
|
||||||
long far *pTime = (long *)0x46C;
|
long *pTime = (long *)0x46C;
|
||||||
while (bioskey(1) == 0) {
|
while (bioskey(1) == 0) {
|
||||||
printf("\n %ld", *pTime);
|
printf("\n %ld", *pTime);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
getch();
|
system("pause");
|
||||||
|
|
||||||
int Time;
|
int Time;
|
||||||
while (bioskey(1) == 0) {
|
while (bioskey(1) == 0) {
|
||||||
asm push ds asm push si
|
asm push ds
|
||||||
|
asm push si
|
||||||
asm mov ax,
|
asm mov ax, 40h
|
||||||
40h asm mov ds, ax asm mov si, 0x6C asm mov ax, [ds : si] asm mov Time,
|
asm mov ds, ax
|
||||||
ax asm pop si asm pop ds
|
asm mov si, 0x6C
|
||||||
|
asm mov ax, [ds : si]
|
||||||
|
asm mov Time, ax
|
||||||
|
asm pop si
|
||||||
|
asm pop ds
|
||||||
|
|
||||||
printf("\n %d", Time);
|
printf("\n %d", Time);
|
||||||
delay(300);
|
delay(300);
|
||||||
@ -64,7 +72,8 @@ int main(void) {
|
|||||||
beep(400, 200);
|
beep(400, 200);
|
||||||
for (lCnt = 0; lCnt < 1000000; lCnt++) {
|
for (lCnt = 0; lCnt < 1000000; lCnt++) {
|
||||||
a1:
|
a1:
|
||||||
asm { mov ax,iA
|
asm {
|
||||||
|
mov ax,iA
|
||||||
mov ax,iA
|
mov ax,iA
|
||||||
mov ax,iA
|
mov ax,iA
|
||||||
mov ax,iA
|
mov ax,iA
|
||||||
|
|||||||
Reference in New Issue
Block a user