Saturday, August 13, 2011

Assume that the lower three bits of P1 are connected to three switches. Write a program to send the following ASCII characters to P2 based on the status of the switches.


;
; SWITCH STATUS AS FOLLOWS
; 000 ‘0’
; 001 ‘1’
; 010 ‘2’
; 011 ‘3’
; 100 ‘4’
; 101 ‘5’
; 110 ‘6’
; 111 ‘7’
;
;
; WE WILL DEFINE BYTE LATER IN THE PROGRAM 


ORG 0000H ;
MOV DPTR, 300H ;
MOV A, P1 ; GET STATUS OF P1
ANL A, 07H ; MASK ALL BUT LOWER 3 BITS
MOV A, @A+DPTR  ; GET CORRESPONDING VALUE
MOV P2, A ; MOVE VALUE TO P2 DISPLAY IT




ORG 0300H  ;
DB '0','1','2','3','4','5','6','7';
END

No comments:

Post a Comment