INCLUDE REG_51.PDF
LOAD1EQUP1.0
LOAD2EQUP1.1
LOAD3EQUP1.2
LOAD4EQUP1.3
LOAD5EQUP1.4
LOAD6EQUP1.5
LOAD7EQUP1.6
LOAD8EQUP1.7
DSEG ; This is internal data memory
ORG 20H ; Bit adressable memory
MOBILE:DS3
COUNTER:DS1
CSEG ; Code begins here
; ---------==========----------==========---------=========---------
; Main routine. Program execution starts here.
; ---------==========----------==========---------=========---------
ORG 00H ; Reset
AJMP MAIN
ORG 0023H
AJMP SERIAL
; ---------==========----------==========---------=========---------
MAIN: MOV SP,#40H
MOV TMOD,#20H;initilize serial port
MOV TH1,#0FDH;Slect 9600 baud rate
MOV SCON,#50H
MOV IE,#10010000B
SETB TR1;start timer
MOV COUNTER,#00H
MOV P1,#00H
AJMP $
;**************************************************************************
SERIAL:
JB TI,TRAS1
MOV A,SBUF
CJNE A,#'A',DOWNW
MOV COUNTER,#00H
AJMP DOWN1
TRAS1:AJMP TRAS
DOWNW:CJNE A,#0AH,DOWNW1
CALL DEVICE_DECODE
AJMP DOWN1
DOWNW1:MOV A,COUNTER
CJNE A,#01H,SD1
MOV MOBILE,SBUF
AJMP DOWN1
SD1:CJNE A,#02H,DOWN1
MOV MOBILE+1,SBUF
DOWN1:INC COUNTER
CLR RI
RETI
TRAS: CLR TI
RETI
;**************************************************************************
DEVICE_DECODE:
MOV A,MOBILE;LOAD 1
CJNE A,#31H,SDF1
MOV A,MOBILE+1
CJNE A,#31H,SDF2
SETB LOAD1
AJMP SDF1
SDF2:CJNE A,#32H,SDF1
CLR LOAD1
SDF1:
MOV A,MOBILE;LOAD 2
CJNE A,#32H,SDF11
MOV A,MOBILE+1
CJNE A,#31H,SDF21
SETB LOAD2
AJMP SDF11
SDF21:CJNE A,#32H,SDF11
CLR LOAD2
SDF11:
MOV A,MOBILE;LOAD 3
CJNE A,#33H,SDF12
MOV A,MOBILE+1
CJNE A,#31H,SDF22
SETB LOAD3
AJMP SDF12
SDF22:CJNE A,#32H,SDF12
CLR LOAD3
SDF12:
MOV A,MOBILE;LOAD 4
CJNE A,#34H,SDF14
MOV A,MOBILE+1
CJNE A,#31H,SDF24
SETB LOAD4
AJMP SDF14
SDF24:CJNE A,#32H,SDF14
CLR LOAD4
SDF14:
MOV A,MOBILE;LOAD 5
CJNE A,#35H,SDF15
MOV A,MOBILE+1
CJNE A,#31H,SDF25
SETB LOAD5
AJMP SDF15
SDF25:CJNE A,#32H,SDF15
CLR LOAD5
SDF15:
MOV A,MOBILE;LOAD 6
CJNE A,#36H,SDF16
MOV A,MOBILE+1
CJNE A,#31H,SDF26
SETB LOAD6
AJMP SDF16
SDF26:CJNE A,#32H,SDF16
CLR LOAD6
SDF16:
MOV A,MOBILE;LOAD 7
CJNE A,#37H,SDF17
MOV A,MOBILE+1
CJNE A,#31H,SDF27
SETB LOAD7
AJMP SDF17
SDF27:CJNE A,#32H,SDF17
CLR LOAD7
SDF17:
MOV A,MOBILE;LOAD 8
CJNE A,#38H,SDF18
MOV A,MOBILE+1
CJNE A,#31H,SDF28
SETB LOAD8
AJMP SDF18
SDF28:CJNE A,#32H,SDF18
CLR LOAD8
SDF18:
MOV A,MOBILE;LOAD 8
CJNE A,#39H,SDF19
MOV P1,#0FFH
SDF19:
MOV A,MOBILE;LOAD 8
CJNE A,#30H,SDF10
MOV P1,#00H
SDF10:
RET
end
Sent from my Nokia phone
No comments:
Post a Comment