                .DO     External
                .LSTON
                .Page
;>>>>>>>>>>>>>>>>>>>>>>>>
;>
;>      Module: Utilities
;>
;>      This module contains all the routines that do not fall
;>      logically into any specific grouping, yet are essential
;>      to the program.
;>
;>      PROCEDURE ClrNormStat
;>      PROCEDURE Move4( Source : PTR { !!r2 }
;>                       Destination : PTR { !!rE }
;>                     )
;>
;>>>>>>>>>>>>>>>>>>>>>>>>
                .LSTOFF
                .FIN
                .DO     External
                .LSTON
                .Page
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>
;>      Procedure: ClrNormStat
;>
;>      This procedure clears all the bytes within standard status.
;>
;>      Inputs: { none }
;>
;>      Outputs: { none }
;>
;>      Algorithm:
;>
;>      BEGIN
;>       FOR i := 1 TO Length( StandardStatus ) DO
;>        StandardStatus[ i ] := 0
;>       IF ( Excpt_Stat.SprTbl_Warn )
;>        THEN SS_SprWarn
;>       IF ( Excpt_Stat.PwrRst )
;>        THEN 
;>              SetStatus( PowerResest )
;>              Excpt_Stat.PwrRst := False
;>      END
;>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                .LSTOFF
                .FIN
                .DO     Internal
                .LSTON
                .Page
                .FIN

ClrNormStat:
                Ld      !r2,#.HIBYTE. CStatus0
                Ld      !r3,#.LOWBYTE. CStatus0
                Clr     !r0
                Ld      !r1,#( CStatus1 - CStatus0 ) ;clear all status bytes
                
Clr_N_Stat:     Lde     @!!r2,!r0
                Incw    !!r2
                Djnz    !r1,Clr_N_Stat
                
                Tm      Excpt_Stat,#SprTbl_Warn
                Jr      Z,Clr_N_PwrRst
                
                Call    SS_SprWarn
                
Clr_N_PwrRst:   Tm      Excpt_Stat,#PwrRst
                Jr      Z,Clr_N_SlfTst
                
                 Ld     !r0,#2 ;byte 2
                 Ld     !r1,#Power_Reset
                Call    SetStatus
                And     Excpt_Stat,#$FF-PwrRst
                
Clr_N_SlfTst:   Or      SlfTst_Result,SlfTst_Result
                Jr      Z,Clr_N_Leave
                
                 Ld     !r0,#01 ;byte 1
                 Ld     !r1,#Stat_SlfTst
                Call    SetStatus
                
Clr_N_Leave:    Jp      Bank_Ret

                .LSTOFF
                .DO     External
                .LSTON
                .Page
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>
;>      Procedure: Move4_B0
;>
;>      This procedure is used to move 4 bytes from the souce to the
;>      destination.
;>
;>      Inputs:
;>              Source : PTR { !!r2 }
;>              Destination : PTR { !!rE }
;>
;>      Outputs: { none }
;>
;>      Algorithm:
;>
;>      BEGIN
;>       FOR i := 0 TO 3 DO
;>        @Destination( i ) := @Source( i )
;>      END
;>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                .LSTOFF
                .FIN
                .DO     Internal
                .LSTON
                .Page
                .FIN

Move4_B0:
                Ld      !r1,#4
Move4_B0_Lp:    Lde     !r0,@!!r2
                Lde     @!!rE,!r0
                Incw    !!r2
                Incw    !!rE
                Djnz    !r1,Move4_B0_Lp
                
                Jp      Bank_Ret
                
                .LSTOFF
                
