Friday, 27 April 2012

FYP Week 14 - Results and Analysis

Hello everyone,

Hope everyone is having a blast! I am so happy that presentation for FYP 2 is over.... I had update my post every week for the past 14 week and today's entry will be my last. I hope everyone enjoys my blog and hope to see you guys next time. 

Last Tuesday, dated 24 April 2012, I have gone finished my presentation for my final year project (FYP). I was assessed by Mdm Naszariah, lecturer from medical section and Ms Syaira from telecommunication section. Thanks to both Mdm Nasza and Ms Syaira for assessing me. Next a very thousand thanks to Mdm Zaba and Mr. Faizal for helping me on my FYP till the very end and to my family as well as to all my friends that supports me along the way.

Now lets see the outcome of my project.  :)

 Part 1: Results and Analysis

I am using the analogue trainer to supply 12 DC Volts to my project as well as 6 DC Volts for my valve and 6 DC Volts for my DC motor. Hehe

Figure 1: Home Patient Monitor

Home Patient Monitor is programmed to have three modes where Mode 1 (switch 1) is the body temperature measurement, Mode 2 (switch 2) is the Blood Pressure measurement and finally Mode 3 (switch 3) is the Heart Rate measurement. These 3 Modes are selection to determine which measurement want to be taken by the user. Below are the result images taken:

Figure 2: Select mode option

 Figure 3: Selecting Mode 1 (switch 1) for body temperature measurement

 Figure 4: Abnormal body temperature reading

Figure 5: Normal body temperature reading

 Figure 6: Selecting Mode 2 for Blood Pressure measurement

 Figure 7: Blood Pressure reading (Systolic/ Diastolic)

Figure 8: Selecting Mode 3 for Heart Rate (beats per minutes/ bpm) measurement

 Figure 9: Heart Rate reading

Next is the programming of the project. The programming of this project is divide into 2 part, namely using Visual Basics and Assembly Language. Visual Basics is use as a user interface to help user to transmit data from hardware to the computer and to display the result for further analysis. Next, is the Assembly Language which is use to program the microcontroller (PIC16F887A) and to control all other function of the project.

Let's have a look at the programming.............  :)  
Visual Basics at Part 2 and Assembly Language at Part 3.....Huhu

Part 2: Visual Bascis Program (User Interface)

Dim gLogFile$
Dim bLog As Boolean
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Dim stage As Integer
Dim hd_Version As String
Dim hd_Beat As Boolean
Dim hd_draw As Boolean
Dim hd_alert As Boolean
Dim hd_active As Boolean
Dim hd_range As Integer
Dim chart_cx As Integer
Dim beat_RATE As Integer
Const he_Beat = 3000
Const he_Warn = 500
Const SysName = "HeartBeat Monitoring System "
Const sign_Warn = "WARNING : NO HEARTBEAT"
Const sign_Normal = "NORMAL"
Const sign_Abnormal = "OUT OF NORMAL RANGE"
Const color_BLACK = &H0&
Const color_WHITE = &HFFFFFF
Const color_TIP = &H80000018
Const color_BLUE = &H80000013
Const color_RED = &HC0&
Const ERR_RATE = 8          ' rate different
Private Sub Command3_Click()
Dim buffer As String
Dim cul_beat As Integer
Dim Rate As Integer
hd_Beat = True
hd_draw = True
'BeatCal.Text = Val(BeatCal.Text) + 1
SampleTime.Enabled = True
End Sub


Private Sub Command12_Click()
Dim tmpVar As String
'lstLateRecord.Width = Form1.Width - 100
lstLateRecord.Clear
Open App.Path & "\Temp.log" For Input As #1
Do Until EOF(1)
Line Input #1, tmpVar
lstLateRecord.AddItem (tmpVar)
Loop
Close #1
End Sub


Private Sub Command2_Click()
MSComm1.Settings = "9600,n,8,1"
On Error GoTo comError
If MSComm1.PortOpen <> False Then
MSComm1.PortOpen = False
End If
MSComm1.CommPort = PORT.Text
MSComm1.PortOpen = True
Exit Sub
comError:
MsgBox "Unable to open Com Port " & PORT
End Sub


Private Sub Command4_Click()
MSComm1.Output = "DBON"
End Sub


Private Sub Command5_Click()
BLOOD.Visible = False
BPM.Visible = False
TEMP.Visible = False
End Sub


Private Sub Form_Deactivate()
Unload Me
End Sub


Private Sub Form_Load()
'Declare myfilename and myfilename2 as strings and specify Log files
Dim myfilename As String
Dim myfilename2 As String
'Make sure the log files are there, if not, create them.
Dim tmpVar As String

BLOOD.Visible = False
BPM.Visible = False
TEMP.Visible = False
End Sub


Private Sub MSComm1_OnComm()
Dim i As Integer
Dim j As Integer
Dim iTmp1 As Integer, iTmp2 As Integer, iTmp3 As Integer
Dim s1, S2 As String
Select Case MSComm1.CommEvent
Case comEvReceive
s1 = MSComm1.Input
               For i = 1 To Len(s1) Step 1
                    S2 = Mid$(s1, i, 1)
                    j = Asc(S2)
                    If (j = 7) Then ' BELL = ERROR!
                    Debug.Print "  ";
                    RX.Text = RX.Text
                    iFlagACK = 2
                    Call SPLITTER
               ElseIf (j = 13) Then ' CR = OK
                    Debug.Print "  "
                    RX.Text = RX.Text + S2
                    iFlagACK = 1
                    Call SPLITTER
                   'Timer4.Enabled = True
                Else
                    Debug.Print "                                            ";
                    RX.Text = RX.Text + S2
                    Call SPLITTER
                   'Timer4.Enabled = True
                End If
            Next i
    End Select
End Sub

Private Sub TEST_Click()
End Sub

Private Sub ONOFF_DragDrop(Source As Control, X As Single, Y As Single)
End Sub

Private Sub Timer1_Timer()
If MSComm1.PortOpen = False Then
    SerialStatus.Caption = "NOT CONNECTED"
    Timer2.Interval = 0
    SerialStatus.ForeColor = &H808080
End If
If MSComm1.PortOpen = True Then
    SerialStatus.Caption = "CONNECTED"
    Timer2.Interval = 100
    'vall = Val(STORE.Text)
    SerialStatus.ForeColor = &HFF0000
