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

📄 macros.lib

📁 frequence metre to mesure the frequence of a signal
💻 LIB
字号:
           nolist
;_____________________________________________________________________
;
;                       General purpose macros
;_____________________________________________________________________
;
; You must define IntSaveW and IntSaveStatus in main program for use
;Pop and Push macros.
;
; Sorted in alphabethical order
;
Addlf      macro      literal,file          ; file = (file) + literal
           movf       file,w
           addlw      literal
           movwf      file
           endm
;
Addwfc     macro      file                  ;  file = (file) + (w) + Cy
           SkipNC
           incfsz     file,f
           addwf      file,w
           movwf      file
           endm
;
Andlf      macro      literal,file          ; file = (file) AND literal
           movf       file,w
           andlw      literal
           movwf      file
           endm
;
Bank0      macro                            ; Select register bank 0
           bcf        STATUS,RP0
           endm
;
Bank1      macro                            ; Select register bank 1
           bsf        STATUS,RP0
           endm
;
CallC      macro      sub                   ; Call subroutine if C = 1
           SkipNC
           call       sub
           endm
;
CallNC     macro      sub                   ; Call subroutine if C = 0
           SkipC
           call       sub
           endm
;
CallNZ     macro      sub                   ; Call subroutine if Z = 0
           SkipZ
           call       sub
           endm
;
CallZ      macro      sub                   ; Call subroutine if Z = 1
           SkipNZ
           call       sub
           endm
;
CJE        macro      file1,file2,address   ; Jump if (file1) = (file2)
           movf       file1,w
           xorwf      file2,w
           SkipNZ
           goto       address
           endm
;
CJEl       macro      file,literal,address  ; Jump if (file) = literal
           movlw      literal
           xorwf      file,w
           SkipNZ
           goto       address
           endm
;
CJNE       macro      file1,file2,address   ; Jump if (file1) # (file2)
           movf       file1,w
           xorwf      file2,w
           SkipZ
           goto       address
           endm
;
CJNEl      macro      file,literal,address  ; Jump if (file) # literal
           movlw      literal
           xorwf      file,w
           SkipZ
           goto       address
           endm
;
CJA        macro      file1,file2,address   ; Jump if (file1) > (file2)
           movf       file1,w
           subwf      file2,w
           SkipC
           goto       address
           endm
;
CJAE       macro      file1,file2,address   ; Jump if (file1) >= (file2)
           movf       file2,w
           subwf      file1,w
           skipNC
           goto       address
           endm
;
CJAEl      macro      file,literal,address  ; Jump if (file) >= literal
           movlw      literal
           subwf      file,w
           SkipNC
           goto       address
           endm
;
CJAl       macro      file,literal,address  ; Jump if (file) > literal
           movf       file,w
           sublw      literal
           SkipC
           goto       address
           endm
;
CJB        macro      file1,file2,address   ; Jump if (file1) < (file2)
           movf       file2,w
           subwf      file1,w
           SkipC
           goto       address
           endm
;
CJBE       macro      file1,file2,address   ; Jump if (file1) <= (file2)
           movf       file1,w
           subwf      file2,w
           SkipNC
           goto       address
           endm
;
CJBEl      macro      file,literal,address  ; Jump if (file) <= literal
           movf       file,w
           sublw      literal
           SkipNC
           goto       address
           endm
;
CJBl       macro      file,literal,address  ; Jump if (file) < literal
           movlw      literal
           subwf      file,w
           SkipC
           goto       address
           endm
;
ComC       macro                            ; Complement carry
           movf       STATUS,w
           xorlw      1
           movwf      STATUS
           endm
;
ComW       macro                            ; Complement W
           xorlw      0FFH
           endm
;
Com2W      macro                            ; 2's complement of W
           sublw      0
           endm
;
Continue   macro      address               ; Used with While, Repeat, etc.
           goto       address
           endm
;
Dnop       macro                            ; Double NOP
           goto       $+1
           endm
;
Dec16      macro      var16                 ; Decrement a 16 bit variable
           decf       var16 + 1,f
           CJNEl      var16 + 1,0FFH,Dec16_End
           decf       var16,f
Dec16_End  
           endm
;
Inc16      macro      var16                 ; Increment a 16 bit variable
           incf       var16 + 1
           SkipNZ
           incf       var16
           endm
;
IncW       macro                            ; Increment W
           addlw      1
           endm
;
InitFile   macro      file,value            ; file = literal
           Movlf      value,file
           endm
;
InitFSR    macro      address               ; FSR = address
           Movlf      address,FSR
           endm
;
InitPortA  macro      config                ; Init PORTA with config
           clrf       PORTA
           Bank1
           movlw      config
           movwf      PORTA
           Bank0
           endm
;
InitPortB  macro      config                ; Init PORTB with config, PullUp
           clrf       PORTB
           Bank1
           movlw      config
           movwf      PORTB
           bcf        INTCON,RBIF
           if         PULLUP == YES
           bcf        OPTION_REG,7
           endif
           Bank0
           endm
;
InitPorts  macro
           InitPortA  CONFIGA
           InitPortB  CONFIGB
           endm
;
InitVector macro      vector, address
           org        vector
           goto       address
           endm
;
IntReq     macro      adresse               ; Jump to Interrupt Request sub
           org        4
           goto       adresse
           endm
;
JC         macro      address               ; Jump if Carry bit = 1
           btfsc      STATUS,C
           goto       address
           endm
;
JNC        macro      address               ; Jump if Carry bit = 0
           btfss      STATUS,C
           goto       address
           endm
;
JNZ        macro      address               ; Jump if Zero bit = 0
           btfss      STATUS,Z
           goto       address
           endm
;
JZ         macro      address               ; Jump if Zero bit = 1
           btfsc      STATUS,Z
           goto       address
           endm
;
Movff      macro      file1,file2           ; file2 = (file1)
           movf       file1,w
           movwf      file2
           endm
;
Movlf      macro      literal,file          ; file = literal
           movlw      literal
           movwf      file
           endm
;
Iorlf      macro      literal,file          ; file = (file) OR literal
           movf       file,w
           iorlw      literal
           movwf      file
           endm
;
Pop        macro                            ; Restore W and STATUS in end
           swapf      IntSaveSTATUS,W       ;of interrupt
           movwf      STATUS
           swapf      IntSaveW,F
           swapf      IntSaveW,W
           endm
;
Push       macro                            ; Save W and STATUS during
           movwf      IntSaveW              ;interrupt
           swapf      STATUS,W
           movwf      IntSaveSTATUS
           endm
;
Reset      macro      adresse               ; Jump to Reset address
           org        0
           goto       adresse
           endm
;
SkipC      macro                            ; Skip next instruction
           btfss      STATUS,C              ;      if Carry bit = 1
           endm
;
SkipNC     macro                            ; Skip next instruction
           btfsc      STATUS,C              ;      if Carry bit = 0
           endm
;
SkipNZ     macro                            ; Skip next instruction
           btfsc      STATUS,Z              ;      if Zero bit = 0
           endm
;
SkipZ      macro                            ; Skip next instruction
           btfss      STATUS,Z              ;      if Zero bit = 1
           endm
;
Sublf      macro      literal,file          ; file = (file) - literal
           movf       file,w
           sublw      literal
           movwf      file
           endm
;
Test       macro      file                  ; Test if (file) = 0
           movf       file,f
           endm
;
Xorlf      macro      literal,file          ; file = (file) XOR literal
           movf       file,w
           xorlw      literal
           movwf      file
           endm
;
           list

⌨️ 快捷键说明

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