⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svoutil.asm

📁 一个完整DVDROM代码(使用日立PICKUP)
💻 ASM
字号:
;==============================================================================
;
; Copyright (C) 2001 Acer Labs, Inc. All Rights Reserved.
;
; File:         SVOUTIL.ASM
;
; Contents:     These file content calculate tracks, calibration disc parameter
;               and mathmetical routine
;
; History:
;   04/18/2001  develop 5705
;
;******************************************************************************
NAME        svoutil
$SET        (XTAL=33)
;$SET		(PD_03=1)

$IF XTAL=40
    TH0_INI         EQU         07DH    ;for 40MHz
    TL0_INI         EQU         0CAH
$ELSEIF XTAL=33
    TH0_INI         EQU         091H    ;for 33MHz
    TL0_INI         EQU         0BFH
$ELSE
    TH0_INI         EQU         0B1H    ;for 24MHz
    TL0_INI         EQU         0DFH
$ENDIF


EXTRN   IDATA       (iwIdleTimer)
EXTRN   IDATA       (iwSpeedTimer)     ;1906a02j   
EXTRN   IDATA       (iwStsTimer)
EXTRN   IDATA       (iwHostCmdTimer)
EXTRN   IDATA       (ibServoTimer)
EXTRN   IDATA       (ibServoSubTimer)
EXTRN   IDATA       (ibRdQTimer)
EXTRN   IDATA       (ibSeekTimer)
EXTRN   IDATA       (ibDSPCmdTimer)
EXTRN   IDATA       (ibDecoderTimer)
EXTRN   IDATA       (ibLEDTimer)

EXTRN   DATA        (STORE)
EXTRN   BIT         (fLEDToggle)
EXTRN   BIT         (fEjectPressed)
EXTRN   BIT         (fTrayDir)


PUBLIC  EJ_KEY,LED

EJ_KEY              BIT         P1.1	;//p1.1
LED                 BIT         P1.2


svoutil_DA          SEGMENT     DATA
        RSEG        svoutil_DA
LEDTimer:           DS          1


svoutil_BI          SEGMENT     BIT
        RSEG        svoutil_BI
fMonitorEjectKey:   DBIT        1
fByteMode:          DBIT        1


        CSEG        at (000Bh)          ;vector address of timer0 interrupt
        LJMP        Timer0Interrupt


svoutil_PR          SEGMENT     CODE
        RSEG        svoutil_PR
        USING       0


;------------------------------------------------------------------------------
;Function:  timer0 interrupt service routine
;Input:     every 10 msec all timers which are not 00 are decremented
;Output:    -
;------------------------------------------------------------------------------
Timer0Interrupt:
        PUSH    AR0
        PUSH    PSW
        MOV     TH0,#TH0_INI            ;re-init timer tick of 10ms.
        MOV     TL0,#TL0_INI
        JNB     fLEDToggle,timer_start
        DJNZ    LEDTimer,timer_start
        CPL     LED
        MOV     R0,#ibLEDTimer
        MOV     LEDTimer,@R0

timer_start:
        CLR     fByteMode
        MOV     R0,#iwIdleTimer+1
CheckTimer:
        CJNE    @R0,#0,SubTimer1
        JB      fByteMode,NextTimer1
        DEC     R0
        CJNE    @R0,#0,SubTimer2
        INC     R0
NextTimer1:
        INC     R0
        JB      fByteMode,check_end
        CJNE    R0,#ibServoTimer,NextTimer2
        SETB    fByteMode
        JMP     CheckTimer
NextTimer2:
        INC     R0
        JMP     CheckTimer
check_end:
        CJNE    R0,#ibLedTimer,CheckTimer
;$IF PD_03=0
        JB      EJ_KEY,check_eject_key  ;eject release
        SETB    fMonitorEjectKey        ;eject pressed
        JMP     end_check_eject
check_eject_key:
        JNB     fMonitorEjectKey,end_check_eject
        SETB    fEjectPressed
        CPL     fTrayDir
        CLR     fMonitorEjectKey
;$ENDIF
end_check_eject:

        POP     PSW
        POP     AR0
        RETI

SubTimer2:
        DEC     @R0                     ;high_order--
        INC     R0
SubTimer1:
        DEC     @R0                     ;timer=timer-1
        SJMP    NextTimer1

;------------------------------------------------------------------------------
;Function:  -
;Input:     -
;Output:    -
;------------------------------------------------------------------------------
PUBLIC  InitMCU
InitMCU:
        CLR     EA
        MOV     IE,#03h                 ;enable timer0
        MOV     IP,#02h                 ;timer0 first priority
        MOV     PSW,#0                  ;Clear status word (bank 0 is used).
        MOV     SCON,#0                 ;Disable series control.
        MOV     TCON,#10h               ;INT0/INT1 low level trigger, timer0 enable
        MOV     TMOD,#51h               ;T1 as 16bits counter, T0 as 16bits timer
        MOV     TH0,#TH0_INI            ;initial timer0 tick 10ms.
        MOV     TL0,#TL0_INI
        MOV     P0,#0FFh
        MOV     P1,#0FFh
        MOV     P2,#0FFh
        MOV     P3,#0FFh
        MOV     R0,#ibLEDTimer
        MOV     @R0,#20                 ;led trigger time
        MOV     LEDTimer,@R0
        SETB    EA                      ;enable interrupt
        RET