End If
    'set time and date
    lblDate.Caption = Format(Now, "dd/mm/yyyy")
    lblTime.Caption = Format(Now, "hh:mm:ss")
End Sub


Private Sub txtFilt_Change()
If Val(txtFilt.Text) < 1 Then txtFilt.Text = "1"
End Sub


Private Sub SPLITTER()
On Error Resume Next
Dim strInputString      As String
    Dim strFilterText       As String
    Dim astrSplitItems()    As String
    Dim astrFilteredItems() As String
    Dim strFilteredString   As String
    Dim intX    As Integer
    Dim t As String
    strInputString = RX.Text
    astrSplitItems = Split(strInputString, ",")
    For intX = 0 To UBound(astrSplitItems)
    RXData(intX).Text = astrSplitItems(intX)
    Next
End Sub


Private Sub Timer3_Timer()
Call Logging
End Sub

Private Sub Logging()
    If RXData(0) = "X" Then
    If RXData(1) = "1" Then
       MODE.Text = "BODY TEMPERATURE"
       BLOOD.Visible = False
       BPM.Visible = False
       TEMP.Visible = True
    End If
    If RXData(1) = "2" Then
       MODE.Text = "BPM TEST"
       BLOOD.Visible = False
       BPM.Visible = True
       TEMP.Visible = False
    End If
    If RXData(1) = "3" Then
       MODE.Text = "BLOOD TEST"
       BLOOD.Visible = True
       BPM.Visible = False
       TEMP.Visible = False
     End If
     End If
If RXData(0) = "P" Then
    PRESSURE.Text = RXData(1)
End If
If RXData(0) = "B" Then
    BloodRE.Text = RXData(1) & "/" & RXData(2)
End If
If RXData(0) = "T" Then
    TempRE.Text = RXData(1)
End If
If RXData(0) = "H" Then
    BPMRE.Text = RXData(1)
End If
RX.Text = ""
End Sub


Private Sub UPDATE()
End Sub
Private Sub txtScale_Change()
If Val(txtScale.Text) <= 0 Then txtScale.Text = "1"
For i = 0 To 2
    Label10(i).Caption = txtScale.Text
    Label11(i).Caption = "-" & txtScale.Text
Next i
End Sub
Private Function Arcsin(X As Single)
Dim tmp As Single
    tmp = -X * X + 1
    If tmp < 0 Then tmp = -tmp
    tmp = Sqr(tmp)
    If tmp <> 0 Then
    tmp = Atn(X / tmp)
    Else
    tmp = pi / 2
    If X < 0 Then tmp = -tmp
    End If
    Arcsin = tmp
End Function
Sub openCom(PORT As Integer)
On Error GoTo comError
If MSComm1.PortOpen <> False Then
    MSComm1.PortOpen = False
End If
'MSComm1.CommPort = PORT.Text
MSComm1.PortOpen = True
Exit Sub
comError:
MsgBox "Unable to open Com Port " & PORT
End Sub


Private Sub Command6_Click()
Call Logging
End Sub



Part 3: Full Assembly Program (PIC16F887A)

;Project: HOME PATIENT MONITOR 
;By Idriah Safriza Bte Idris Chin (51216110284)
;Universiti Kuala Lumpur British Malaysian Institute (UniKL BMI) 
;Project Supervisor: Mdm Zabariah Binti Zakaria

;--------------------------------------------------------------------------------------------------------------Home Patient Monitor----------------------------------------------------------------------------------------------------------------------

                                                                                                list                   p=pic16f877a
                                                                                                include            p16f877a.inc
                                                                                                __config          0x1E72
                                                                                                errorlevel        -302                                                               ;Suppress bank warning
                                                                       
                                                                                                CBlock 0x20
                                                                                                N                                                                                         ; Delay registers
                                                                                                N1                                                                                       ; Delay registers
                                                                                                count1                                                                                  ; Delay registers
                                                                                                counta                                                                                 ; Delay registers
                                                                                                countb                                                                                 ; Delay registers
                                                                                                countc                                                                                  ; Delay registers
                                                                                                FIXDELAY                                                                             ; Delay registers
                                                                                                visdelay                                                                                ; Delay registers
                                                                                                dataL
                                                                                                COUNTER1
                                                                                                COUNTER2
                                                                                                temp_dig
                                                                                                rmng_num                                                                            ; Digit breaker registers
                                                                                                quotient
                                                                                                temp_num
                                                                                                rmng_num2                                                                             ; Digit breaker registers
                                                                                                quotient2
                                                                                                temp_num2
                                                                                                ANALOGL                                                                            ; ANALOG variable registers
                                                                                                ANALOGH
                                                                                                ANALOGfract
                                                                                                Bigest
                                                                                                digitANALOGdata0                                                             ; ANALOG data digit registers
                                                                                                digitANALOGdata1                                                             
                                                                                                digitANALOGdata2                                                            
                                                                                                digitANALOGdataL0                                  
                                                                                                digitANALOGdataL1                                   
                                                                                                digitANALOGdataL2                                  
                                                                                                ANALOGnonfract0                                                                  ; Actual ANALOG digit registers
                                                                                                ANALOGnonfract1                                                                                      
                                                                                                ANALOGnonfract2                                                                                     
                                                                                                ANALOGfract0                                                                                            
                                                                                                ANALOGfract1                                                                     
                                                                                                tempHtrans                                                  
                                                                                                tempLtrans
                                                                                                ANALOGHtrans
                                                                                                ANALOGLtrans
                                                                                                A1
                                                                                                A2
                                                                                                A3
                                                                                                D1
                                                                                                D2
                                                                                                D3
                                                                                                rxtime1
                                                                                                rxtime2
                                                                                                ANALOGL2                                                                               ; ANALOG variable registers
                                                                                                ANALOGH2                                                                                                                         
                                                                                                ANALOGfract2
                                                                                                digitANALOGdata02                                                           ; ANALOG data digit registers
                                                                                                digitANALOGdata12                                                                                   
                                                                                                digitANALOGdata22                                                          
                                                                                                digitANALOGdataL02
                                                                                                digitANALOGdataL12
                                                                                                digitANALOGdataL22
                                                                                                ANALOGnonfract02                                                           ; ANALOG digit registers
                                                                                                ANALOGnonfract12                                                           
                                                                                                ANALOGnonfract22                                                          
                                                                                                ANALOGfract02
                                                                                                ANALOGfract12
                                                                                                ANALOGHtrans2
                                                                                                ANALOGLtrans2
                                                                                                M1
                                                                                                M2
                                                                                                TH
                                                                                                TL
                                                                                                TXSW
                                                                                                TimeOutCounter
                                                                                                TimeOutCounter1
                                                                                                F2
                                                                                                F3
                                                                                                F4
                                                                                                F5
                                                                                                F6
                                                                                                F7
                                                                                                F8
                                                                                                U1
                                                                                                U2
                                                                                                U3
                                                                                                ENDC
                                                                                                org 0x00
                                                                                                nop                                                                                                                                                                 ; Reserved for ICD II.
                                                                                                goto                start

