piclist 2001\01\29\123526a >
Thread: Motorola assembly instructions
www.piclist.com/techref/microchip/devices.htm?key=pic
flavicon
face BY : Alice Campbell email (remove spam text)



Here are some macros i've been using and fiddling with.  They
are not complete, and a few might not even be right, but it
would get you started:

alice

;motmacro.asm
       list    p=16c84
       radix   dec
       #include p16c84.inc
       __CONFIG _LP_OSC & _WDT_OFF &_PWRTE_ON & _CP_OFF
;----------------------------------------------------
;cpu equates (memory map)
status  equ     0x03
porta   equ     0x05
portb   equ     0x06
trisa   equ     0x85
trisb   equ     0x86
;yes i know, but i hate uppercase.
       cblock  0x10
       temp
       tempa
       wtemp
       answer
       endc
c       =       0
z               =       2
w       =     0       ;work reg
f       =     1       ;file reg
_pd     =     3
_to     =     4

;-----------------------------------------------------
       org     0x00
       nop                     ;this program is mostly used in simulator.
       goto    tryout
;------------------------------------------------------
;various macros in no particular order
;macro area
;compare literal in work
cmpl    macro   value   ;nondestructive
       movwf   wtemp
       sublw   value
       swapf   wtemp,f
       swapf   wtemp,w
       endm

;compare file in work
cmpf    macro   file
       movwf   wtemp
       movfw   file
       subwf   wtemp,w
       endm

;branch not equal
bne     MACRO fr1,fr2,address
       movf fr2,W
       subwf fr1,W
       btfss 3,2
       goto address
       ENDM

;branch if equal
beq     MACRO fr1,fr2,address
       movf fr2,W
       subwf fr1,W
       btfsc 3,2
       goto address
       ENDM

;branch if less
blo     macro   address
       btfss   status,c
       goto    address
       endm

;branch if higher
bhi     macro   address
       btfsc   status,c
       goto    address
       ENDM

;branch if plus-- test bit 7 set
bpl     macro   file,address    ;????
       movfw   file
       andlw   b'10000000'
       btfsc   status,z
       goto    address
       ENDM

;branch if minus-- test bit 7 set
bmi     macro   file,address    ;????
       movfw   file
       andlw   b'10000000'
       btfss   status,z
       goto    address
       ENDM

;branch less than or same
bls     MACRO fr1,fr2,address
       movf fr1,W
       subwf fr2,W
       btfsc 3,0
       goto address
       ENDM

bhs     MACRO fr1,fr2,address
       movf fr2,W
       subwf fr1,W
       btfsc 3,0
       goto address
       ENDM

cmp     macro   file
       movwf   wtemp
       movfw   file
       subwf   wtemp,w
       endm

txa     MACRO   address
       movfw   indf
       ENDM

ldx     MACRO   address
       movwf   fsr
       ENDM

atx     MACRO address
       movfw   indf
       ENDM

ldaf    MACRO   address
       movfw   address
       ENDM

ldal    MACRO   L
       movlw   L
       ENDM
bra     MACRO   address
       goto    address
       ENDM

rts     MACRO
       RETURN
       ENDM

sta     MACRO   address
       movwf   address
       ENDM


jsr     MACRO address
       call  address
       EMDM

jmp     MACRO address
       goto    address
       ENDM


sub   MACRO address,fr1         ;CHECK THAT FILE SUBTRACTS FROM
WORK
       movfw   fr1
       subwf address,F
       ENDM

nega    MACRO
       MOVWF   wtemp
       comf    wtemp,w
       ENDM

stx     MACRO
       movwf   fsr
       ENDM
;sta    movwf   whatever

sbc     MACRO address
       subwf   address, F
       ENDM

subw    MACRO   address
       subwf   address,f
       ENDM
;----------------------------------------------------
tryout
       movlw   .8
       movwf   tempa
       movlw   .8
       movwf   temp
       movlw   .5
       nop
       cmp     tempa
       bhi     true
;       bne temp,tempa,true
;       movwf   answer
false
stopit  goto    stopit
true
orbit   goto    orbit
;----------------------------------------
       end
;%)%)%)%)%)%)%)%)%)%)%)%)%)%)%)%)%)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


<3A753968.20928.3F7A9F@localhost> 7BIT

In reply to: <02ec01c086a3$e2fb86e0$ac1d61cb@joe>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Motorola assembly instructions

month overview.

new search...