• AVR Freaks

Hot!pic-as 2.20 - error in defining and using bits explanation.

Page: 12 > Showing page 1 of 2
Author
atferrari
Super Member
  • Total Posts : 1448
  • Reward points : 0
  • Joined: 2004/07/08 13:09:24
  • Location: Buenos Aires - Argentina
  • Status: online
2020/07/15 14:35:26 (permalink)
5 (1)

pic-as 2.20 - error in defining and using bits explanation.

pic-as 2.20
 
In the recent XC8 PIC Assembler User's Guide for Embedded Engineers, the paragraph 7.2 Defining And Using Bits,
explains how to define a bit object inside a specific Psect, fitted with the "bit" flag which means "this Psect holds bit objects". Those objects are just 1 bit wide.
 
The guide shows these two examples for defining the flag needcopy
 
BANKSEL (needCopy/8)
bsf BANKMASK(needCopy/8),needCopy&7
 
or
 
#define NEEDCOPY BANKMASK(needCopy/8),needCopy%7
 
It is worth to note that mod 7 IS WRONG. The right divisor for it is 8, thus, the proper calculation must be:
 
BANKSEL (needCopy/8)
bsf BANKMASK(needCopy/8),needCopy mod 8
 
or
 
#define NEEDCOPY BANKMASK(needCopy/8),needCopy mod 8
 
A ticket raised in due time, MCHP took note to correct this.
 
Enjoy your journey to Mars.

Agustín Tomás

In theory, there is no difference between theory and practice. In practice, however, there is.

http://cablemodem.fibertel.com.ar/atferrari/
#1

