當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] ;*************************************************************************;; OriginalheaderfileforPIC16F84&AKIZUKI’sassembler.; Copyright(c)1998by32TechnicalLaboratory(JG6DFK/QRP).; A

;*************************************************************************
;
; OriginalheaderfileforPIC16F84&AKIZUKI’sassembler.
; Copyright(c)1998by32TechnicalLaboratory(JG6DFK/QRP).
; Allrightsreserved.
;
;*************************************************************************

.16f84

;-------------------------------------------------------------------------
;Registerdefinitionsofbank0.
;-------------------------------------------------------------------------

indf equ 00h ;DataI/Oportforindirectaddressing.
tmr0 equ 01h ;8bitsreal-timecLOCk/counter.
pcl equ 02h ;Loworder8bitsoftheprogramcounter.(PC)
status equ 03h ;Statusregister.
fsr equ 04h ;Indirectdatamemoryaddresspointer0.
porta equ 05h ;I/OportsA.(=RA0toRA4)
portb equ 06h ;I/OportsB.(=RB0toRB7)
ra equ 05h ;SameasPORTA.
rb equ 06h ;SameasPORTB.
eEDAta equ 08h ;EEPROMdataregister.
eeadr equ 09h ;EEPROMaddressregister.
pclath equ 0Ah ;Writebufferforupper5bitsofthePC.
iNTCon equ 0Bh ;Interruptcontrolregister.

;-------------------------------------------------------------------------
;Registerdefinitionsofbank1.
;-------------------------------------------------------------------------

option equ 01h ;(=81h)Optionregister.
trISA equ 05h ;(=85h)I/OportsAdatadirectionregister.
trisb equ 06h ;(=86h)I/OportsBdatadirectionregister.
eecon1 equ 08h ;(=88h)EEPROMdatamemoryR/Wstatusregister.
eecon2 equ 09h ;(=89h)I/OportforEEPROMdatamemory.

;-------------------------------------------------------------------------
;Others.
;-------------------------------------------------------------------------

;-----Forstatusregister.

irp equ 7 ;Registerbankselectbitforindirectaddressing.
rp1 equ 6 ;RP1:RP0 00=Bank0,01=Bank1.
rp0 equ 5 ; 10=Bank2,03=Bank3.
to equ 4 ;Time-outbit.
pd equ 3 ;Power-downbit.
z equ 2 ;Zerobit.
dc equ 1 ;Digitcarryorbollowbit.
c equ 0 ;Carryorborrowbit.

;-----Forinterruptcontrolregister.

gie equ 7 ;Globalinterruptenablebit.
eeie equ 6 ;EEPROMwritecompleteinterruptenablebit.
t0ie equ 5 ;TMR0overflowinterruptenablebit.
inte equ 4 ;RB0/INTinterruptenablebit.
rbie equ 3 ;RBportchangeinterruptenablebit.
t0if equ 2 ;TMR0overflowinterruptflagbit.
intf equ 1 ;RB0/INTinterruptflagbit.
rbif equ 0 ;RBportchangeinterruptflagbit.

;-----Foroptionregister.

rbpu equ 7 ;I/OportsBpull-updisablebit.
intedg equ 6 ;Interruptedgeselectbit.
t0cs equ 5 ;TMR0clocksourceselectbit.
t0se equ 4 ;TMR0sourceedgeselectbit.
psa equ 3 ;PrescalerAssignmentbit.
ps2 equ 2 ;PS2:PS0=Prescalerrateselectbits.
ps1 equ 1 ; ForTMR0=1:2to1:256.
ps0 equ 0 ; WDT =1:1to1:128.

;-----ForI/OportsA.(RA)

ra4 equ 4 ;RA4/T0CKI.
t0cki equ 4 ;Sameas’ra4’.
ra3 equ 3 ;RA3.
ra2 equ 2 ;RA2.
ra1 equ 1 ;RA1.
ra0 equ 0 ;RA0.

;-----ForI/OportsB.(RB)

rb7 equ 7 ;RB7.
rb6 equ 6 ;RB6.
rb5 equ 5 ;RB5.
rb4 equ 4 ;RB4.
rb3 equ 3 ;RB3.
rb2 equ 2 ;RB2.
rb1 equ 1 ;RB1.
rb0 equ 0 ;RB0.
int equ 0 ;Sameas’rb0’.

;-----ForEEPROMcontrolregister.(EECON1)

eeif equ 4 ;EEPROMwriteoperationinterruptflagbit.
wrerr equ 3 ;EEPROMwriteerrorflagbit.
wren equ 2 ;EEPROMwriteenablebit.
wr equ 1 ;EEPROMwritecontrolbit.
rd equ 0 ;EEPROMreadcontrolbit.

;-----Forgeneral

w equ 0 ;Destinationselector.(Workingregister)
f equ 1 ;Destinationselector.(Registerfile)
;*************************************************************************
;
; SOFtwareforFrequencyCountermodelPIC-FC1.
; Version1.00.
;
; Copyright(c)1999by32TechnicalLaboratory.(JG6DFK/QRP)
; Allrightsreserved.
;
;*************************************************************************

;I/Oassignment:
; RA4(PIN 3)Input. (I)
; RA3(pin 2)LCDData#3. (O)
; RA2(pin 1)LCDData#2. (O)
; RA1(pin18)LCDData#1. (O)
; RA0(pin17)LCDData#0. (O)
; RB7(pin13)LCDLoadEnable. (O)
; RB6(pin12)LCDRegisterSelect. (O)
; RB5(pin11)DisplayMode. (I)
; RB4(pin10)Externalprescalermode. (I)
; RB3(pin 9)Internalprescalermode#1. (I)
; RB2(pin 8)Internalprescalermode.#0. (I)
; RB1(pin 7)Gatetime#1. (I)
; RB0(pin 6)Gatetime#0. (I)


.include 16f84_32.h

.osc xt ;Clock=10MHz.
.wdt off
.pwrt on
.protect off

id 0100h ;=VersionNo.

;-------------------------------------------------------------------------
;Equations.
;-------------------------------------------------------------------------

;-----I/Odifinitions.

LCD_LE equ rb7 ;LCDloadenable.
LCD_RS equ rb6 ;LCDregisterselect.

I_SELDSP equ rb5 ;Displaymode selectSW.
I_EXTPSC equ rb4 ;ExternalprescalerselectSW.
I_INTPS1 equ rb3 ;ExternalprescalerselectSW#1.
I_INTPS0 equ rb2 ;ExternalprescalerselectSW#0.
I_SELRS1 equ rb1 ;Resolution selectSW#1.
I_SELRS0 equ rb0 ;Resolution selectSW#0.