;-----------------------------------------Start---------------------------------------------------

start                                       
                                                                                                call initports                                                                          ; Initialize Ports as output/inputs.
                                                                                                call setupUART
                                                                                                call INITLCD                                                                           ; Initialize LCD
                                                                                                call clrscreen                                                                           ; Clear LCD SCREEN
                                                                                                bcf PORTD,3
                                                                                                bcf PORTC,6
                                                                                                bcf PORTC,7
                                                                                                call SECOND_1                                                                                               ;1s delay before start main program
                                                                                                call SECOND_1                                                                                                                      
                                                                                                call SECOND_1                                                                                                                                              
                                                                                                movlw d'240'
                                                                                                movwf TimeOutCounter
                                                                                                movlw d'3'
                                                                                                movwf TimeOutCounter1
                                                                                                movlw A'0'
                                                                                                movwf A1
                                                                                                movwf A2
                                                                                                movwf A3
                       
StartMain
                                                                                                call DisSelect
                                                                                                call visualdelay
                                               
WaitCMD
                                                                                                btfss PORTC,3
                                                                                                goto TEMP_CHECKx
                                                                                                btfss PORTD,1
                                                                                                goto HR_CHECKx
                                                                                                btfss PORTD,0
                                                                                                goto BP_CHECKx
                                                                                                goto WaitCMD
;-----------------------------------------End of Start--------------------------------------------
                                                                                               
;-------------------------------------------MODE 1------------------------------------------------

TEMP_CHECKx
                                                                                                call SEND_MODE1
                                                                                                call DisMODE1
                                                                                                call SECOND_1
                                                                                                call SECOND_1                                              
TEMP_CHECK                                                                      
                                                                                                call DisLCD
                                                                                                call visualdelay
                                                                                                call Delay_Tx
                                                                                                call SEND_TEMP
                                                                                                call SECOND_1
                                                                                                btfss PORTC,3
                                                                                                goto StartMain
                                                                                                btfss PORTD,1
                                                                                                goto StartMain
                                                                                                btfss PORTD,0
                                                                                                goto StartMain
                                                                                                goto TEMP_CHECK

;----------------------------------------END OF MAIN 1--------------------------------------------

;-------------------------------------------MODE 2------------------------------------------------

HR_CHECKx
                                                                                                call SEND_MODE2
                                                                                                call DisMODE3
                                                                                                call SECOND_1
                                                                                                call SECOND_1

HR_CHECK                           
                                                                                                call clrdata
                                                                                                btfss PORTA,2
                                                                                                goto HR_CHECK

HR_CHECK2
                                                                                                btfsc PORTA,2
                                                                                                goto HR_CHECK2

ReadyCount 
                                                                                                call DECCount
                                                                                                call DelayBPM
                                                                                                btfss PORTA,2
                                                                                                goto ReadyCount
                                                                                                call DisBPM
                                                                                                call visualdelay
                                                                                                btfss PORTC,3
                                                                                                goto StartMain
                                                                                                btfss PORTD,1
                                                                                                goto StartMain
                                                                                                btfss PORTD,0
                                                                                                goto StartMain
                                                                                                goto HR_CHECK
                                                                       
clrdata           
                                                                                                movlw A'2'
                                                                                                movwf A1
                                                                                                movlw A'9'
                                                                                                movwf A3
                                                                                                movwf A2
                                                                                                return
                                                                       
;-----------------------------------------END OF MAIN 2-------------------------------------------

;--------------------------------------------MODE 3------------------------------------------------

BP_CHECKx  
                                                                                                call SEND_MODE3
                                                                                                call DisMODE2
                                                                                                call SECOND_1
                                                                                                call SECOND_1

BP_CHECK    
                                                                                                call DisLCD2
                                                                                                call visualdelay
                                                                                                call Delay_Tx
                                                                                                btfss PORTC,3
                                                                                                goto ONR
                                                                                                btfss PORTD,1
                                                                                                call OFFR
                                                                                                btfss PORTD,0
                                                                                                goto StartMain
                                                                                                goto BP_CHECK

ONR                                                              
                                                                                                bsf PORTD,2
                                                                                                call Delay_Tx
                                                                                                call Delay_Tx
                                                                                                call DisLCD2
                                                                                                call visualdelay
                                                                                                movf ANALOGnonfract1,w
                                                                                                xorlw A'3'
                                                                                                btfss STATUS,Z
                                                                                                goto ONR
                                                                                                call SECOND_1
                                                                                                call SECOND_1
                                                                                                call SECOND_1
                                                                                                bcf PORTD,2

LoopONR     
                                                                                                call tempconv2                                             ; Convert Pressure
                                                                                                call displaydata
                                                                                                bsf PORTD,3
                                                                                                btfss PORTA,2
                                                                                                goto LoopONR
                                                                                                movf ANALOGnonfract1,w
                                                                                                movwf U1
                                                                                                movf ANALOGnonfract0,w
                                                                                                movwf U2
                                                                                                movf ANALOGfract1,w
                                                                                                movwf U3
                                                                                                call DisLCD2A
                                                                                                call visualdelay
                                                                                                call SECOND_1
                                                                                                call SECOND_1

LoopDIA       
                                                                                                call tempconv2                                             ; Convert Pressure
                                                                                                call displaydata
                                                                                                btfss PORTA,2
                                                                                                goto LoopDIA
                                                                                                call SECOND_1

