;*************************************************************** ;* Macro LONGC ;Long Call ;by Walter Quitt ;*************************************************************** LONGC MACRO SUBROUTINE bsf CPUSTA,GLINTD ;interrupts off movlw HIGH (SUBROUTINE) movfp WREG,PCLATH ;Z unaffected bcf CPUSTA,GLINTD ;interrupts on lcall LOW (SUBROUTINE) ENDM
Olin Lathrop [olin at cognivis.com] of cognivis (978) 772-3129 says
; ;******************** ; ; Macro SKIP_WLE ; ; Skip the next instruction if W was less than or equal to the value ; it was subtracted from. This assumes that the carry flag has been ; preserved from the last SUBWF or SUBLW instruction. ; skip_wle macro if fam_17 btfss alusta, c exitm endif btfss status, c ;skip if no borrow occurred endm ; ;******************** ; ; Macro SKIP_WGT ; ; Skip the next instruction if W was greater than the value ; it was subtracted from. This assumes that the carry flag has been ; preserved from the last SUBWF or SUBLW instruction. ; skip_wgt macro if fam_17 btfsc alusta, c exitm endif btfsc status, c ;skip if a borrow occurred endm ; ;******************** ; ; Macro SKIP_Z ; ; Skip the next instruction if the zero flag is set. ; skip_z macro if fam_17 btfss alusta, z exitm endif btfss status, z endm ; ;******************** ; ; Macro SKIP_NZ ; ; Skip the next instruction if the zero flag is not set. ; skip_nz macro if fam_17 btfsc alusta, z exitm endif btfsc status, z endm ; ;******************** ; ; Macro SKIP_CARR ; ; Skip the next instruction if a carry occurred. ; skip_carr macro if fam_17 btfss alusta, c exitm endif btfss status, c endm ; ;******************** ; ; Macro SKIP_NCARR ; ; Skip the next instruction if no carry occurred. ; skip_ncarr macro if fam_17 btfsc alusta, c exitm endif btfsc status, c endm ; ;******************** ; ; Macro SKIP_BORR ; ; Skip the next instruction if a borrow occurred. ; skip_borr macro if fam_17 btfsc alusta, c exitm endif btfsc status, c endm ; ;******************** ; ; Macro SKIP_NBORR ; ; Skip the next instruction if no borrow occurred. ; skip_nborr macro if fam_17 btfss alusta, c exitm endif btfss status, c endm ; ;******************** ; ; Macro INTR_OFF ; ; Globally disable interrupts without changing which interrupts are ; individually disabled. This macro together with INTR_ON can be used ; around small sections of code that need to run with interrupts off. ; intr_off macro if fam_16 bcf intcon, gie endif if fam_17 bsf cpusta, glintd endif endm ; ;******************** ; ; Macro INTR_ON ; ; Globally enable interrupts without changing which interrupts are ; individually enabled. This macro together with INTR_OFF can be used ; around small sections of code that need to run with interrupts off. ; intr_on macro if fam_16 bsf intcon, gie endif if fam_17 bcf cpusta, glintd endif endm
Simon says:
BETTER?: intr_off macro if fam_16 foo: bcf intcon, gie btfsc intcon, gie goto foo endif if fam_17 bar: bsf cpusta, glintd btfss cpusta, glintd goto bar endif endm cut & paste of the reasoning behind the code from Thomas' code: ;If an IRQ happens when the "bcf intcon,gie" line is executing, ;the GIE bit will be cleared, but the interrupt will still occur. ;If the interrupt routine has a RETFIE instruction at the ;end, (which is the usual state of affairs),then GIE will ;be set to 1 again.
Questions:
What does the LONGC macro do ? Why would anyone ever want to use it ? I'm missing the point."
file: /Techref/microchip/17inst.htm, 4KB, , updated: 2004/8/11 22:26, local time: 2024/11/29 10:57,
3.137.219.68:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/microchip/17inst.htm"> microchip 17inst</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.