;-----Constants.

FRES_1 equ 0 ;Resolutionmode= 1Hz.
FRES_10 equ 1 ; 10Hz.
FRES_100 equ 2 ; 100Hz.
FRES_1000 equ 3 ; 1kHz.

DSP_FREQ equ 0 ;Displaymode=frequency.
DSP_LENG equ 1 ; wavelength.(X.XXXm)

IPSC_1 equ 0 ;Internalprescaler=1:1.
IPSC_4 equ 1 ; 1:4.
IPSC_8 equ 2 ; 1:8.
IPSC_16 equ 3 ; 1:16.

TMR0_1 equ 00101000b ;PrescalerrateforTMR0=1:1.
TMR0_4 equ 00100001b ; 1:4.
TMR0_8 equ 00100010b ; 1:8.
TMR0_16 equ 00100011b ; 1:16.

XPSC_OFF equ 0 ;Externalprescaler=disabLED.
XPSC_ON equ 1 ; enabled.

XPSC_RATE equ 64 ;Externalprescalerrate.

MAXDIGIT equ 10 ;Maxdigit="XXXXXXX.XXX".

;-----LCDfunctions.

L_SELDR equ 0 ;LCDdataregisterselect.

L_FNCSET equ 00101000b ;LCDfunctionset.
L_ENTSET equ 00000110b ;LCDentrymodeset.
L_DSPCLR equ 00000001b ;LCDdisplayclear.
L_DSPOFF equ 00001000b ;LCDdisplayOFF.
L_DSPON equ 00001100b ;LCDdisplayON.
L_CSHOME equ 00000010b ;LCDcursorpositionreset.
L_DDFREQ equ 10000000b+01h ;LCD"Frequency"DDRAMaddr.
L_DDMODE equ 10000000b+4Ch ;LCD"Mode" DDRAMaddr.
L_DDINP1 equ 10000000b+40h ;LCD"Input" DDRAMaddr1.
L_DDINP2 equ 10000000b+46h ;LCD"Input" DDRAMaddr2.
L_DDGATE equ 10000000b+4Fh ;LCD"Gate" DDRAMaddr.

;-------------------------------------------------------------------------
;Registerfile(=Workarea)definitions.
;
;Notes:Lowerbyteislocatedfirstonlonglengthvariables.
; $ $+1$+2
; (Intelformat.Ex:186A0h->A0 86 01)
;-------------------------------------------------------------------------

org 0Ch

;-----General.

I ds 4 ;Generalloopcounter.
X ds 4 ;Source registerforlongwordcalc.
EX ds 4 ;Extrasourceregisterformul/div.
Y ds 4 ;Destination registerforlongwordcalc.
EY ds 4 ;Extradest. registerformul/div.

;-----Forcountprocedure.

CNTMODE ds 1 ;Temporaryinputbuffer.

DSPMODE ds 1 ;Displaymode.
EXT_PSC ds 1 ;Externalprescalermode.
INT_PSC ds 1 ;Internalprescalermode.
RESMODE ds 1 ;Resolutionmode.

GATETIME ds 2 ;Gatetimeinmilliseconds.
RTC_OLD ds 1 ;RTCCpreviousvalue.
RTC_NEW ds 1 ;RTCCnewvalue.
CNT ds 3 ;Countvalue.

;-----ForLCDprocedure.

LCD_RSEL ds 1 ;LCDregisterselect.
LCD_DATA ds 1 ;LCDcommandorcharacterdata.
LCD_STRBUF ds MAXDIGIT ;LCDstringbuffer.
LCD_DPOINT ds 1 ;LCDdecimalpointlocation.
LCD_FXMPTR ds 1 ;LCDfixedmessagepointer.

;-----Forcalculationprocedure.

MDLOOPCT ds 1 ;Loopcounterformul/div.
CALCTMP1 ds 5 ;Temporarybufferforcalculation.
CALCTMP2 ds 5 ;Temporarybufferforcalculation.

;-----Forwaitprocedure.

WAIT1 ds 1 ;Forlargeloop.
WAIT2 ds 1 ;Forsmallloop.

;-------------------------------------------------------------------------
;Programentry.
;-------------------------------------------------------------------------

org 0
goto main
nop
nop
nop
goto main

;-------------------------------------------------------------------------
;Stringtables.
;-------------------------------------------------------------------------

s_kHz
retlw ’’ ;"kHz".
retlw ’k’ ;
retlw ’H’ ;
retlw ’z’ ;
retlw 0 ;

s_MHz
retlw ’’ ;"MHz".
retlw ’M’ ;
retlw ’H’ ;
retlw ’z’ ;
retlw 0 ;

s_m
retlw ’’ ;"m ".
retlw ’m’ ;
retlw ’’ ;
retlw ’’ ;
retlw 0 ;

s_LFMode
retlw ’L’ ;"LF".
retlw ’F’ ;
retlw 0 ;

s_MFmode
retlw ’M’ ;"MF".
retlw ’F’ ;
retlw 0 ;

s_MHmode
retlw ’M’ ;"MH".
retlw ’H’ ;
retlw 0 ;

s_HFmode
retlw ’H’ ;"HF".
retlw ’F’ ;
retlw 0 ;

s_xpsHDR
retlw ’I’ ;"INPUT".
retlw ’N’ ;
retlw ’P’ ;
retlw ’U’ ;
retlw ’T’ ;
retlw ’:’ ;
retlw 0 ;

s_xpsOFF
retlw ’A’ ;"A".
retlw 0 ;(Externalprescaler:OFF)

s_xpsON
retlw ’B’ ;"B".
retlw 0 ;(Externalprescaler:ON)

s_over
retlw ’T’ ;"TooLong!!"
retlw ’o’ ;
retlw ’o’ ;
retlw ’’ ;
retlw ’L’ ;
retlw ’o’ ;
retlw ’n’ ;
retlw ’g’ ;
retlw ’’ ;
retlw ’!’ ;
retlw ’!’ ;
retlw 0 ;

;-------------------------------------------------------------------------
;Datatables.
;-------------------------------------------------------------------------

;-----GetInternalprescalerrate.-------------------------------------

get_iprate
addwf pcl,f
retlw 1 ;1:1.
retlw 4 ;1:4.
retlw 8 ;1:8.
retlw 16 ;1:16.

;-----GetInternalprescalerrateforTMR0.----------------------------