LoopDIA1      
                                                                                                call tempconv2                                             ; Convert Pressure
                                                                                                call displaydata
                                                                                                btfss PORTA,2
                                                                                                goto LoopDIA1
                                                                                                call SECOND_1

LoopDIA2     
                                                                                                call tempconv2                                             ; Convert Pressure
                                                                                                call displaydata
                                                                                                btfss PORTA,2
                                                                                                goto LoopDIA2
                                                                                                bcf PORTD,3
                                                                                                movf ANALOGnonfract1,w
                                                                                                movwf D1
                                                                                                movf ANALOGnonfract0,w
                                                                                                movwf D2
                                                                                                movf ANALOGfract1,w
                                                                                                movwf D3
                                                                                                call DisLCD2B
                                                                                                call SECOND_1
                                                                                                call SECOND_1
                                                                                                call SECOND_1

WaitY            
                                                                                                btfss PORTC,3
                                                                                                goto BP_CHECKx
                                                                                                btfss PORTD,0
                                                                                                goto StartMain
                                                                                                goto WaitY
                                                                                                goto ONR

OFFR             
                                                                                                bcf PORTD,2
                                                                                                call SECOND_1
                                                                                                return                                                                                    

;-------------------------------------------------------------------------------------------------

ADDON        
                                                                                                incf A3,1
                                                                                                movf A3,w
                                                                                                xorlw A':'
                                                                                                btfss STATUS,Z
                                                                                                return
                                                                                                movlw A'0'
                                                                                                movwf A3

ADDON1       
                                                                                                incf A2,1
                                                                                                movf A2,w
                                                                                                xorlw A':'
                                                                                                btfss STATUS,Z
                                                                                                return
                                                                                                movlw A'0'
                                                                                                movwf A2

ADDON2      
                                                                                                incf A1,1
                                                                                                movf A1,w
                                                                                                xorlw A':'
                                                                                                btfss STATUS,Z
                                                                                                return
                                                                                                movlw A'9'
                                                                                                movwf A1
                                                                                                movwf A2
                                                                                                movwf A3
                                                                                                return

DECCount
                                                                                                movf A3,w
                                                                                                xorlw A'0'
                                                                                                btfss STATUS,Z
                                                                                                goto Dec1
                                                                                                movf A2,w
                                                                                                xorlw A'0'
                                                                                                btfss STATUS,Z
                                                                                                goto Dec2
                                                                                                movf A1,w
                                                                                                xorlw A'0'
                                                                                                btfss STATUS,Z
                                                                                                goto Dec3
                                                                                                return

Dec1               
                                                                                                decf A3,1
                                                                                                return

Dec2              
                                                                                                decf A2,1
                                                                                                movlw A'9'
                                                                                                movwf A3
                                                                                                return

Dec3                                      
                                                                                                decf A1,1
                                                                                                movlw A'9'
                                                                                                movwf A2
                                                                                                movwf A3
                                                                                                return

;-----------------------------------------END OF MAIN 3-------------------------------------------

;------------------------------------------SEND MODE----------------------------------------------

SEND_MODE1
                                                                                                movlw A'X'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movlw A'1'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

SEND_MODE2
                                                                                                movlw A'X'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movlw A'2'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

SEND_MODE3
                                                                                                movlw A'X'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movlw A'3'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

SEND_TEMP
                                                                                                movlw A'T'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movf ANALOGnonfract2,w
                                                                                                call transmit
                                                                                                movf ANALOGnonfract1,w
                                                                                                call transmit
                                                                                                movf ANALOGnonfract0,w
                                                                                                call transmit
                                                                                                movlw A'.'                                                                             
                                                                                                call transmit
                                                                                                movf ANALOGfract1,w
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

SEND_BPM
                                                                                                movlw A'H'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movf A1,w
                                                                                                call transmit
                                                                                                movf A2,w
                                                                                                call transmit
                                                                                                movf A3,w
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

SEND_BP
                                                                                                movlw A'B'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movf U1,w
                                                                                                call transmit
                                                                                                movf U2,w
                                                                                                call transmit
                                                                                                movf U3,w
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movf D1,w
                                                                                                call transmit
                                                                                                movf D2,w
                                                                                                call transmit
                                                                                                movf D3,w
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

SEND_PRESS  
                                                                                                movlw A'P'
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                movf ANALOGnonfract1,w
                                                                                                call transmit
                                                                                                movf ANALOGnonfract0,w
                                                                                                call transmit
                                                                                                movf ANALOGfract1,w
                                                                                                call transmit
                                                                                                movlw A','
                                                                                                call transmit
                                                                                                return

;----------------------------------------END OF MAIN PROGRAM---------------------------------------

;-------------------------------------Subroutine for Time&Delay------------------------------------

SECOND_1
                                                                                                movlw            d'4'
                                                                                                movwf           N

more              
                                                                                                call                   Delay_T

continue        
                                                                                                DECFSZ           N,1
                                                                                                goto                more
                                                                                                return

Delay_T         
                                                                                                movlw            d'240'                                                             ;delay 250 ms (4 MHz clock)
                                                                                                movwf           count1

d1                                           
                                                                                                movlw            0xC7
                                                                                                movwf           counta
                                                                                                movlw            0x01
                                                                                                movwf           countb

Delay_0
                                                                                                decfsz             counta, f
                                                                                                goto                $+2
                                                                                                decfsz             countb, f
                                                                                                goto                Delay_0
                                                                                                decfsz             count1             ,f
                                                                                                goto                d1
                                                                                                retlw               0x00

DelayBPM     
                                                                                                movlw            d'1'                                                                   ;delay 250 ms (4 MHz clock)
                                                                                                movwf           count1

d1BPM
                                                                                                movlw            d'1'
                                                                                                movwf           counta
                                                                                                movlw            d'1'
                                                                                                movwf           countb

Delay_0BPM
                                                                                                decfsz             counta, f
                                                                                                goto                $+2
                                                                                                decfsz             countb, f
                                                                                                goto                Delay_0BPM
                                                                                                decfsz             count1             ,f
                                                                                                goto                d1BPM
                                                                                                retlw               0x00
                       
Delay_T24
                                                                                                movf TH,w
                                                                                                movwf           countc

