Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

using macros in pic microcontrollers

Posted on 2006-07-13
2
Medium Priority
?
323 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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