get_iprtm0
addwf pcl,f
retlw TMR0_1 ;1:1.
retlw TMR0_4 ;1:4.
retlw TMR0_8 ;1:8.
retlw TMR0_16 ;1:16.

;-----Getmessageaddressofinternalprescalermode.------------------

get_ipmptr
addwf pcl,f
retlw s_LFmode ;"LF".
retlw s_MFmode ;"MF".
retlw s_MHmode ;"MH".
retlw s_HFmode ;"HF".

;-----Getdecimalpointlocation.--------------------------------------

get_dploc
addwf pcl,f
retlw 3 ; X.XXXkHz.
retlw 5 ;X.XXXXXMHz.
retlw 4 ; X.XXXXMHz.
retlw 3 ; X.XXXMHz.

;-------------------------------------------------------------------------
;Interruptprocedure.
;-------------------------------------------------------------------------

; Nointerruptprocedure.

;-------------------------------------------------------------------------
;Mainprocedure.
;-------------------------------------------------------------------------

main

; ***Initializeregisters***

clrf pclath ;Selectprogrammemorybank#0.

MOV lw 00000000b ;Disabledallinterrupt
MOV wf intcon ;sources.

clrf porta ;InitializeI/Oports.
clrf portb ;

bsf status,rp0 ;Selectbank1.

MOV lw 00101000b ;Pull-upPORTB,T0CS=EXT&
MOV wf option ;setTMR0rate.(1:1)

MOV lw 00010000b ;Setdatadirections.
MOV wf trisa ; 1:asinput.
MOV lw 00111111b ;
MOV wf trisb ;

bcf status,rp0 ;Selectbank0.(Default)

MOV lw 11110000b ;Setalloutputportsto’0’.
andwf porta,f ;
MOV lw 00111111b ;
andwf portb,f ;

; ***Initializevariable***

clrf CNT+0 ;Clearcounterfor
clrf CNT+1 ;dummydisplay.
clrf CNT+2 ;

; ***InitializeLCD***

call init_LCD ;Containsfunctionset&clearscreen.
call dsp_fixmsg ;Displayfixedmessage.

; ***MainLoop***

mainloop
call set_cntmode ;Setcountmode.(Gatetimeetc.)
call dsp_status ;Displaystatus.

MOV f DSPMODE,f ;Checkdisplaymode.
btfss status,z ;
goto len_mode ;

call dsp_freq ;Displayfrequency.
goto cntstart
len_mode
call dsp_leng ;Displaywavelength.
cntstart
call dsp_goff ;Display"GateOFF".
call dsp_gon ;Display"GateON".
call count ;Countcore.

goto mainloop

;-------------------------------------------------------------------------
;Setcountmode.
; Input:PortB (Datainputportofcountmode)
; Output:DSPMODE (Displaymode)
; EXT_PSC (Externalprescalermode)
; INT_PSC (Internalprescalermode)
; RESMODE (Resolutionmode)
; GATETIME(Gatetimeinmilliseconds)
; Wregister&variableIwillbebroken.
;
; Notes:Allinputportsarenegativelogic.
;-------------------------------------------------------------------------

set_cntmode

; ***Getcountmodefrominputport***

MOV f portb,w ;Readinputport&
andlw 00111111b ;negatelogic.
xorlw 00111111b ;
MOV wf CNTMODE ;

andlw 00000011b ;Getresolutionmode.
MOV wf RESMODE ;

rrf CNTMODE,f ;Getinternalprescalermode.
rrf CNTMODE,f ;
MOV f CNTMODE,w ;
andlw 00000011b ;
MOV wf INT_PSC ;

rrf CNTMODE,f ;Getexternalprescalermode.
rrf CNTMODE,f ;
MOV f CNTMODE,w ;
andlw 00000001b ;
MOV wf EXT_PSC ;

rrf CNTMODE,f ;Getdisplaymode.
MOV f CNTMODE,w ;
andlw 00000001b ;
MOV wf DSPMODE ;

; ***Setgatetime***

MOV lw FRES_100 ;Setgatetimesoonif
subwf RESMODE,w ;resolution>=100Hz.
btfsc status,c ;
goto set_gtime ;

MOV f EXT_PSC,f ;Checkothermode
btfsc status,z ;ifexternalprescalerisenabled&
goto set_gtime ;internalprescalerrate<>1:1.
;
MOV f INT_PSC,f ;
btfsc status,z ;
goto set_gtime ;

MOV lw IPSC_16 ;Resolution=100Hzif
subwf INT_PSC,w ;internalprescalerrate=1:16,
MOV lw FRES_10 ;elseresolution=10Hz.
btfsc status,c ;
MOV lw FRES_100 ;
;
MOV wf RESMODE ;
set_gtime
MOV lw 1 ;X<-externalprescalerrate
MOV f EXT_PSC,f ; *internalprescalerrate
btfss status,z ; *1000.
MOV lw XPSC_RATE ;
;
MOV wf X+0 ;
clrf X+1 ;
clrf X+2 ;
clrf X+3 ;
;
MOV f INT_PSC,w ;
call get_iprate ;
MOV wf Y+0 ;
clrf Y+1 ;
clrf Y+2 ;
clrf Y+3 ;
;
call mul_xy ;
;
MOV lw 0e8h ;
MOV wf Y+0 ;
MOV lw 03h ;
MOV wf Y+1 ;
call mul_xy ;

MOV lw 10 ;X<-X/10whileI>0.
MOV wf Y+0 ;(SkipsoonifRESMODE=FRES_1)
clrf Y+1 ;
;
MOV f RESMODE,w ;
btfsc status,z ;
goto end_sgt ;
;
MOV wf I ;
sgt_loop ;
call div_xy ;
;
decfsz I ;
goto sgt_loop ;
end_sgt
MOV f X+0,w ;GATETIME<-X.
MOV wf GATETIME+0 ;
MOV f X+1,w ;
MOV wf GATETIME+1 ;

; ***SetInternalprescalerrate***

MOV f INT_PSC,w ;GetTMR0rate.
call get_iprtm0 ;

bsf status,rp0 ;Selectbank1.
MOV wf option ;setnewTMR0rate.
bcf status,rp0 ;Selectbank0.(Default)

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Countprocedure.
; Input:GATETIME(Gatetimeinmilliseconds)
; Output:CNT(Value)
; Wregister&variableI,X,Ywillbebroken.
;-------------------------------------------------------------------------

count

; ***Prologue***