d124              
                                                                                                movlw            0xC7
                                                                                                movwf           counta
                                                                                                movlw            0x01
                                                                                                movwf           countb

Delay_024
                                                                                                decfsz             counta, f
                                                                                                goto                $+2
                                                                                                decfsz             countb, f
                                                                                                goto                Delay_024  
                                                                                                decfsz             countc             ,f
                                                                                                goto                d124
                                                                                                retlw               0x00

Delay_Tx
                                                                                                movlw            d'50'                                                                ;delay 250 ms (4 MHz clock)
                                                                                                movwf           countc

d1x                 
                                                                                                movlw            0xC7
                                                                                                movwf           counta
                                                                                                movlw            0x01
                                                                                                movwf           countb

Delay_0x
                                                                                                decfsz             counta, f
                                                                                                goto                $+2
                                                                                                decfsz             countb, f
                                                                                                goto                Delay_0x
                                                                                                decfsz             countc             ,f
                                                                                                goto                d1x
                                                                                                retlw               0x00

Delay_T4
                                                                                                movf TL,w
                                                                                                movwf           countc

d14                                         
                                                                                                movlw            0xC7
                                                                                                movwf           counta
                                                                                                movlw            0x01
                                                                                                movwf           countb

Delay_04
                                                                                                decfsz             counta, f
                                                                                                goto                $+2
                                                                                                decfsz             countb, f
                                                                                                goto                Delay_04
                                                                                                decfsz             countc             ,f
                                                                                                goto                d14
                                                                                                retlw               0x00

Delay_Tz       
                                                                                                movlw            d'5'                                                                  ;delay 250 ms (4 MHz clock)
                                                                                                movwf           countc

d1z                 
                                                                                                movlw            0xC7
                                                                                                movwf           counta
                                                                                                movlw            0x01
                                                                                                movwf           countb

Delay_0z
                                                                                                decfsz             counta, f
                                                                                                goto                $+2
                                                                                                decfsz             countb, f
                                                                                                goto                Delay_0z
                                                                                                decfsz             countc             ,f
                                                                                                goto                d1z
                                                                                                retlw               0x00

;----------------------------------END of Subroutine for Time&Delay--------------------------------

;-------------------------Subroutine to initialize the PORTs as Inputs or Outputs------------------

initports        
                                                                                                bcf STATUS,RP0
                                                                                                clrf    PORTB
                                                                                                clrf    PORTC
                                                                                                clrf                   PORTA
                                                                                                clrf                   PORTD
                                                                                                clrf                   PORTE
                                                                                                bsf     STATUS,RP0      ;Change to Bank1
                                                                                                bcf                   OPTION_REG,7
                                                                                                MOVLW        0x06                                                              ;CONFIGURED ALL PIN AS DIGITAL I/O
                                                                                                MOVWF        ADCON1      
                                                                                                movlw            b'00011111'
                                                                                                movwf           TRISA
                                                                                                movlw            b'00000011'     ;Set PORTA all OUTPUT
                                                                                                movwf           TRISD
                                                                        clrf    TRISB           ;Set PORTB
                                                                                                movlw            b'10001000'
                                                                                                movwf           TRISC
                                                                        movlw            b'00000000'
                                                                                                movwf           TRISE
                                                                                                bcf     STATUS,RP0      ;Change to Bank0
                                                                                                return

;---------------------END Subroutine to initialize the PORTs as Inputs or Outputs------------------                          

;-------------------------------------Initialize the LCD-------------------------------------------

INITLCD                                
                                                                                                MOVLW        0xE6                                                               ; Call for 46ms delay
                                                                                                CALL               NDELAY                                                         ; Wait for VCC of the LCD to reach 5V
                                                                                                BCF                                         PORTD, 5                              ; Clear RS to select Instruction Reg.
                                                                                                BCF                                         PORTD, 6                              ; Clear R/W to write
                                                                                                MOVLW        B'00111011'                              ; Function Set to 8 bits, 2 lines and 5x7 dot matrix
                                                                                                MOVWF        PORTB
                                                                                                CALL               ENABLEPULSE
                                                                                                CALL               DELAY50
                                                                                                CALL               ENABLEPULSE
                                                                                                CALL               DELAY50
                                                                                                CALL               ENABLEPULSE
                                                                                                CALL               DELAY50                                                       ; Call 50us delay and wait for instruction completion
                                                                                                MOVLW        B'00001000'                          ; Display OFF
                                                                                                MOVWF        PORTB
                                                                                                CALL               ENABLEPULSE
                                                                                                CALL               DELAY50                                                       ; Call 50us delay and wait for instruction completion
                                                                                                MOVLW        B'00000001'                          ; Clear Display
                                                                                                MOVWF        PORTB
                                                                                                CALL               ENABLEPULSE
                                                                                                MOVLW        0x09                                                               ; Call 1.8ms delay and wait for instruction completion                                                                                                
                                                                                                CALL               NDELAY                                
                                                                                                MOVLW        B'00000010'                          ; Cursor Home
                                                                                                MOVWF        PORTB
                                                                                                CALL               ENABLEPULSE
                                                                                                MOVLW        0x09                                                               ; Call 1.8ms delay and wait for instruction completion                                                                                                
                                                                                                CALL               NDELAY
                                                                                                MOVLW        B'00001100'                           ; Display ON, Cursor OFF, Blinking OFF
                                                                                                MOVWF        PORTB
                                                                                                CALL               ENABLEPULSE
                                                                                                CALL               DELAY50                                                       ; Call 50us delay and wait for instruction completion
                                                                                                MOVLW        B'00000110'                           ; Entry Mode Set, Increment & No display shift
                                                                                                MOVWF        PORTB
                                                                                                CALL               ENABLEPULSE
                                                                                                CALL               DELAY50                                                       ; Call 50us delay and wait for instruction completion
                                                                                                BSF                                          PORTD, 5                              ; Set RS to select Data Reg.
                                                                                                BCF                                         PORTD, 6                              ; Clear R/W to write
                                                                                                RETURN

;---------------------------------END of Initialize the LCD--------------------------------------

;--------------------Enable Pulse for writing or reading instructions or data--------------------

