Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/freehos1/public_html/projectus/core/open_close_dbase_connection.php on line 0

Deprecated: Function split() is deprecated in /home/freehos1/public_html/projectus/Railway-anticollision-system/index.php(0) : eval()'d code on line 22

Deprecated: Function split() is deprecated in /home/freehos1/public_html/projectus/Railway-anticollision-system/index.php(0) : eval()'d code on line 35

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/freehos1/public_html/projectus/scripts/get_ad_type_position.php on line 0

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/freehos1/public_html/projectus/scripts/load_ads.php on line 0

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/freehos1/public_html/projectus/scripts/sponsor_found.php on line 0

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/freehos1/public_html/projectus/scripts/load_links.php on line 0

Deprecated: Function split() is deprecated in /home/freehos1/public_html/projectus/Railway-anticollision-system/index.php(0) : eval()'d code on line 161

Deprecated: Function split() is deprecated in /home/freehos1/public_html/projectus/Railway-anticollision-system/index.php(0) : eval()'d code on line 164

Deprecated: Function split() is deprecated in /home/freehos1/public_html/projectus/Railway-anticollision-system/index.php(0) : eval()'d code on line 167
assembly language programming for train anticollision
projectus.freehost7.com:UG and PG level projects,mini projects and many more here ...







 

ASSEMBLY LANGUAGE PROGRAMMING

ASSEMBLY LANGUAGE: Basic software for some of the important input, output and delay hardware is described here. Memory mapped I/O is used for connecting I/O clips and microcontroller. For this reason we have used instruction such as MOV X to access the 8255.

FOR INPUT: Whenever it is required to read any input port, we assign that port address to DPTR. Then by using MOV X instruction, we copy the content of that specified port into accumulator and check the particular bit. The copy of the input is saved in memory location (scratch pad RAM,30-7F) for other purposes.

FOR OUTPUT: To switch on different LEDís and LCDís, siren corresponding bit pattern is loaded into the accumulator. Again by MOV X instruction, we assign that bit pattern into a particular port address from where we can output different signals.

FOR DELAY: We have calculated time delay based on crystal frequency of 8051 which is 12MHZ.In 8051 one machine cycles lasts 12oscillator periods. To calculate machine cycles, We take 1/12 of the crystal frequency. Since we are using nested loop, this time is approximated.

 

; ----------------------Declaration Part-----------------------

ACC DATA 0E0H

B DATA 0F0H

P0 DATA 80H

P1 DATA 90H

P2 DATA 0A0H

DPL DATA 82H

DPH DATA 83H

IE DATA 0A8H

TMOD DATA 89H

TH0 DATA 8CH

TL0 DATA 8AH

TH1 DATA 8DH

TL1 DATA 8BH

TCON DATA 88H

DEC_RESULT EQU 068H

ASCII_RESULT EQU 06CH

; ------------------------Program----------------------------------

ORG 00H ; MAIN ROUTINE

; -------------------8255 Initialization -----------------------------------

MOV A,#80H

MOV DPTR,#8203H ;2CR Addr(PA,PB,PC=O/P)

MOVX @DPTR,A

MOV A,#9BH

MOV DPTR,#8103H ;3CR Addr(PA,PB,PC=I/P)

MOVX @DPTR,A

MOV A,#8AH

MOV DPTR,#8003H ;1CR Addr(PA,PCL=O/P & PB,PCH=I/P)

MOVX @DPTR,A

; --------------------Delay 2 Seconds ---------------------------------

LCALL DELAY_2SECS

; ----------- Project Title Display--------------------------

LCALL PROJECT_TITLE_DISPLAY1

LCALL DELAY_2SECS

LCALL PROJECT_TITLE_DISPLAY2

LCALL DELAY_2SECS

LCALL STUDENTS_NAME_DISPLAY1

LCALL DELAY_2SECS

LCALL STUDENTS_NAME_DISPLAY2

LCALL DELAY_2SEC

 

 

PROJECT_TITLE_DISPLAY1:

MOV A,#38H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#0EH

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#01H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#84H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'M'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'I'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'C'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'R'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'O'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'C'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'O'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'N'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'T'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'R'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'O'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'L'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'L'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'E'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'R'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#0C0H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'B'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'A'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'S'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'E'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'D'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

RET

PROJECT_TITLE_DISPLAY2:

MOV A,#38H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#0EH

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#01H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#84H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'A'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'N'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'T'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'I'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'C'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#' O'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'L'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'I'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'S'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'I'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'O'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'N'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#0C0H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'S'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'Y'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'S'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'T'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'E'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'M'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

RET

; ----------------------Project Participants---------------------------

STUDENTS_NAME_DISPLAY1:

MOV A,#38H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#0EH

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#01H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#84H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'R'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'A'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'M'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'U'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#0C0H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'D'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'E'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'V'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'E'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'N'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'D'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'R'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'A'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

RET

STUDENTS_NAME_DISPLAY2:

MOV A,#38H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#0EH

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#01H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#84H

LCALL COMNWRT

LCALL DELAY_2MS

MOV A,#'S'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'A'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'R'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'A'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'T'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'H'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

MOV A,#'I'

LCALL DATAWRT

LCALL DELAY_100_MICROSEC

RET

--------------------------Train Operation--------------------------

BACK: NOP

MOV DPTR,#8101H

MOVX A,@DPTR

MOV 30H,A

JB ACC.2,NEXT1

JB ACC.3,NEXT2

NEXT1:

SETB 00H

LJMP HERE1

NEXT2:

CLR 00H

HERE1:

JB ACC.2,NEXT3

JB ACC.5,NEXT4

NEXT3:

SETB 01H

LJMP HERE2

NEXT4:

CLR 01H

HERE2:

JB ACC.4,NEXT5

JB ACC.5,NEXT6

NEXT5:

SETB 02H

LJMP HERE3

NEXT6:

CLR 02H

HERE3:

JB ACC.4,NEXT7

LCALL STATION2

JB ACC.3,NEXT8

NEXT7:

SETB 03H

LJMP HERE4

NEXT8:

CLR 03H

HERE4:

LCALL STATION2

JB ACC.2,NEXT9

LCALL STATION2

JB ACC.3,NEXT10

NEXT9:

SETB 04H

LJMP HERE5

NEXT10:

CLR 04H

HERE5:

LCALL STATION2

JB ACC.2,NEXT11

LCALL STATION2

JB ACC.5,NEXT12

NEXT11:

SETB 05H

LJMP HERE6

NEXT12:

CLR 05H

HERE6:

LCALL STATION2

JB ACC.4,NEXT13

LCALL STATION2

JB ACC.5,NEXT14

NEXT13:

SETB 06H

LJMP HERE7

NEXT14:

CLR 06H

HERE7:

LCALL STATION2

JB ACC.4,NEXT15

LCALL STATION1

JB ACC.3,NEXT16

NEXT15:

SETB 07H

LJMP HERE8

NEXT16:

CLR 07H

HERE8:

LCALL STATION1

JB ACC.0,LEVEL1

LJMP LEVEL4

LEVEL1:

JNB 00H,LEVEL2

LJMP LEVEL4

LEVEL2:

JNB 01H,LEVEL3

LJMP LEVEL4

LEVEL3:

SETB 08H

CLR 09H

LJMP LEVEL5

LEVEL4:

CLR 08H

SETB 09H

LEVEL5:

LCALL STATION1

JB ACC.1,LEVEL6

LJMP LEVEL9

LEVEL6:

JNB 02H,LEVEL7

LJMP LEVEL9

LEVEL7:

JNB 03H,LEVEL8

LJMP LEVEL9

LEVEL8:

SETB 0AH

CLR 0BH

LJMP LEVEL10

LEVEL9:

CLR 0AH

SETB 0BH

LEVEL10:

LCALL STATION2

JB ACC.0,LEVEL11

LJMP LEVEL14

LEVEL11:

JNB 04H,LEVEL12

LJMP LEVEL14

LEVEL12:

JNB 05H,LEVEL13

LJMP LEVEL14

LEVEL13:

SETB 0CH

CLR 0DH

LJMP LEVEL15

LEVEL14:

CLR 0CH

SETB 0DH

LEVEL15:

LCALL STATION2

JB ACC.1,LEVEL16

LJMP LEVEL19

LEVEL16:

JNB 06H,LEVEL17

LJMP LEVEL19

LEVEL17:

JNB 05H,LEVEL18

LJMP LEVEL19

LEVEL18:

SETB 0EH

CLR 0FH

LJMP LEVEL20

LEVEL19:

CLR 0EH

SETB 0FH

LEVEL20:

MOV A,21H

MOV DPTR,#8200H

MOVX @DPTR,A

LJMP BACK

; --------------------------------------Subroutines------------------------------------

STATION1:

MOV DPTR,#8101H

MOVX A,@DPTR

MOV 30H,A

RET

STATION2:

MOV DPTR,#8102H

MOVX A,@DPTR

MOV 31H,A

RET

COMNWRT:

MOV DPTR,#8000H

MOVX @DPTR,A

MOV DPTR,#8002H

MOV A,#00001000B

MOVX @DPTR,A

LCALL DELAY_100_MICROSEC

MOV DPTR,#8002H

MOV A,#00000000B

MOVX @DPTR,A

RET

DATAWRT:

MOV DPTR,#8000H

MOVX @DPTR,A

MOV DPTR,#8002H

MOV A,#00001010B

MOVX @DPTR,A

LCALL DELAY_100_MICROSEC

MOV DPTR,#8002H

MOV A,#00000010B

MOVX @DPTR,A

RET

; -----------------------Delay Subroutines-------------------------------

DELAY_100_MICROSEC:

NOP ; 100MICROSEC

MOV R1, #3

HR13: MOV R0,#6

HR15: DJNZ R0, HR15

DJNZ R1, HR13

RET

DELAY1:

MOV R0,#5 ;1 MILLISEC

HR2:MOV R1,#33

HR1:DJNZ R1,HR1

DJNZ R0,HR2

RET

DELAY1A:

MOV R0,#30

HR2A:MOV R1,#95

HR1A:DJNZ R1,HR1A

DJNZ R0,HR2A

RET

DELAY_2SECS:

MOV R1,#70

AGAIN:MOV R2,#70

ONCE:MOV R3,#50

HR:NOP

NOP

DJNZ R3,HR

DJNZ R2,ONCE

DJNZ R1,AGAIN

RET

DELAY:

NOP ;100MICROSEC

MOV R1,#3

HR131:MOV R0,#6

HR151:DJNZ R0,HR151

DJNZ R1,HR131

RET

;Delay Program for 2ms

DELAY_2MS:

MOV R3,#10

HR6:MOV R4,#68

HR7:DJNZ R4,HR7

DJNZ R3,HR6

RET

END