MOV f GATETIME+0,w ;I<-GATETIME*100.
MOV wf X+0 ;(Convertmillisecondsto
MOV f GATETIME+1,w ; 10microseconds)
MOV wf X+1 ;
clrf X+2 ;I:Countloopcounter.
clrf X+3 ;(Uselower24bits)
;
MOV lw 64h ;
MOV wf Y+0 ;
clrf Y+1 ;
clrf Y+2 ;
clrf Y+3 ;
;
call mul_xy ;
;
MOV f X+0,w ;
MOV wf I+0 ;
MOV f X+1,w ;
MOV wf I+1 ;
MOV f X+2,w ;
MOV wf I+2 ;

clrf CNT+0 ;Clearpulsecounter.
clrf CNT+1 ;
clrf CNT+2 ;

;ClearRTCC&initOLDvalueofRTCC.
clrw ;(Butyoumaynotclearit)
MOV wf tmr0 ;RTCCisdisabledtoincrement
MOV wf RTC_OLD ;for2instructioncyclesafter
nop ;itismodified.

MOV lw 7 ;Wait10microseconds.
MOV wf I+3 ;
;
decfsz I+3 ;
goto $-1 ;
nop ;
nop ;
nop ;

; ***Pulsecounter(Gatetime=10microseconds*I)***

pulse_cnt
MOV f tmr0,w ;Incrementpulsecounter.
MOV wf RTC_NEW ;
MOV f RTC_OLD,w ;
subwf RTC_NEW,w ;
;
addwf CNT+0,f ;
MOV lw 1 ;
btfsc status,c ;
addwf CNT+1,f ;
btfsc status,c ;
addwf CNT+2,f ;

MOV f RTC_NEW,w ;OLD<-NEW.
MOV wf RTC_OLD ;

MOV lw 1 ;Decrementcounterforsubloop.
subwf I+0,f ;
btfss status,c ;
subwf I+1,f ;
btfss status,c ;
subwf I+2,f ;

nop ;Trim.

MOV f I+0,w ;ContinueifI>0.
iorwf I+1,w ;
iorwf I+2,w ;
btfss status,z ;
goto pulse_cnt ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;InitLCD.
; Input:None.
; Output:PortA,PortB(DataoutputportforLCD)
; LCD_RSEL(LCDregisterselectwhichalways0)
; Wregister&variableLCD_DATA,Iwillbebroken.
;
;Notes:Waitingtimeisaboutexecutiontime*2.7.
;-------------------------------------------------------------------------

init_LCD

; ***PowerONwait***

MOV lw 100 ;PowerONwaitforLCD.
call wait_ms ;(>=15milliseconds)