24 Replies Related Threads

    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 15:11:59 (permalink)
    -1 (1)
    That %7 looks like a typo and meant to be &7.
     
    #2
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 15:12:22 (permalink)
    0 (2)
    needCopy&7
    and
    needCopy mod 8
    are equivalent, so long as "&" is supported as meaning "bitwise and"
    "%7" is plainly wrong if "%" means "mod".
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 15:15:52 (permalink)
    0 (2)
    ric
    "%7" is plainly wrong if "%" means "mod".

    According to Table 3-2 in the MPASM to PIC Assembler Migration Guide, % is the modulus operator. ;)
     
    #4
    atferrari
    Super Member
    • Total Posts : 1448
    • Reward points : 0
    • Joined: 2004/07/08 13:09:24
    • Location: Buenos Aires - Argentina
    • Status: online
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 16:17:09 (permalink)
    0 (2)
    The relevant point of my post is that the divisor must be 8.
    post edited by atferrari - 2020/07/16 05:32:59

    Agustín Tomás

    In theory, there is no difference between theory and practice. In practice, however, there is.

    http://cablemodem.fibertel.com.ar/atferrari/
    #5
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 16:32:23 (permalink)
    +1 (3)
    Our point is that % is a typo, and should be &

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    dan1138
    Super Member
    • Total Posts : 3731
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 16:38:25 (permalink)
    +1 (3)
    The pic-as(v2.20) assembler has a specific usage for the % operator within a MACRO/ENDM context that is very different than the C language preprocessor usage.
     
    You will be well off if you can avoid using the C language mod (%) operator for any reason in an assembly language source code file.
    #7
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 16:45:57 (permalink)
    0 (2)
    dan1138
    The pic-as(v2.20) assembler has a specific usage for the % operator within a MACRO/ENDM context that is very different than the C language preprocessor usage.

    Good point!
    That makes it even more certain that this is a typo.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/15 17:24:25 (permalink)
    +2 (4)
    dan1138
    The pic-as(v2.20) assembler has a specific usage for the % operator within a MACRO/ENDM context that is very different than the C language preprocessor usage.

    I was surprised to find the % operator for modulus in the migration document. The only assembly operator for modulus is mod in the XC8 C Compiler User's Guide.
     
    IMO, PIC Assembler's usage of BANKMASK() and this way of representing a bit is ... sad!!!  It makes the code more difficult to read and write.
     
    dan1138
    You will be well off if you can avoid using the C language mod (%) operator for any reason in an assembly language source code file.

    The migration document does not list the mod operator as the modulus operator. ;)
    post edited by 1and0 - 2020/07/15 17:25:57
    #9
    mad_c
    Super Member
    • Total Posts : 1249
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/16 16:08:11 (permalink)
    0 (2)
    atferrari
    pic-as 2.20
     
    In the recent XC8 PIC Assembler User's Guide for Embedded Engineers, the paragraph 7.2 Defining And Using Bits,
    explains how to define a bit object inside a specific Psect, fitted with the "bit" flag which means "this Psect holds bit objects". Those objects are just 1 bit wide.
     
    The guide shows these two examples for defining the flag needcopy

    Thanks for pointing this out. It had already been picked up and will be corrected in the next revision.
     
    Jeff.
    #10
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 03:41:19 (permalink)
    -2 (2)
    @mad_c
    Are you a Microchip employee?

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #11
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 03:52:36 (permalink)
    +1 (3)
    Marty, you hang around in the 8 bit forums enough that you should have noticed he's one of the XC8 authors who came from HiTech C

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 04:19:55 (permalink)
    -3 (5)
    Pickled ric.
    I don't have any interest in 8bit, used to Years ago.
     
    I might read some 8bit threads now and again but I am not on the forum all Day
    and Night to notice who People are.
     
     
    I suppose it will be the usual downvote for expressing my opinion won't it ric ?
     
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #13
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 04:43:19 (permalink)
    +2 (4)
    Gort2015
    Pickled ric.
    I don't have any interest in 8bit, used to Years ago.

    Yet you often post in the 8 bit forums...
     

     I suppose it will be the usual downvote for expressing my opinion won't it ric ?

    I stated just yesterday, I NEVER downvote. If I disagree with someone, I tell them why.
    Can't you stop being paranoid for just a moment?

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 04:57:09 (permalink)
    -3 (5)
    Paranoid, of course I am constantly looking behind me
    and the Virus might get me.
     
    You did state it Yesterday and you have stated it before.
     
    I don't know mad_c, in fact all you had to say was that mad_c
    did not work for Microchip instead of one of your little pops at me.
     
    Cheer up ric, you don't sound happy at all.
    Do you drink?
     
     
     
    post edited by Gort2015 - 2020/07/17 05:04:36

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #15
    mlp
    boots too small
    • Total Posts : 946
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 07:09:31 (permalink)
    +2 (6)
    Gort2015
    all you had to say was that mad_c did not work for Microchip

    Ric would not say such a thing because it would be incorrect.
     
    Dr Jeff a.k.a. mad_c (Microchip Australia Design Centre, I believe is what the userid originally stood for) was at HI-TECH long before I started there and was still there at the Microchip acquisition; whereupon he became and is still a Microchip employee to this day, unlike myself. He's now primarily responsible for the manuals (thus his authoritative statements about updates to the documentation) and was the original author of some of the gnarly parts of the compiler itself.
     
    Unlike Ric, I will and do downvote posts that detract from the discussion. I usually don't touch yours, though, because I have you blocked and don't see them. When others comment on your comments I am sometimes sufficiently intrigued to look more closely. So far my decision to block in general remains sound.
     
    I try to correct misinformation when I see it presented.


    Mark (this opinion available for hire)
    #16
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 14:54:09 (permalink)
    -2 (4)
    I asked a simple question but you had to make a song and dance about it.
     
    I responded in kind to how ric spoke to me.
     
    Sticking together and down voting me is juvenile.
     
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #17
    dan1138
    Super Member
    • Total Posts : 3731
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 15:57:47 (permalink)
    -1 (1)
    Gort2015
    I asked a simple question but you had to make a song and dance about it.
     
    I responded in kind to how ric spoke to me.
     
    Sticking together and down voting me is juvenile.



    First, consider that in eye for an eye contests everyone goes blind after two rounds.
     
    Second, Olin Lathrop was by far and away the biggest ego (i.e. dick) around here that never got banned and he got down voted way more than you. He left for Stack Overflow and has not been back. Seems like a win-win.
     
    Thirdly, there's no need to be paranoid because almost everyone seems out to get you.
     
    <EDIT>
     
    I have been admonished and corrected. Olin Lathrop was banned. It would seem that he took excessive and vociferous exception to the impotence of his position within this community to lash out in ways that were unacceptable to the moderators.
     
    It's been my experience that vulgarity is the refuge of the weak minded.
    post edited by dan1138 - 2020/07/18 00:26:25
    #18
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 16:22:51 (permalink)
    -1 (3)
    Since when did this become a private enclosed members club?
     
    You are right Dan, maybe MC should get involved, see all the
    crap going on.  Check the forum stats.
     
    Find who the Trolls are.
     
    All I've ever done is post useful stuff like I2C scanners.

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #19
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: pic-as 2.20 - error in defining and using bits explanation. 2020/07/17 19:09:25 (permalink)
    -2 (4)
    So whenever I post I get auto downvoted.
     
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5