Скачиваний:
34
Добавлен:
15.09.2014
Размер:
1.39 Кб
Скачать
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <string.h>

#pragma inline

void print_symbol(char symbol,int mode)
{
	switch(mode)
	{
		case 49:
				asm{
					mov  ah,5
					mov  dl,symbol
					int 0x21
				}
				break;
		case 50:
				asm{
					mov  ah,2
					mov  dx,0
					int  0x17
					test ah,01101001b
					jnz  ERROR
				}
				if(symbol=='\x0C')
				{
					asm{
						mov  ah,1	
						mov  dx,0
						int  0x17
					}
				}
				else
				{
					asm{
						mov  ah,0	
						mov  al,symbol
						mov  dx,0	
						int  0x17
					}
				}			
				asm{
					jmp NOTERROR
				}
				ERROR:
					printf("Printer is not ready\n");
					getch();
				NOTERROR:
				break;
	}
}
void print_string(char *str,int mode)
{
	int i = 0;
	for (i = 0; i < strlen(str); i++)
	{
		print_symbol(str[i],mode);
	}
}
void main()
{
	char mode;
	char str1[10]= "Test";
	char str2[35] = "Stroka napechatana";
	char str3[15] = "bez oshibok :)";
	clrscr();
	printf("Choose mode of working: ");
	printf("\n1 - using 21h interrupt\n2 - using 17h interrupt");
	mode = getch();

	print_symbol('\x0C',mode);
	print_string(str1,mode);
	print_symbol('\x0A',mode);
	print_symbol('\x0D',mode);
	print_string(str2,mode);
	print_symbol('\x0A',mode);
	print_symbol('\x0D',mode);
	print_string(str3,mode);
	print_symbol('\x0C',mode);
}