;------------------------------------------------------------------------------
;Function:  This function is used to conver a BCD byte to a HEX byte.(for CD,DVD)
;Input:     R7(Points to BCDByte)
;Output:    R7(Conver result HEX)
;Use:       A,B,R6
;------------------------------------------------------------------------------
PUBLIC  _BCDToHEX
_BCDToHEX:
        MOV     A,#0FH
        ANL     A,R7
        MOV     R6,A
        MOV     A,R7
        SWAP    A
        ANL     A,#0FH
        MOV     B,#10
        MUL     AB
        ADD     A,R6
        MOV     R7,A
        RET

;------------------------------------------------------------------------------
;Function:  This function is used to conver a HEX byte to a BCD byte.(for CD,DVD)
;Input:     R7(Points to DecByte)
;Output:    R7(Conver result BCD)
;Use:       A,B
;------------------------------------------------------------------------------
PUBLIC  _HEXToBCD
_HEXToBCD:
        MOV     B,#10
        MOV     A,R7
        DIV     AB
        SWAP    A
        ANL     A,#0F0H
        ORL     A,B
        MOV     R7,A
        RET

;------------------------------------------------------------------------------
;Function:  -
;Input:     Time(hex),offset(less then 75)
;Output:    TP_TIME1(hex)
;Use:       5,6,7
;------------------------------------------------------------------------------
PUBLIC  _SubTime
_SubTime:
        MOV     R0,AR7
        MOV     A,@R0
        MOV     STORE+5,A
        INC     R0
        MOV     A,@R0
        MOV     STORE+6,A
        INC     R0
        MOV     A,@R0
        CLR     C
        SUBB    A,R5
        MOV     STORE+7,A
        JNC     subtime_ok
        SUBB    A,#0B4H
        MOV     STORE+7,A
        MOV     A,STORE+6
        JZ      subtime_1
        DEC     A
        MOV     STORE+6,A
        JMP     subtime_ok
subtime_1:
        MOV     STORE+6,#03BH
        MOV     A,STORE+5
        DEC     A
        MOV     STORE+5,A
subtime_ok:
        RET

;------------------------------------------------------------------------------
;Function:  Delay25us * R7
;Input:     R7(DelayTimes)
;Output:    -
;------------------------------------------------------------------------------
PUBLIC  _Delay25us
_Delay25us:
$IF XTAL=40
        MOV     R5,#40                  ;for 40MHz
$ELSEIF XTAL=33
        MOV     R5,#33                  ;for 33MHz
$ELSE
        MOV     R5,#23                  ;for 24MHz
$ENDIF
        DJNZ    R5,($)
        DJNZ    R7,($-4)
        RET

;------------------------------------------------------------------------------
;Function:  Delay1ms * R7
;Input:     R7(DelayTimes)
;Output:    -
;------------------------------------------------------------------------------
PUBLIC  _Delay1ms
_Delay1ms:
        MOV     R5,#10
$IF XTAL=40
        MOV     R3,#165                 ;for 40MHz
$ELSEIF XTAL=33
        MOV     R3,#139                 ;for 33MHz
$ELSE
        MOV     R3,#98                  ;for 24MHz
$ENDIF
        DJNZ    R3,($)
        DJNZ    R5,($-4)
        DJNZ    R7,($-8)
        RET

;------------------------------------------------------------------------------
;Function:  Delay10ms * R7
;Input:     R7(DelayTimes)
;Output:    -
;------------------------------------------------------------------------------
PUBLIC  _Delay10ms
_Delay10ms:
        MOV     R5,#100
$IF XTAL=40
        MOV     R3,#165                 ;for 40MHz
$ELSEIF XTAL=33
        MOV     R3,#139                 ;for 33MHz
$ELSE
        MOV     R3,#98                  ;for 24MHz
$ENDIF
        DJNZ    R3,($)
        DJNZ    R5,($-4)
        DJNZ    R7,($-8)
        RET


boot_PR             SEGMENT     CODE
    RSEG            boot_PR
        USING       0

;------------------------------------------------------------------------------
;Function:  -
;Input:     -
;Output:    -
;------------------------------------------------------------------------------
PUBLIC  ReStartUP
ReStartUP:
        MOV     DPTR,#0FD5DH            ;0x15D=>0x80 disable flash rom mode
        MOV     A,#80H
        MOVX    @DPTR,A

        MOV     DPTR,#0FD5CH            ;0x15C=>0x44 ROM code is from flashROM
        MOV     A,#44H
        MOVX    @DPTR,A

        MOV     AR0,#0
        PUSH    AR0
        PUSH    AR0
        RET                             ;reboot uP F/W


        END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -