please dont rip this site

Microchip MPASM

Macros for useing Motorola ASM code in MPASM (!)

Alice Cambell says:

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


file: /Techref/microchip/mpasmmotmac.htm, 4KB, , updated: 2001/12/14 17:35, local time: 2024/11/5 17:58,
TOP NEW HELP FIND: 
3.129.195.45: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://linistepper.com/techref/microchip/mpasmmotmac.htm"> Macros for useing Motorola ASM code in 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?