list ; MPASM Macro Definitions , by S.Nishioka ,2006/1/3 nolist ;Add literal into fr addr# macro fr,#lit movlw #lit addwf fr,1 endm ;Add frb into fra addrr macro fr1,fr2 movf fr2,0 addwf fr1,1 endm ;Add W into fr addrw macro fr,w addwf fr,1 endm ;Add fr into W addwr macro w,fr addwf fr,0 endm ;Add bit into fr ;addb macro fr,bit ;And literal into fr andr# macro fr,#lit movlw #lit andwf fr,1 endm ;And fr2 into fr1 andrr macro fr1,fr2 movf fr2,0 andwf fr1,1 endm ;And W into fr andrw macro fr,w andwf fr,1 endm ;And literal into W andw# macro w,#lit andlw #lit endm ;And fr into W andwr macro w,fr andwf fr,0 endm ;compare fr to literal and jump if above cjar# macro fr,#lit,addr9 movlw #lit ^ 0xff addwf fr,0 btfsc 3,0 goto addr9 endm ;compare fr1 to fr2 and jump if above cjarr macro fr1,fr2,addr9 movf fr1,0 subwf fr2,0 btfss 3,0 goto addr9 endm ;compare fr to literal and jump if above or equal. cjaer# macro fr,#lit,addr9 movlw #lit subwf fr,0 btfsc 3,0 goto addr9 endm ;compare fr1 to fr2 and jump if above or equal cjaerr macro fr1,fr2,addr9 movf fr2,0 subwf fr1,0 btfsc 3,0 goto addr9 endm ;compare fr to literal and jump if below cjbr# macro fr,#lit,addr9 movlw #lit subwf fr,0 btfss 3,0 goto addr9 endm ;compare fr1 to fr2 and jump if below cjbrr macro fr1,fr2,addr9 movf fr2,0 subwf fr1,0 btfss 3,0 goto addr9 endm ;compare fr to literal and jump if below or equal cjber# macro fr,#lit,addr9 movlw 0xff-#lit addwf fr,0 btfss 3,0 goto addr9 endm ;compare fr1 to fr2 and jump if below or equal cjberr macro fr1,fr2,addr9 movf fr1,0 subwf fr2,0 btfsc 3,0 goto addr9 endm ;compare fr to literal and jump if equal cjer# macro fr,#lit,addr9 movlw #lit subwf fr,0 btfsc 3,2 goto addr9 endm ;compare fr1 to fr2 and jump if equal cjerr macro fr1,fr2,addr9 movf fr2,0 subwf fr1,0 btfsc 3,2 goto addr9 endm ;compare fr to literal and jump if not equal cjner# macro fr,#lit,addr9 movlw #lit subwf fr,0 btfss 3,2 goto addr9 endm ;compare fr1 to fr2 and jump if not equal cjnerr macro fr1,fr2,addr9 movf fr2,0 subwf fr1,0 btfss 3,2 goto addr9 endm ;clear carry clc macro bcf 3,0 endm ;clear fr clr macro fr clrf fr endm ;clear W clw macro clrw endm ;clear the watchdog timer clwdt macro clrwdt endm ;clear bit clrb macro fr,bit bcf fr,bit endm ;clear zero clz macro bcf 3,2 endm ;compare fr to literal and skip if above csar# macro fr,#lit movlw 0xff-#lit addwf fr,0 btfss 3,0 endm ;compare fr1 to fr2 and skip if above csarr macro fr1,fr2 movf fr1,0 subwf fr2,0 btfsc 3,0 endm ;compare fr to literal and skip if above or equal csaer# macro fr,#lit movlw #lit subwf fr,0 btfss 3,0 endm ;compare fr1 to fr2 and skip if above or equal csaerr macro fr1,fr2 movf fr2,0 subwf fr1,0 btfss 3,0 endm ;compare fr to literal and skip if below csbr# macro fr,#lit movlw #lit subwf fr,0 btfsc 3,0 endm ;compare fr1 to fr2 and skip if below csbrr macro fr1,fr2 movf fr2,0 subwf fr1,0 btfsc 3,0 endm ;compare fr to literal and skip if below or equal csber# macro fr,#lit movlw 0xff - #lit addwf fr,0 btfsc 3,0 endm ;compare fr1 to fr2 and skip if below or equal csberr macro fr1,fr2 movf fr1,0 subwf fr2,0 btfss 3,0 endm ;compare fr to literal and skip if equal cser# macro fr,#lit movlw #lit subwf fr,0 btfss 3,2 endm ;compare fr1 to fr2 and skip if equal cserr macro fr1,fr2 movf fr2,0 subwf fr1,0 btfss 3,2 endm ;compare fr to literal and skip if not equal csner# macro fr,#lit movlw #lit subwf fr,0 btfsc 3,2 endm ;compare fr1 to fr2 and skip if not equal csnerr macro fr1,fr2 movf fr2,0 subwf fr1,0 btfsc 3,2 endm ;decrement fr dec macro fr decf fr,1 endm ;decrement fr and skip if zero decsz macro fr decfsz fr,1 endm ;decrement fr and jump if not zero djnz macro fr,addr9 decfsz fr,1 goto addr9 endm ;increment fr and jump if not zero ijnz macro fr,addr9 incfsz fr,1 goto addr9 endm ;increment fr inc macro fr incf fr,1 endm ;increment fr and skip if zero incsz macro fr incfsz fr,1 endm ;jump if bit jb macro fr,bit,addr9 btfsc fr,bit goto addr9 endm ;jump if carry jc macro addr9 btfsc 3,0 goto addr9 endm ;jump to address jmp macro addr9 goto addr9 endm ;jump to PC+W jmppcw macro addwf 2,1 endm ;jump to W jmpw macro movwf 2 endm ;jump if not bit jnb macro fr,bit,addr9 btfss fr,bit goto addr9 endm ;jump if not carry jnc macro addr9 btfss 3,0 goto addr9 endm ;jump if not zero jnz macro addr9 btfss 3,2 goto addr9 endm ;jump if zero jz macro addr9 btfsc 3,2 goto addr9 endm ;long call ;long jump ;long set movr# macro fr,#lit movlw #lit movwf fr endm movrr macro fr1,fr2 movf fr2,0 movwf fr1 endm movrw macro fr,w movwf fr endm ;movopt# macro #lit ;;;;;;;;;;;;; ; movlw #lit ; OPTION ; endm ;movoptr macro fr ; movf fr,0 ; OPTION ; endm ;movoptw macro ; OPTION ; endm ;movport# macro port,#lit ; movlw #lit ; TRIS port ; endm ;movportr macro port,fr ; movf fr,0 ; TRIS port ; endm ;movportw macro port,w ;;;;;;;;;;;;; ; TRIS port ; endm movw# macro w,#lit movlw #lit endm movwr macro w,fr movf fr,0 endm ;Move not fr into W movw_notr macro w,fr comf fr,0 endm ;Nove fr-W into W movw_rsubw macro w,fr sbwf fr,0 endm ;Move the incremented value of fr into W ;movw_incr ;Move the decremented value of fr into W ;movw_decr ;move the left-rotated value of fr into W ;movw_leftr ;Move the right-rotated value of fr into W ;movw_rightr ;Move the nibble-swapped value of fr into W ;movw_swapr ;Move bit2 to bit1 movb_b macro fr1,b1,fr2,b2 btfss fr2,b2 bcf fr1,b1 btfsc fr2,b2 bsf fr1,b1 endm ;Move not bit2 to bit1 movb_notb macro fr1,b1,fr2,b2 btfsc fr2,b2 bcf fr1,b1 btfss fr2,b2 bsf fr1,b1 endm ;Move the incremented value of fr into W and skip if zero ;movszw_incr ;Move the decremented value of fr into W and skip if zero ;movszw_decr ;Negate fr ;negr ;No operation ;nop ;Not fr not macro fr comf fr,1 endm ;Not W notw macro xorlw 0xff endm ;OR literal into fr orr# macro fr,#lit movlw #lit iorwf fr,1 endm ;OR fr2 into fr1 orrr macro fr1,fr2 movf fr2,0 iorwf fr1,1 endm ;OR W into fr orrw macro fr,w iorwf fr,1 endm ;OR literal into W orw# macro w,#lit iorlw #lit endm ;OR fr into W orwr macro w,fr iorwf fr,0 endm ;Return from subroutine ret macro retlw 0 endm ;Return from subroutine with literal in W #define retw dt ;retw macro #lit ; retlw #lit ; endm ;Return from interrupt reti macro retfie endm ;Rotate left fr rl macro fr rlf fr,1 endm ;Rotate right fr rr macro fr rrf fr,1 endm ;Skip if bit sb macro fr,bit btfss fr,bit endm ;Skip if carry sc macro btfss 3,0 endm ;Set bit setb macro fr,bit bsf fr,bit endm ;Skip skip macro btfsc 0x0A,7 ;misiyou@REG read as '0' endm ;Enter sleep mode ;sleep ;Skip if not bit snb macro fr,bit btfsc fr,bit endm ;Skip if not carry snc macro btfsc 3,0 endm ;Sip if not zero snz macro btfsc 3,2 endm ;Set carry stc macro bsf 3,0 endm ;Set zero stz macro bsf 3,2 endm ;Subtracrt literal from fr subr# macro fr,#lit movlw #lit subwf fr,1 endm ;Subtract fr2 from fr1 subrr macro fr1,fr2 movf fr2,0 subwf fr1,1 endm ;Subtract W from fr subrw macro fr,w subwf fr,1 endm ;Subtract bit from fr ;subb macro fr,bit ; btfss 3,0 ; decf fr,1 ; endm ;Swap nibbles in fr swap macro fr swapf fr,1 endm ;Skip if zero sz macro btfss 3,2 endm ;Test fr for zero test macro fr movf fr,1 endm ;Test W for zero testw macro iorlw 0x00 endm ;XOR literal into fr xorr# macro fr,#lit movlw #lit xorwf fr,1 endm ;XOR fr2 into fr1 xorrr macro fr1,fr2 movf fr2,0 xorwf fr1,1 endm ;XOR W into fr xorrw macro fr,w xorwf fr,1 endm ;XOR literal into W xorw# macro w,#lit xorlw #lit endm ;XOR fr into W xorwr macro w,fr xorwf fr,0 endm list