hotrodhed120
Member
Hello guys, I'm a beginner in the programming pic department but, I'm getting to the point to where interrupts are starting to look more appealing but I have a couple of brief question about them first.
This piece of code is from the pic mcu ref manual and I was wandering why you have to SWPF the status reg when you save them.
Also, could I get a good explanation of what a macro is? Is it basically just a kind of subroutine, and why is there no call?
Thanks for any help you can give.
This piece of code is from the pic mcu ref manual and I was wandering why you have to SWPF the status reg when you save them.
Also, could I get a good explanation of what a macro is? Is it basically just a kind of subroutine, and why is there no call?
Code:
PUSH_MACRO MACRO ; This Macro Saves register contents
MOVWF W_TEMP ; Copy W to a Temporary Register
; regardless of current bank
SWAPF STATUS,W ; Swap STATUS nibbles and place
; into W register
MOVWF STATUS_TEMP ; Save STATUS to a Temporary register
; in Bank0
ENDM ; End this Macro
;
POP_MACRO MACRO ; This Macro Restores register contents
SWAPF STATUS_TEMP,W ; Swap original STATUS register value
; into W (restores original bank)
MOVWF STATUS ; Restore STATUS register from
; W register
SWAPF W_TEMP,F ; Swap W_Temp nibbles and return
; value to W_Temp
SWAPF W_TEMP,W ; Swap W_Temp to W to restore original
; W value without affecting STATUS
ENDM ; End this Macro
Thanks for any help you can give.