ENABLEPULSE                       
                                                                                                BCF                 PORTD, 7                                                      ; 2us LOW followed by 3us HIGH Enable Pulse and 2us LOW.
                                                                                                NOP
                                                                                                NOP
                                                                                                BSF                  PORTD, 7
                                                                                                NOP
                                                                                                NOP
                                                                                                NOP
                                                                                                BCF PORTD, 7
                                                                                                NOP
                                                                                                NOP
                                                                                                RETURN

;-------------------END Enable Pulse for writing or reading instructions or data------------------

--------------------------------------------------------------------------------------------------

;---------N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more)--------

NDELAY
                                                                                                MOVWF N                                                                            ; N is delay multiplier

NOTOVER    
                                                                                                CALL DELAY200                                           ; Call for 200us
                                                                                                DECFSZ N, 1                                                   ; Decrease N by 1
                                                                                                GOTO NOTOVER                                       ; The delay isn't done
                                                                                                RETURN


;----END of N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more)------
;-------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------
;-------------------------------------------DELAY-------------------------------------------------
;-------------------------------------------------------------------------------------------------
;------FIXED 200us DELAY (Possibly more due to execution time of the DECFSZ instruction.)---------

DELAY200    
                                                                                                MOVLW 0x42                                                                      ; 66 LOOPS
                                                                                                MOVWF FIXDELAY                                      ; 200us fixed delay

NOTDONE200                   
                                                                                                DECFSZ FIXDELAY, 1             ; Decrement of FIXDELAY
                                                                                                GOTO NOTDONE200                               ; If 200us isn't up go back to NOTDONE200
                                                                                                RETURN                                                                                 ; If 200us is up then return to instruction.

;--------------------------------------------------------------------------------------------------
;-------FIXED 50us DELAY (Possibly more due to execution time of the DECFSZ instruction.)----------

DELAY50      
                                                                                                MOVLW 0x10                                                                       ; 16 LOOPS
                                                                                                MOVWF FIXDELAY                                      ; 50us fixed delay

NOTDONE50                      
                                                                                                DECFSZ FIXDELAY, 1             ; Decrement of FIXDELAY
                                                                                                GOTO NOTDONE50                                 ; If 50us isn't up go back to NOTDONE50
                                                                                                RETURN                                                                                 ; If 50us is up then return to instruction.

;--------------------------------------------------------------------------------------------------
;-------------------------------------Visual delay subroutine--------------------------------------

visualdelay
                                                                                                movlw 0x10
                                                                                                movwf visdelay

seetemp        
                                                                                                movlw 0x10
                                                                                                call NDELAY
                                                                                                decfsz visdelay, 1
                                                                                                goto seetemp
                                                                                                return

visualdelay1
                                                                                                movlw 0x12                                                  ;FAST
                                                                                                movwf visdelay

seetemp2      
                                                                                                movlw 0xAA
                                                                                                call NDELAY
                                                                                                decfsz visdelay, 1
                                                                                                goto seetemp2
                                                                                                return

;-----------------------------------------END of DELAY---------------------------------------------
;--------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------
;----------------------------Fast Directive to write characters to LCD-----------------------------

PUTCHAR
                                                                                                MOVWF PORTB                                                                  ; A quicker way of writing characters to LCD.
                                                                                                CALL ENABLEPULSE
                                                                                                CALL CHKBUSY
                                                                                                RETURN

;---------------------END of Fast Directive to write characters to LCD-----------------------------
;--------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------
;--------------------------------------------LCD setting-------------------------------------------
;Subroutine to check for the BUSY flag. Mostly used for instructions that follows up a character write.

CHKBUSY
                                                                                                bcf                   PORTD,5                                                       ; Clear RS to select Instruction Reg.
                                                                                                bsf                   PORTD,6                                                       ; Set R/W to read.
                                                                                                banksel TRISB                                                ; Select Bank for TRISC.
                                                                                                movlw 0xFF                                                  ; Define all PORTC Pins as Inputs.
                                                                                                movwf TRISB
                                                                                                banksel PORTD                                            ; Select Bank for PORTC.
                                                                                                bsf PORTD,7                                                
                                                                                                movf PORTB,w                                           
                                                                                                bcf PORTD,7                                                
                                                                                                andlw 0x80                                                 
                                                                                                btfss STATUS,Z
                                                                                                goto CHKBUSY
                                                                                                banksel TRISB                                                ; Select Bank for TRISB.
                                                                                                movlw 0x00                                                 ; Define all PORTC Pins as Outputs.
                                                                                                movwf TRISB
                                                                                                banksel PORTD                                            ; Select Bank for PORTA, B, and C.
                                                                                                bsf PORTD,5                                                                         ; Set RS to select Data Register.
                                                                                                bcf PORTD,6                                                                         ; Clear R/W to write.
                                                                                                return

;--------------------------------------------------------------------------------------------------
;---------------------------------Position Cursor to the next line---------------------------------

nextline
                                                                                                banksel PORTD
                                                                                                bcf PORTD, 5                                                ; Select Instructions Register.
                                                                                                bcf PORTD, 6                                                ; Select Write.
                                                                                                movlw b'11000000'             ; Shift cursor to second line at 0x40 RAM address on LCD.
                                                                                                call PUTCHAR
                                                                                                return

;--------------------------------------------------------------------------------------------------
;------------------------------------Clear screen and Cursor home----------------------------------

clrscreen
                                                                                                banksel PORTD
                                                                                                bcf PORTD, 5                                                ; Clear RS to select Instructions Register.
                                                                                                bcf PORTD, 6                                                ; Clear R/W to select Write.
                                                                                                banksel PORTB
                                                                                                MOVLW B'00000001'         ; Clear Display
                                                                                                call PUTCHAR
                                                                                                return

;--------------------------------------------------------------------------------------------------
;--------------------------------Position Cursor to home position----------------------------------

cursorhome
                                                                                                banksel PORTD
                                                                                                bcf PORTD, 5                                                ; Select Instructions Register.
                                                                                                bcf PORTD, 6                                                ; Select Write.
                                                                                                movlw b'00000010'            ; Position cursor to home position.
                                                                                                call PUTCHAR
                                                                                                return

;-------------------------------------END of LCD setting-------------------------------------------
;--------------------------------------------------------------------------------------------------

;--------------------------------------------------------------------------------------------------
;-----------Wait 20us for Acquisition time in order for holding capacitor to charge up-------------

