0% found this document useful (0 votes)
8 views4 pages

Keypad

The document contains three MASM programs for the 8086 microprocessor, each demonstrating different functionalities with hardware interfaces. The first program interfaces with the 8279 keyboard, continuously reading key inputs. The second program uses the 8255 for key scanning, while the third program displays messages and captures a key press using DOS interrupts.

Uploaded by

21012ec045
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Keypad

The document contains three MASM programs for the 8086 microprocessor, each demonstrating different functionalities with hardware interfaces. The first program interfaces with the 8279 keyboard, continuously reading key inputs. The second program uses the 8255 for key scanning, while the third program displays messages and captures a key press using DOS interrupts.

Uploaded by

21012ec045
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MASM Program (8086 + 8279)

DATA SEGMENT

KEY DB ?

DATA ENDS

CODE SEGMENT

ASSUME CS:CODE, DS:DATA

CMD_PORT EQU 80H

DATA_PORT EQU 81H

START:

MOV AX, DATA

MOV DS, AX

; Initialize 8279 - Keyboard Mode

MOV AL, 23H

OUT CMD_PORT, AL

READ_KEY:

; Read key from 8279

IN AL, DATA_PORT

MOV KEY, AL

JMP READ_KEY

CODE ENDS

END START

MASM Program (8086 + 8255)


DATA SEGMENT
KEY DB ?

DATA ENDS

CODE SEGMENT

ASSUME CS:CODE, DS:DATA

PORTA EQU 80H

PORTB EQU 81H

CTRL EQU 83H

START:

MOV AX, DATA

MOV DS, AX

; Initialize 8255

MOV AL, 82H

OUT CTRL, AL

SCAN:

MOV AL, 0FEH ; Activate column 0

OUT PORTA, AL

IN AL, PORTB ; Read rows

CMP AL, 0FFH

JE SCAN ; No key pressed

MOV KEY, AL ; Store key pattern

JMP SCAN

CODE ENDS

END START
MASM Program (WORKING)
DATA SEGMENT

MSG1 DB 10,13,"Press any key: $"

MSG2 DB 10,13,"You pressed: $"

KEY DB ? ; Stores pressed key

DATA ENDS

CODE SEGMENT

ASSUME CS:CODE, DS:DATA

START:

MOV AX, DATA

MOV DS, AX

; Display "Press any key"

LEA DX, MSG1

MOV AH, 09H

INT 21H

; Read a key from keyboard

MOV AH, 01H

INT 21H

MOV KEY, AL ; Store key in memory

; Display "You pressed"

LEA DX, MSG2

MOV AH, 09H

INT 21H
; Display the stored key

MOV DL, KEY

MOV AH, 02H

INT 21H

; Exit program

MOV AH, 4CH

INT 21H

CODE ENDS

END START

You might also like