Solved

using macros in pic microcontrollers

Posted on 2006-07-13
2
310 Views
Last Modified: 2010-05-18
Hi,
I am new to coding in assembly language for pics.

I have the following code below. What appears to be happening is the memory address of Count and Count2 are xor'ed together rather than what is contained in those variables. If I pass two literals values and change the macro use literals instead the desired result is achieved of determining if the two variables are equal in value.
As it stands it just just determines if the location of the variables is at the same memory address, which is not desired....

Thank you in advance for any help.
John

Main  routine
        movlw            0x05
        movfw            Count
        movlw            0x05
        movfw            Count2

        bcf            PORTA,3
        EqualF      Count,Count2
        btfsc            Flag,E      ;      
        bsf            PORTA,3
        goto            Stop

Stop
        goto            Stop
            

Macro which in included from another file

EqualF            macro      par1, par2
                  bcf            Flag,E
                  movf      par1,w
                  xorwf      par2,w
                  btfsc      STATUS,Z      
                     bsf            Flag,E            
                  endm
0
Comment
Question by:jdav3579
2 Comments
 
LVL 3

Accepted Solution

by:
PeterdLo earned 500 total points
ID: 17116230
Hi jdav3579,

By reviewing your posted code, I think your problem is NOT macro related. In your main routine, you used "movfw Count" that resulted as follows.

the value of Count will be copied into W register. (I don't think that is what you want).

Therefore, you should use "movwf Count" to reverse the copy. In other words, you want Count to have a value of 5.

Peter
0
 

Author Comment

by:jdav3579
ID: 17116995
Thanks very much for your help. John
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Swapping a Int64 var (using ASM) 19 1,098
Show semaphore name in Pascal 12 634
FIR_filter 2 220
Debugging multi threaded application 25 612
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now