This is a computer graphics lab program. This is an animation program in which a car can be moved using the arrow keys on keyboard. The car should move forward when right arrow key is pressed and backward when left arrow key is pressed. The car accelerates as the right arrow key is pressed. When it is released the car decelerates. The program uses the graphics library graphics.h. This program works well in the turbo c compiler with Borland graphics interface (BGI). The output of the program is as follows:
The program is as follows:
Search This Blog
Showing posts with label keyboard. Show all posts
Showing posts with label keyboard. Show all posts
C Program to Display SCAN and ASCII Codes of Keys on Keyboard Using 8086 Interrupt
![]() |
Output (ASCII and SCAN code) when a is pressed |
The interrupt stores scan code in higher byte of accumulator and ASCII code in lower byte of accumulator.
8086 interrupt number 16h (hexadecimal) to read a keystroke from keyboard. The condition for this interrupt is that the higher byte of accumulator (AH) should be 00h.
#include<stdio.h>
#include<dos.h>
#include<conio.h>
void main()
{
union REGS inregs,outregs; //declaring 2 register files
clrscr();
inregs.h.ah=0x0; //pre-requisite for desired operation of interrupt 16h
int86(0x16,&inregs,&outregs); //calling interrupt 16h
printf("\nScan Code :%d\nASCII code:%d\n",outregs.h.ah,outregs.h.al);
getch();
}
Subscribe to:
Posts (Atom)