please dont rip this site

Microchip MPASM

Instruction set@

Macros for useing Motorola ASM code in MPASM (!)

Templates:

See:

See also:

Olin Lathrop says:

In this same, spirit I've made my own macros for handling bank switching and lots of other stuff public. My "standard" macros come in two include files, which are probably too large to attach to this message. I've set up a web site at http://www.embedinc.com/pic to eventually make most of my PIC development environment available to everyone.

John [jsand at PIXIE.CO.ZA] says:

After disabling interrupts i.e.
    bcf    intcon,gie

complete safety is not assured unless you check the global enable bit to see that it *really* is as expected (clear, that is).

My trouble with this magically vanished when I started to use macros for int. enable/disable:


int_off         MACRO                ;disables all interrupts
                     bcf intcon,gie
                     btfsc intcon,gie  ;make sure bit cleared (int could
                                       ;have occurred 1/2way thru instruction)
                     goto $-2
           ENDM

int_on         MACRO               ;re-enable interrupts
                     bsf intcon,gie
           ENDM

Simon Niel says:

...this might help avoid a few headaches with the '877 series...
; Bank[3:0] variables - 16 bytes accessible in all banks
          cblock    0x70
                    lo_save_w                 ; must be here as bank not known when interrupt occurs
                    program_status            ; flags for program operation
          ;
                    end_global_vars:0
          endc
          if end_global_vars > 0x80
                    error "Global variable space overrun"
          endif

; Bank 0 variables - Must not extend above 0x6F
          cblock    0x20
                    some_variable
          ;
                    end_bank_0_vars:0
          endc
          if end_bank_0_vars > 0x70
                    error "Bank0 variable space overrun"
          endif

; Bank 1 variables
          cblock    0xA0
                    more_variables:16
          ;
                    end_bank_1_vars:0
          endc
          if end_bank_1_vars > 0xf0
                    error "Bank1 variable space overrun"
          endif

; Bank 2 variables
          cblock    0x20
                    you_probably_get_the_point_now
          ;
                    end_bank_2_vars:0
          endc
          if end_bank_2_vars > 0x70
                    error "Bank2 variable space overrun"
          endif

; Bank 3 variables
          cblock    0xA0
                    oh_never_mind_then
          ;
                    end_bank_3_vars:0
          endc
          if end_bank_3_vars > 0xf0
                    error "Bank3 variable space overrun"
          endif

Jinx says:

OK, I hate unnecessary typing. I like little macros. These are some I use. Others will tell you of their distaste for macros. Don't listen to them !! ;-))) But you do need to be careful ... although a macro name is just one line in the editor, it could be several instructions, depending on what it does of course, and that affects things like GOTO $+. If you GOTO labels or can actually count the embedded instructions (on your fingers will do), you'll be OK. Use them just as normal mnemonics

For example, an awful lot of code behind these four lines. But the macros have been written so that these four easily-typed "instructions" really speed up development and minimise typos

;==============
;pr_v0    lcd_pos ln1+.06      ;position 6 on line 1
;         disp    0x7f         ;<- on LCD
;         sec1                 ;1 second delay
;         clrscrn              ;clear LCD
;==============

mov      macro   litval,file    ;eg  mov  .57,temp = load temp with dec 57
         movlw   litval
         movwf   file
         endm

movfw    macro   litval     ;eg movfw temp = copy temp to W
         movf    litval,w
         endm

skpnc    macro
         btfsc   carry
         endm

skpc     macro
         btfss   carry
         endm

clrc     macro               ;clear C
         bcf     status,0
         endm

clrz     macro             ;clear Z
         bcf     status,2
         endm

setz     macro
         bsf     status,2
         endm

skpz     macro            ;skip if Z is set
         btfss   status,2
         endm

skpnz    macro
         btfsc   status,2
         endm

usec     macro                ;1us delay
         movff   temp,temp
         movff   temp,temp
         movff   temp,temp
         movff   temp,temp
         movff   temp,temp
         endm

usec10   macro                ;10us delay
         mov     .08,cnt1
         usec                        ;one macro inside another
         decfsz  cnt1
         bra     $-16
         endm

Here's an example of what to watch for re gotos

#define  switch  portb,6   ;switch input

For not-the-18 series

sw_on    macro         ;if switch = 1, then switch is on, leave loop
         btfss   switch
         goto    $-1        ;loop back to the btfss
         endm

On the 18 series

sw_on    macro
         btfss   switch
         bra     $-2
         endm

Questions:

Archive:

Comments:


file: /Techref/microchip/mpasm.htm, 11KB, , updated: 2011/1/11 17:46, local time: 2024/10/8 17:32,
TOP NEW HELP FIND: 
44.222.134.250:LOG IN
©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!

 ©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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/microchip/mpasm.htm"> MPASM</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .