?
Solved

using macros in pic microcontrollers

Posted on 2006-07-13
2
Medium Priority
?
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
PeterdLo earned 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 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