Solved

using macros in pic microcontrollers

Posted on 2006-07-13
2
316 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IRQL_NOT_LESS_OR_EQUAL for Kernel Timer Thread 7 585
Intel DX58SO board 7 885
How to do these things in assembly !? 1 447
abcpdf error 3 837
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

680 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