delay20                                 
                                                                                                banksel FIXDELAY                ; A loop to generate 20us delay.
                                                                                                movlw 0x08
                                                                                                movwf FIXDELAY
                                                                       
notdone20  
                                                                                                decfsz FIXDELAY, 1
                                                                                                goto notdone20
                                                                                                return

;--------------------------------------------------------------------------------------------------
;----------------------Delay to provide some settling time for start up----------------------------

delay                                      
                                                                                                banksel dataL
                                                                                                clrf dataL

settle                                      
                                                                                                decfsz dataL, f                                               ; The delay loop.
                                                                                                goto settle                                                                            
                                                                                                movf RCREG, w                                            ; Flush the receive buffer.
                                                                                                movf RCREG, w
                                                                                                movf RCREG, w
                                                                                                return

;--------------------------------------------------------------------------------------------------
;------------------------------------Initialize ADC Subroutine-------------------------------------
                                               
initadc                                   
                                                                                                banksel TRISA                                                ; Select Bank for TRISA.
                                                                                                movlw b'11111111'                   ; Initialize RA0 - RA5 as Inputs.
                                                                                                movwf TRISA
                                                                                                movlw b'00000111'              ; Initialize RA0 - RA5 as Inputs.
                                                                                                movwf TRISE
                                                                                                banksel ADCON1                                          ; Select Bank for ADCON1.
                                                                                                movlw b'00000100'            ; ADFM for Left Justified, Vref-=Vss Vref+=AN3 Analog In=AN0, AN1 (R/C = 1/2).
                                                                                                movwf ADCON1
                                                                                                banksel ADCON0                                         ; Select Bank for ADCON0.
                                                                                                movlw b'01000001'             ; Fosc/8, Channel 0, Enable the ADC (Default Chan. 0)
                                                                                                movwf ADCON0                
                                                                                                banksel TRISA
                                                                                                bsf TRISA,1    
                                                                                                bsf TRISA,2
                                                                                                return

;---------------------------------------------------------------------------------------------------
;--------------This routine starts the AD Conversion and waits for it to complete-------------------

startadc         
                                                                                                banksel ADCON0                                         ; Select Bank for ADCON0.
                                                                                                bsf ADCON0, GO                                        ; Set the GO bit to begin AD Conversion.
                                                                                                banksel ADCON0                                         ; Select Bank for ADCON0.

checkdone
                                                                                                btfsc ADCON0, GO             ; Check if the conversion is done
                                                                                                goto checkdone                    ; If not, check again.
                                                                                                return                                   ; Else, return to the main programme.

;--------------------------------------------------------------------------------------------------
;-------------------------------Select Channel AN0 of A/D Converter--------------------------------

chan0                                     
                                                                                                banksel ADCON0
                                                                                                bcf ADCON0, 5
                                                                                                bcf ADCON0, 4
                                                                                                bcf ADCON0, 3
                                                                                                return

;--------------------------------------------------------------------------------------------------
;--------------------------------Select Channel AN1 of A/D Converter-------------------------------

chan1                                      
                                                                                                banksel ADCON0
                                                                                                bcf ADCON0, 5
                                                                                                bcf ADCON0, 4
                                                                                                bsf ADCON0, 3
                                                                                                return

;-------------------------------------------------------------------------------------------------------------------
;-------------------------------Select Channel AN1 of A/D Converter--------------------------------

chan2                                     
                                                                                                banksel ADCON0
                                                                                                bcf ADCON0, 5
                                                                                                bsf ADCON0, 4
                                                                                                bcf ADCON0, 3
                                                                                                return

;--------------------------------------------------------------------------------------------------------------------
;-------------------------------Select Channel AN1 of A/D Converter--------------------------------

chan3                                     
                                                                                                banksel ADCON0
                                                                                                bcf ADCON0, 5
                                                                                                bsf ADCON0, 4
                                                                                                bsf ADCON0, 3
                                                                                                return

;--------------------------------------------------------------------------------------------------------------------
;------------------------------Select Channel AN1 of A/D Converter----------------------------------

chan4                                     
                                                                                                banksel ADCON0
                                                                                                bsf ADCON0, 5
                                                                                                bcf ADCON0, 4
                                                                                                bcf ADCON0, 3
                                                                                                return

;--------------------------------------------------------------------------------------------------------------------
;-----------------------------Select Channel AN1 of A/D Converter----------------------------------

chan5                                     
                                                                                                banksel ADCON0
                                                                                                bsf ADCON0, 5
                                                                                                bcf ADCON0, 4
                                                                                                bsf ADCON0, 3
                                                                                                return
;------------------------------------------------------------------------------------------------------------------
;----------------------------------Convert Reading to ASCII Format---------------------------------

displaydata   
                                                                                                movlw d'48'                                                                                                  ; Convert individual digits to ASCII.
                                                                                                addwf digitANALOGdata22, f
                                                                                                addwf digitANALOGdata12, f
                                                                                                addwf digitANALOGdata02, f
                                                                                                addwf digitANALOGdataL22, f
                                                                                                addwf digitANALOGdataL12, f
                                                                                                addwf digitANALOGdataL02, f
                                                                                                addwf ANALOGnonfract22, f
                                                                                                addwf ANALOGnonfract12, f
                                                                                                addwf ANALOGnonfract02, f
                                                                                                addwf ANALOGfract12, f
                                                                                                addwf ANALOGfract02, f
                                                                                                addwf digitANALOGdata2, f
                                                                                                addwf digitANALOGdata1, f
                                                                                                addwf digitANALOGdata0, f
                                                                                                addwf digitANALOGdataL2, f
                                                                                                addwf digitANALOGdataL1, f
                                                                                                addwf digitANALOGdataL0, f
                                                                                                addwf ANALOGnonfract2, f
                                                                                                addwf ANALOGnonfract1, f
                                                                                                addwf ANALOGnonfract0, f
                                                                                                addwf ANALOGfract1, f
                                                                                                addwf ANALOGfract0, f
                                                                                                return

;---------------------------------------------------------------------------------------------------------
;--------------------------------------Display to LCD-----------------------------------------------
 