; ***Functionset(Dummy#1)***

clrf LCD_RSEL ;RS=’0’.
bcf portb,LCD_RS ;(Default)

MOV lw 11110000b ;Functionset.
andwf porta,f ;(Databus=8bits)
MOV lw 00000011b ;
iorwf porta,f ;

MOV lw 3 ;Repeat3times.
MOV wf I ;
Li_fsloop
bsf portb,LCD_LE ;Strobe.
nop ;
nop ;
bcf portb,LCD_LE ;

MOV lw 5 ;Wait>=4.1milliseconds.
call wait_ms ;

decfsz I ;ContinueifI>0.
goto Li_fsloop ;

; ***Functionset(Dummy#2)***

MOV lw 11110000b ;Functionset.
andwf porta,f ;(Databus=4bits)
MOV lw 00000010b ;
iorwf porta,f ;

bsf portb,LCD_LE ;Strobe.
nop ;
nop ;
bcf portb,LCD_LE ;

call wait_100us ;Wait>=100microseconds.

; ***Functionset(Real)***

MOV lw L_FNCSET ;Setrealfunction.
call set_LCD ;

; ***Others***

MOV lw L_DSPOFF ;DisplayOFF.
call set_LCD ;

call cls ;Cleardisplay.

MOV lw L_ENTSET ;Setentrymode.
call set_LCD ;

MOV lw L_DSPON ;DisplayON.
call set_LCD ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Displayfixedmessage.
; Input:None.
; Output:None.
; Wregister,variableLCD_DATA&LCD_FXMPTRwillbebroken.
;-------------------------------------------------------------------------

dsp_fixmsg

; ***Displaymessage***

MOV lw L_DDINP1 ;Setcursorto"Input".
call set_LCD ;(Headermessage)

MOV lw s_xpshdr ;Displayheadermessageof
MOV wf LCD_FXMPTR ;inputchannel.
call dsp_fixstr ;(Externalprescaler)

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Displaystatus.
; Input:INT_PSC (Internalprescalermode)
; EXT_PSC (Externalprescalermode)
; Output:None.
; Wregister,variableLCD_FXMPTRwillbebroken.
;-------------------------------------------------------------------------

dsp_status

; ***Displayinternalprescalermode***

MOV lw L_DDMODE ;Setcursorto"Mode".
call set_LCD ;

MOV f INT_PSC,w ;Getmessageaddress.
call get_ipmptr ;

MOV wf LCD_FXMPTR ;Displayinternalprescalermode.
call dsp_fixstr ;

; ***DisplayInputchannel(Ext.prescalermode)***

MOV lw L_DDINP2 ;Setcursorto"Input".
call set_LCD ;(Core)

MOV lw s_xpsOFF ;Setmessageaddress.
MOV f EXT_PSC,f ;
btfss status,z ;
MOV lw s_xpsON ;

MOV wf LCD_FXMPTR ;Displayinputchannel.
call dsp_fixstr ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Display"GateOpen".
; Input:None.
; Output:None.
; Wregisterwillbebroken.
;-------------------------------------------------------------------------

dsp_gon

; ***Displaymessage***

MOV lw L_DDGATE ;Setcursorto"Gate".
call set_LCD ;

bsf LCD_RSEL,L_SELDR ;Selectdataregister.

MOV lw ’*’ ;Setgatesign.
call set_LCD ;

clrf LCD_RSEL ;Settodefault.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Display"GateClose".
; Input:None.
; Output:None.
; Wregister&variableLCD_DATAwillbebroken.
;-------------------------------------------------------------------------

dsp_goff

; ***Displaymessage***

MOV lw L_DDGATE ;Setcursorto"Gate".
call set_LCD ;

bsf LCD_RSEL,L_SELDR ;Selectdataregister.

MOV lw ’’ ;Cleargatesign&
MOV wf LCD_DATA ;wait.
call set_LCDcmd ;
MOV lw 100 ;
call wait_ms ;

clrf LCD_RSEL ;Settodefault.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Displayfrequency.
; Input:CNT (Countvalue)
; RESMODE(Resolutionmode)
; Output:None.
; Wregister,variableX,EX,Y,EY,LCD_DPOINT&LCD_FXMPTR
; willbebroken.
;-------------------------------------------------------------------------

dsp_freq

; ***SetcursorlocationofLCD&convertcountdatatostring***

MOV lw L_DDFREQ ;Setcursorto"frequency".
call set_LCD ;

MOV f CNT+0,w ;Changecountdatato
MOV wf X+0 ;string.
MOV f CNT+1,w ;
MOV wf X+1 ;
MOV f CNT+2,w ;
MOV wf X+2 ;
clrf X+3 ;
clrf EX+0 ;
clrf EX+1 ;
clrf EX+2 ;
clrf EX+3 ;
call x_to_str ;

; ***Displayfrequency***

MOV f RESMODE,w ;Setdecimalpointlocation.
call get_dploc ;
MOV wf LCD_DPOINT ;

call dsp_value ;Displayvalue.

MOV lw s_kHz ;Addunit.(kHzorMHz)
MOV f RESMODE,f ;
btfss status,z ;
MOV lw s_MHz ;
;
MOV wf LCD_FXMPTR ;
call dsp_fixstr ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Displaywavelength.
; Input:CNT (Countvalue)
; RESMODE(Resolutionmode)
; Output:None.
; Wregister,variableI,X,EX,Y,EY,LCD_DPOINT&LCD_FXMPTR
; willbebroken.
;-------------------------------------------------------------------------

dsp_leng

; ***SetcursorlocationofLCD***

MOV lw L_DDFREQ ;Setcursorto"frequency".
call set_LCD ;

; ***Trimcountdata***

MOV f CNT+0,w ;X<-Countvalue.
MOV wf X+0 ;Y<-1000/Resolution.
MOV f CNT+1,w ;X<-X/Y.
MOV wf X+1 ;
MOV f CNT+2,w ;
MOV wf X+2 ;
clrf X+3 ;
clrf EX+0 ;
clrf EX+1 ;
clrf EX+2 ;
clrf EX+3 ;
;
MOV lw 10 ;
MOV wf Y+0 ;
clrf Y+1 ;
clrf Y+2 ;
clrf Y+3 ;
;
MOV f RESMODE,w ;
sublw FRES_1000 ;
btfsc status,z ;
goto dpln_cv0 ;
;
MOV wf I ;
dpln_trim ;
call div_xy ;
;
decfsz I ;
goto dpln_trim ;

; ***Convertdatatostring***

dpln_cv0
MOV f X+0,w ;Y<-X.
MOV wf Y+0 ;(Y:frequencyinkHz)
MOV f X+1,w ;
MOV wf Y+1 ;
MOV f X+2,w ;
MOV wf Y+2 ;
MOV f X+3,w ;
MOV wf Y+3 ;

iorwf Y+2,w ;Display"TooLong!!"
iorwf Y+1,w ;ifvalue=0.
iorwf Y+0,w ;(Lessthan1kHz)
btfss status,z ;
goto dpln_cv1 ;
;
MOV lw s_over ;
MOV wf LCD_FXMPTR ;
call dsp_fixstr ;
goto end_dpln ;
dpln_cv1
MOV lw 00h ;X<-300000000/Y
MOV wf X+0 ;(X:wavelengthinmm)
MOV lw 0A3h ;&converttostring.
MOV wf X+1 ;
MOV lw 0E1h ;
MOV wf X+2 ;
MOV lw 11h ;
MOV wf X+3 ;
call div_xy ;
call x_to_str ;

; ***Displaywavelength***

MOV lw 3 ;Setdecimalpointlocation.
MOV wf LCD_DPOINT ;(X.XXXm)

call dsp_value ;Displayvalue.
end_dpln
MOV lw s_m ;Addunit.(m)
MOV wf LCD_FXMPTR ;
call dsp_fixstr ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Displayvalue.(With0suppless&decimalpoint)
; Input:LCD_STRBUF(Stringbuffer)
; LCD_DPOINT(Decimalpointfromrightside)
; Output:None.
; W,Indexregister&variableIwillbebroken.
;-------------------------------------------------------------------------

dsp_value

; ***Initialize***

bsf LCD_RSEL,L_SELDR ;Selectdataregister.

MOV lw LCD_STRBUF ;Setpointerofstring.
MOV wf fsr ;

; ***DisplaysPACe(Zerosuppless)***

MOV lw MAXDIGIT-1 ;Setmaxspacecount.
MOV wf I ;(MAXDIGIT-1)
dspvl_l1
MOV f I,w ;Exitthisloopif
subwf LCD_DPOINT,w ;thisloc.=decimalpointor
btfsc status,z ;notzero.
goto dspvl_2s ;
;
MOV f indf,w ;
sublw ’0’ ;
btfss status,z ;
goto dspvl_2s ;

MOV lw ’’ ;Put’’.
call set_LCD ;

incf fsr ;Setlocationtonext.
decfsz I ;
goto dspvl_l1 ;

; ***Displaynumber&decimalpoint***

dspvl_2s
incf I ;Incrementcounter.
dspvl_l2
MOV f indf,w ;Displaynumber.
call set_LCD ;

incf fsr ;Decrementcounter&
decf I ;skipbelowifthisloc
MOV f I,w ;isnotdecimalpointloc.
subwf LCD_DPOINT,w ;
btfss status,z ;
goto dspvl_2e ;

MOV lw ’.’ ;Displaydecimalpoint.
call set_LCD ;
dspvl_2e
MOV f I,f ;ContinueifI>0.
btfss status,z ;
goto dspvl_l2 ;

; ***Returnfromsubroutine***

clrf LCD_RSEL ;Settodefault.
return

;-------------------------------------------------------------------------
;ConvertvalueofXtostring.(Fixed10digits)
; Input: X[0]-X[3](Value)
; EX[0]-EX[3]
; Output:LCD_STRBUF (BufferofstringforLCD)
; W,Indexregister&variableI,Y,EYwillbebroken.
;-------------------------------------------------------------------------

x_to_str

; ***Initialize***

MOV lw LCD_STRBUF ;Setpointerofstring.
addlw 9 ;(Tobottom)
MOV wf fsr

MOV lw 10 ;Setloopcounter&
MOV wf I ;Y.
MOV wf Y+0 ;
clrf Y+1 ;
clrf Y+2 ;
clrf Y+3 ;

; ***Conversionloop(32bits=10digitsmax)***

xts_loop
call div_xy ;X<-X/10.
MOV f EY+0,w ;EY(Lowestdigit)<-Xmod10.

addlw ’0’ ;ChangetoASCII&
MOV wf indf ;store.

decf fsr ;Setlocationtonext.
decfsz I ;
goto xts_loop ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Clearscreen.(display)
; Input:None.
; Output:None.
; Wregister&variableLCD_DATAwillbebroken.
;-------------------------------------------------------------------------

cls

; ***Cleardisplay***

MOV lw L_DSPCLR ;Cleardisplay.
MOV wf LCD_DATA ;
call set_LCDcmd ;

MOV lw 5 ;Wait.
call wait_ms ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;Displayfixedstring.(ASCIZstringonROM)
; Input:LCD_FXMPTR(PointeroffixedASCIZstringtable)
; Output:None.
; W,Indexregister,variable&LCD_FXMPTRwillbebroken.
;-------------------------------------------------------------------------

dsp_fixstr

; ***Initialize***

bsf LCD_RSEL,L_SELDR ;Selectdataregister.

; ***Displayloop***

dfs_loop
call get_fixchr ;Exitifcharacter=NULL.
addlw 0 ;
btfsc status,z ;
goto end_dfs ;

call set_LCD ;Displaycharacter.

incf LCD_FXMPTR ;Continue.
goto dfs_loop ;

; ***Returnfromsubroutine***

end_dfs
clrf LCD_RSEL ;Settodefault.
return

;-------------------------------------------------------------------------
;Getcharacterfromfixedmessagetable.
; Input:LCD_FXMPTR(PointeroffixedASCIZstringtable)
; Output:None.
; Wregisterwillbebroken.
;-------------------------------------------------------------------------

get_fixchr
MOV f LCD_FXMPTR,w ;Caution:UpperbyteofPCL
MOV wf pcl ;isalways0.

;-------------------------------------------------------------------------
;SetLCDcommandforstandardoperation.
; Input:Wregister(Command)
; Output:None.
; Wregister&variableLCD_DATAwillbebroken.
;-------------------------------------------------------------------------

set_LCD

; ***Setcommand***

MOV wf LCD_DATA
call set_LCDcmd
call wait_100us

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;SetLCDcommand(Instruction).
; Input:LCD_RSEL(LCDregisterselect)
; LCD_DATA(LCDdata)
; Output:PortA,PortB(DataoutputportforLCD)
; Wregisterwillbebroken.
;-------------------------------------------------------------------------

set_LCDcmd

; ***Selectregister***

bcf portb,LCD_RS ;Selectregister.
btfsc LCD_RSEL,L_SELDR ;
bsf portb,LCD_RS ;

; ***Senduppernibbles***

MOV lw 11110000b ;Setuppernibbles.
andwf porta,f ;
swapf LCD_DATA,w ;
andlw 00001111b ;
iorwf porta,f ;

bsf portb,LCD_LE ;Strobe.
nop ;
nop ;
bcf portb,LCD_LE ;
nop ;
nop ;

; ***Sendlowernibbles***

MOV lw 11110000b ;Setlowernibbles.
andwf porta,f ;
MOV f LCD_DATA,w ;
andlw 00001111b ;
iorwf porta,f ;

bsf portb,LCD_LE ;Strobe.
nop ;
nop ;
bcf portb,LCD_LE ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Add.(32bitssource+32bitsdestination)
; Input:X[0]-X[3](Source :32bits)
; Y[0]-Y[3](Destination:32bits)
; Output:X[0]-X[3](Answer :32bits)
; Wregisterwillbebroken.
;
;Allocations(MSB<->LSB):
; X[3]X[2]X[1]X[0]
; Y[3]Y[2]Y[1]Y[0]
;-------------------------------------------------------------------------

add_xy

; ***AddYtoX***

MOV f Y+0,w ;Lower.
addwf X+0,f ;
MOV lw 1 ;
btfsc status,c ;
addwf X+1,f ;
btfsc status,c ;
addwf X+2,f ;
btfsc status,c ;
addwf X+3,f ;

MOV f Y+1,w ;Middlelower.
addwf X+1,f ;
MOV lw 1 ;
btfsc status,c ;
addwf X+2,f ;
btfsc status,c ;
addwf X+3,f ;

MOV f Y+2,w ;Middleupper.
addwf X+2,f ;
MOV lw 1 ;
btfsc status,c ;
addwf X+3,f ;

MOV f Y+3,w ;Upper.
addwf X+3,f ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Subtract.(32bitssource-32bitsdestination)
; Input:X[0]-X[3](Source :32bits)
; Y[0]-Y[3](Destination:32bits)
; Output:X[0]-X[3](Answer :32bits)
; Wregisterwillbebroken.
;
;Allocations(MSB<->LSB):
; X[3]X[2]X[1]X[0]
; Y[3]Y[2]Y[1]Y[0]
;-------------------------------------------------------------------------

sub_xy

; ***SubtractYfromX***

MOV f Y+0,w ;Lower.
subwf X+0,f ;
MOV lw 1 ;
btfss status,c ;<-PositiveifCF=1.
subwf X+1,f ;
btfss status,c ;
subwf X+2,f ;
btfss status,c ;
subwf X+3,f ;

MOV f Y+1,w ;Middlelower.
subwf X+1,f ;
MOV lw 1 ;
btfss status,c ;
subwf X+2,f ;
btfss status,c ;
subwf X+3,f ;

MOV f Y+2,w ;Middleupper.
subwf X+2,f ;
MOV lw 1 ;
btfss status,c ;
subwf X+3,f ;

MOV f Y+3,w ;Upper.
subwf X+3,f ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Multiply.(32by32bits)
; Input: X[0]-X[3](Source :32bits)
; Y[0]-Y[3](Destination:32bits)
; Output:EX[0]-EX[3](Answer :64bits)
; X[0]-X[3]
; EY[0]-EY[3](AssameasX[0]-X[3])
;
; Wregisterwillbebroken.
;
;Notes:ReferredtoAKIZUKI’sPICsamplesoftware.
; Thisroutineusesthesametechnicofmanual-calculation.
;
;Example: 00010010(12h)
; x00110100(34h)
; ----------
; 00000000
; 00000000
; 00010010
; 00000000
; 00010010
; 00010010
; 00000000
; 00000000
; ------------------
; 0000001110101000(03A8h)
;
;Allocations(MSB<->LSB):
; EX[3]EX[2]EX[1]EX[0]X[3]X[2]X[1]X[0]
; EY[3]EY[2]EY[1]EY[0]Y[3]Y[2]Y[1]Y[0]
;-------------------------------------------------------------------------

mul_xy

; ***Initialize***

MOV f X+0,w ;EY<-X.
MOV wf EY+0 ;
MOV f X+1,w ;
MOV wf EY+1 ;
MOV f X+2,w ;
MOV wf EY+2 ;
MOV f X+3,w ;
MOV wf EY+3 ;

MOV f Y+0,w ;X<-Y.
MOV wf X+0 ;
MOV f Y+1,w ;
MOV wf X+1 ;
MOV f Y+2,w ;
MOV wf X+2 ;
MOV f Y+3,w ;
MOV wf X+3 ;

clrf EX+0 ;ClearEX.
clrf EX+1 ;
clrf EX+2 ;
clrf EX+3 ;

MOV lw 32 ;Setdatalength.
MOV wf MDLOOPCT ;

; ***Multiplyloop(32times)***

mul_loop
btfss X+0,0 ;SkipbelowifLSBofXL=’0’.
goto mul_next ;(EY*’0’=0)

bcf X+0,0 ;ClearalwaysLSBofX.

MOV f EY+0,w ;EX<-EX+EY.
addwf EX+0,f ;
MOV lw 1 ;SetLSBofXto’1’
btfsc status,c ;ifoverflow.(Setcarry)
addwf EX+1,f ;
btfsc status,c ;
addwf EX+2,f ;
btfsc status,c ;
addwf EX+3,f ;
btfsc status,c ;
bsf X+0,0 ;
;
MOV f EY+1,w ;
addwf EX+1,f ;
MOV lw 1 ;
btfsc status,c ;
addwf EX+2,f ;
btfsc status,c ;
addwf EX+3,f ;
btfsc status,c ;
bsf X+0,0 ;
;
MOV f EY+2,w ;
addwf EX+2,f ;
MOV lw 1 ;
btfsc status,c ;
addwf EX+3,f ;
btfsc status,c ;
bsf X+0,0 ;
;
MOV f EY+3,w ;
addwf EX+3,f ;
btfsc status,c ;
bsf X+0,0 ;
mul_next
bcf status,c ;RotateEX+Xtoright.
rrf EX+3 ;(LSBofX->MSBofEX)
rrf EX+2 ;
rrf EX+1 ;
rrf EX+0 ;
rrf X+3 ;
rrf X+2 ;
rrf X+1 ;
rrf X+0 ;
btfsc status,c ;
bsf EX+3,7 ;

decfsz MDLOOPCT,f ;Continueifloop>0.
goto mul_loop ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Divide.(64bitssourceby32bitsdestination)
; Input:EX[0]-EX[3](Source :64bits)
; X[0]-X[3]
; Y[0]-Y[3](Destination:32bits)
; Output:EX[0]-EX[3](Answer :64bits)
; X[0]-X[3]
; Y[0]-Y[3](Mod :32bits)
;
; Wregisterwillbebroken.
;
;Notes:ReferredtoAKIZUKI’sPICsamplesoftware.
; Thisroutineusesthesametechnicofmanual-calculation.
;
;Example: 0000000001100100(64h)
; +------------------
; (10h)1010|0000001111101000(03E8h)
; 1010
; -------------------
; 1011
; 1010
; -------------------
; 1010
; 1010
; -------------------
; 0
;
;Allocations(MSB<->LSB):
; EX[3]EX[2]EX[1]EX[0]X[3]X[2]X[1]X[0]
; EY[3]EY[2]EY[1]EY[0]Y[3]Y[2]Y[1]Y[0]
;-------------------------------------------------------------------------

div_xy

; ***Initialize***

clrf CALCTMP1+0 ;Cleartemporarybuffer.
clrf CALCTMP1+1 ;
clrf CALCTMP1+2 ;
clrf CALCTMP1+3 ;
clrf CALCTMP1+4 ;

MOV lw 64 ;Setdatalength.
MOV wf MDLOOPCT ;

; ***Divideloop(64times)***

div_loop
bcf status,c ;ShiftCALCTMP1(Mod)+EX+X
rlf X+0 ;toleft.
rlf X+1 ;
rlf X+2 ;
rlf X+3 ;
rlf EX+0 ;
rlf EX+1 ;
rlf EX+2 ;
rlf EX+3 ;
rlf CALCTMP1+0 ;
rlf CALCTMP1+1 ;
rlf CALCTMP1+2 ;
rlf CALCTMP1+3 ;
rlf CALCTMP1+4 ;

MOV f CALCTMP1+0,w ;CALCTMP2(Work)<-CALCTMP1.
MOV wf CALCTMP2+0 ;
MOV f CALCTMP1+1,w ;
MOV wf CALCTMP2+1 ;
MOV f CALCTMP1+2,w ;
MOV wf CALCTMP2+2 ;
MOV f CALCTMP1+3,w ;
MOV wf CALCTMP2+3 ;
MOV f CALCTMP1+4,w ;
MOV wf CALCTMP2+4 ;

MOV f Y+0,w ;CALCTMP2<-CALCTMP2-Y.
subwf CALCTMP2+0,f ;(Signedoperation)
MOV lw 1 ;
btfss status,c ;<-PositiveifCF=1.
subwf CALCTMP2+1,f ;
btfss status,c ;
subwf CALCTMP2+2,f ;
btfss status,c ;
subwf CALCTMP2+3,f ;
btfss status,c ;
subwf CALCTMP2+4,f ;
;
MOV f Y+1,w ;
subwf CALCTMP2+1,f ;
MOV lw 1 ;
btfss status,c ;
subwf CALCTMP2+2,f ;
btfss status,c ;
subwf CALCTMP2+3,f ;
btfss status,c ;
subwf CALCTMP2+4,f ;
;
MOV f Y+2,w ;
subwf CALCTMP2+2,f ;
MOV lw 1 ;
btfss status,c ;
subwf CALCTMP2+3,f ;
btfss status,c ;
subwf CALCTMP2+4,f ;
;
MOV f Y+3,w ;
subwf CALCTMP2+3,f ;
MOV lw 1 ;
btfss status,c ;
subwf CALCTMP2+4,f ;

btfsc CALCTMP2+4,7 ;SkipbelowifCALCTMP2<0.
goto div_next ;(MSBofCALCTMP2is’1’)

MOV f CALCTMP2+0,w ;CALCTMP1(Mod)<-CALCTMP2&
MOV wf CALCTMP1+0 ;LSBofX<-’1’.
MOV f CALCTMP2+1,w ;
MOV wf CALCTMP1+1 ;
MOV f CALCTMP2+2,w ;
MOV wf CALCTMP1+2 ;
MOV f CALCTMP2+3,w ;
MOV wf CALCTMP1+3 ;
MOV f CALCTMP2+4,w ;
MOV wf CALCTMP1+4 ;
;
bsf X+0,0 ;
div_next
decfsz MDLOOPCT,f ;Continueifloop>0.
goto div_loop ;

; ***Returnfromsubroutine***

MOV f CALCTMP1+0,w ;EY(Mod)<-CALCTMP1.
MOV wf EY+0 ;
MOV f CALCTMP1+1,w ;
MOV wf EY+1 ;
MOV f CALCTMP1+2,w ;
MOV wf EY+2 ;
MOV f CALCTMP1+3,w ;
MOV wf EY+3 ;

return

;-------------------------------------------------------------------------
;General:Rotateleft.(16bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

rl16

; ***Rotateleft***

MOV wf fsr

bcf status,c ;Set’0’onLSB.
rlf indf,f ;Lower.
incf fsr,f
rlf indf,f ;Upper.

decf fsr,f
btfsc status,c
bsf indf,0 ;Set’1’onLSBifCF=’1’.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Rotateright.(16bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

rr16

; ***Rotateright***

MOV wf fsr

incf fsr,f

bcf status,c ;Set’0’onMSB.
rrf indf,f ;Upper.
decf fsr,f
rrf indf,f ;Lower.

incf fsr,f
btfsc status,c
bsf indf,7 ;Set’1’onMSBifCF=’1’.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Rotateleft.(32bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

rl32

; ***Rotateleft***

MOV wf fsr

bcf status,c ;Set’0’onLSB.
rlf indf,f ;Lower.
incf fsr,f
rlf indf,f ;Middlelower.
incf fsr,f
rlf indf,f ;Middleupper.
incf fsr,f
rlf indf,f ;Upper.

decf fsr,f
decf fsr,f
decf fsr,f
btfsc status,c
bsf indf,0 ;Set’1’onLSBifCF=’1’.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Rotateright.(32bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

rr32

; ***Rotateright***

MOV wf fsr

incf fsr,f
incf fsr,f
incf fsr,f

bcf status,c ;Set’0’onMSB.
rrf indf,f ;Upper.
decf fsr,f
rrf indf,f ;Middleupper.
decf fsr,f
rrf indf,f ;Middlelower.
decf fsr,f
rrf indf,f ;Lower.

incf fsr,f
incf fsr,f
incf fsr,f
btfsc status,c
bsf indf,7 ;Set’1’onMSBifCF=’1’.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:shiftleft.(16bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

sl16

; ***Shiftleft***

MOV wf fsr

bcf status,c ;Set’0’onLSB.
rlf indf,f ;Lower.
incf fsr,f
rlf indf,f ;Upper.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Shiftright.(16bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

sr16

; ***Shiftright***

MOV wf fsr

incf fsr,f

bcf status,c ;Set’0’onMSB.
rrf indf,f ;Upper.
decf fsr,f
rrf indf,f ;Lower.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Shiftleft.(32bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

sl32

; ***Shiftleft***

MOV wf fsr

bcf status,c ;Set’0’onLSB.
rlf indf,f ;Lower.
incf fsr,f
rlf indf,f ;Middlelower.
incf fsr,f
rlf indf,f ;Middleupper.
incf fsr,f
rlf indf,f ;Upper.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Shiftright.(32bitslength)
; Input:W(Pointerofentry)
;-------------------------------------------------------------------------

sr32

; ***Shiftright***

MOV wf fsr

incf fsr,f
incf fsr,f
incf fsr,f

bcf status,c ;Set’0’onMSB.
rrf indf,f ;Upper.
decf fsr,f
rrf indf,f ;Middleupper.
decf fsr,f
rrf indf,f ;Middlelower.
decf fsr,f
rrf indf,f ;Lower.

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Waitprocedure.
; Input:W(Timeinmilliseconds)
; Output:None.
; Wregister&variableWAIT1,WAIT2willbebroken.
;-------------------------------------------------------------------------

wait_ms

; ***Waitloop***

MOV wf WAIT1 ;Setmillisecondsloopcounter.
wm_loop1
MOV lw 249 ;Setmicrosecondsloopcounter.
MOV wf WAIT2 ;(996microseconds/4)
wm_loop2
nop
nop
nop
nop
nop
nop
nop
decfsz WAIT2 ;Continueifloop2>0.
goto wm_loop2 ;

nop
nop
nop
nop
nop
nop
decfsz WAIT1 ;Continueifloop1>0.
goto wm_loop1 ;

; ***Returnfromsubroutine***

return

;-------------------------------------------------------------------------
;General:Waitprocedure.(Fixed100microseconds)
; Input:None.
; Output:None.
; Wregister&variableWAIT1willbebroken.
;-------------------------------------------------------------------------

wait_100us

; ***Waitloop***

MOV lw 48 ;Set100microsecondsloopcounter.
MOV wf WAIT1 ;(96microseconds)
wu_loop
nop
nop
decfsz WAIT1 ;Continueifloop>0.
goto wu_loop ;

; ***Returnfromsubroutine***

nop
nop
nop
nop
nop
return

;EndofCOUNTER.ASM


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

倫敦2024年8月29日 /美通社/ -- 英國(guó)汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開(kāi)發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動(dòng) BSP

北京2024年8月28日 /美通社/ -- 越來(lái)越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來(lái)越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對(duì)日本游戲市場(chǎng)的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)開(kāi)幕式在貴陽(yáng)舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語(yǔ)權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對(duì)環(huán)境變化,經(jīng)營(yíng)業(yè)績(jī)穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤(rùn)率延續(xù)升勢(shì) 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長(zhǎng) 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競(jìng)爭(zhēng)力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競(jìng)爭(zhēng)優(yōu)勢(shì)...

關(guān)鍵字: 通信 BSP 電信運(yùn)營(yíng)商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺(tái)與中國(guó)電影電視技術(shù)學(xué)會(huì)聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會(huì)上宣布正式成立。 活動(dòng)現(xiàn)場(chǎng) NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長(zhǎng)三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會(huì)上,軟通動(dòng)力信息技術(shù)(集團(tuán))股份有限公司(以下簡(jiǎn)稱"軟通動(dòng)力")與長(zhǎng)三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