Solved

using macros in pic microcontrollers

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
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.

688 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