DisLCD                                                          
                                                                                                call clrscreen
                                                                                                call cursorhome                                                                     ; Reposition cursor to home.
                                                                                                call tempconv                                                                        ; Convert Temperature
                                                                                                call displaydata
                                                                                                movlw A'T'                                                                            
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'm'
                                                                                                call PUTCHAR
                                                                                                movlw A'p'
                                                                                                call PUTCHAR
                                                                                                movlw A':'
                                                                                                call PUTCHAR
                                                                                                movf ANALOGnonfract2,w
                                                                                                call PUTCHAR
                                                                                                movf ANALOGnonfract1,w
                                                                                                call PUTCHAR
                                                                                                movf ANALOGnonfract0,w
                                                                                                call PUTCHAR
                                                                                                movlw A'.'                                                                             
                                                                                                call PUTCHAR
                                                                                                movf ANALOGfract1,w
                                                                                                call PUTCHAR
                                                                                                movlw A'c'                                                                             
                                                                                                call PUTCHAR
                                                                                                call nextline
                                                                                                call SEND_TEMP
                                                                                                movf ANALOGnonfract2,w
                                                                                                xorlw A'0'
                                                                                                btfss STATUS,Z
                                                                                                goto ABNORMAL
                                                                                                movf ANALOGnonfract1,w
                                                                                                xorlw A'3'
                                                                                                btfss STATUS,Z
                                                                                                goto ABNORMAL
                                                                                                movf ANALOGnonfract0,w
                                                                                                xorlw A'6'
                                                                                                btfsc STATUS,Z
                                                                                                goto NORMAL
                                                                                                movf ANALOGnonfract0,w
                                                                                                xorlw A'7'
                                                                                                btfsc STATUS,Z
                                                                                                goto NORMAL
                                                                                                goto ABNORMAL

ABNORMAL 
                                                                                                movlw A'A'
                                                                                                call PUTCHAR
                                                                                                movlw A'B'                                                                            
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'N'
                                                                                                call PUTCHAR
                                                                                                movlw A'O'
                                                                                                call PUTCHAR
                                                                                                movlw A'R'
                                                                                                call PUTCHAR
                                                                                                movlw A'M'
                                                                                                call PUTCHAR
                                                                                                movlw A'A'
                                                                                                call PUTCHAR
                                                                                                movlw A'L'
                                                                                                call PUTCHAR
                                                                                                movlw A'!'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                return

NORMAL                                                      
                                                                                                movlw A'N'
                                                                                                call PUTCHAR
                                                                                                movlw A'O'
                                                                                                call PUTCHAR
                                                                                                movlw A'R'
                                                                                                call PUTCHAR
                                                                                                movlw A'M'
                                                                                                call PUTCHAR
                                                                                                movlw A'A'
                                                                                                call PUTCHAR
                                                                                                movlw A'L'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                return
;--------------------------------------------------------------------------------------------------
 
standby                                                         
                                                                                                call clrscreen
                                                                                                call cursorhome
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'F'                                                                            
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'i'
                                                                                                call PUTCHAR
                                                                                                movlw A'n'
                                                                                                call PUTCHAR
                                                                                                movlw A'g'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'r'                                                                             
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'S'
                                                                                                call PUTCHAR
                                                                                                movlw A'P'
                                                                                                call PUTCHAR
                                                                                                movlw A'O'
                                                                                                call PUTCHAR
                                                                                                movlw A'2'
                                                                                                call PUTCHAR
                                                                                                call nextline                                                                          
                                                                                                movlw A' '                                                                             
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'R'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'a'
                                                                                                call PUTCHAR
                                                                                                movlw A'd'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'r'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                return

DisSelect        
                                                                                                call clrscreen
                                                                                                call cursorhome
                                                                                                movlw A'S'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'l'                                                                             
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'c'
                                                                                                call PUTCHAR
                                                                                                movlw A't'
                                                                                                call PUTCHAR
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'M'                                                                          
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'O'
                                                                                                call PUTCHAR
                                                                                                movlw A'D'
                                                                                                call PUTCHAR
                                                                                                movlw A'E'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                call SECOND_1
                                                                                                call SECOND_1
                                                                                                return

DisMODE1                            
                                                                                                call clrscreen
                                                                                                call cursorhome
                                                                                                movlw A'T'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'm'                                                                           
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'p'
                                                                                                call PUTCHAR
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'C'
                                                                                                call PUTCHAR
                                                                                                movlw A'h'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'                                                                            
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'c'
                                                                                                call PUTCHAR
                                                                                                movlw A'k'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                return

DisMODE2                           
                                                                                                call clrscreen
                                                                                                call cursorhome
                                                                                                movlw A'B'
                                                                                                call PUTCHAR
                                                                                                movlw A'P'
                                                                                                call PUTCHAR
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'C'
                                                                                                call PUTCHAR
                                                                                                movlw A'h'                                                                            
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'c'
                                                                                                call PUTCHAR
                                                                                                movlw A'k'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                return

DisMODE3                           
                                                                                                call clrscreen
                                                                                                call cursorhome
                                                                                                movlw A'H'
                                                                                                call PUTCHAR
                                                                                                movlw A'R'
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A' '
                                                                                                call PUTCHAR
                                                                                                movlw A'C'
                                                                                                call PUTCHAR
                                                                                                movlw A'h'
                                                                                                call PUTCHAR
                                                                                                movlw A'e'
                                                                                                call PUTCHAR
                                                                                                movlw A'c'                                                                             
                                                                                                call PUTCHAR                                                                       
                                                                                                movlw A'k'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                movlw A'.'
                                                                                                call PUTCHAR
                                                                                                call visualdelay
                                                                                                return

;--------------------------------------------------------------------------------------------------
;-------------------------------------------End of Programme---------------------------------------
                                                                       
                                                                                                END


 END of Programming



That's is all folks, I have shared alot with u people and hope u guys like it and have gain alot of knowledge from it...... All the best in life and my god bless us always.....Happy 2012 everyone...! Take care and till we meet again...

Bubye...... :)



(((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) 

Quote of the day............!

 Success is sweet: the sweeter if long delayed and attained through manifold struggles and defeats.
A. Branson Alcott

(((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>))))) (((((<>)))))

 

Regards,


Idriah Safriza bte Idris Chin   :)
/* CUTE CURSOR */ Waving Onion Kun /* ticker */