Example 5 22 a switch is connected to pin p17 and an

This preview shows page 48 - 51 out of 51 pages.

Example 5-22 A switch is connected to pin P1.7 and an LED to pin P2.0. Write a program to get the status of the switch and send it to the LED.
Example 5-23 RAM bit location 12H holds the status of whether there has been a phone call or not. If it is high, it means there has been a new call since it was checked the last time .Write a program to display “New Messages” on a LCD if bit RAM 12H is high. If it is low, the LCD should say “No New Messages ” Solution PHONBIT BIT 12H ORG 400H MOV C,PHONBIT YES_MG: DB “New Messages” ,0 JNC NO MOV DPTR,#400H No_MG: DB “No New Messages” ,0 LCALL DISPLAY SJMP EXIT NO: MOV DPTR,#420H LCALL DISPLAY EXIT:
EQU directive Use the EQU to assign addresses Defined by names, like P1.7 or P2 Defined by addresses, like 97H or 0A0H
Example 5-24 A switch is connected to pin P1.7. Write a program to check the status of the switch and make the following decision.(a) If SW = 0, send “NO” to P2 (b) If SW = 1, send “YES“ to P2 Solution: SW EQU P1.7 SJMP HERE MYDATA EQU P2 END HERE: MOV C,SW JC OVER MOV MYDATA,#’N’ MOV MYDATA,#’O’ SJMP HERE OVER: MOV MYDATA,#’Y’ MOV MYDATA,#’E’ MOV MYDATA,#’S’

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture