Shop OBEX P1 Docs P2 Docs Learn Events
mov truncation problem using sx/b asm function — Parallax Forums

mov truncation problem using sx/b asm function

BC BakerBC Baker Posts: 1
edited 2009-07-19 00:19 in General Discussion
I am using the sx28 to generate a pulsetrain. I need it to run faster than 500 Hz, so I created my own delay routine using assembly and the asm command in the sxb compiler. My problem is that the assembly mov command truncates my word size variable to a byte. I can have two word sized variables and have the source be larger than 256, but then when I check the value of the destination it is 256. I get no errors or anything. I have to force a literal mov, with the source greater than 256 to get a truncation warning.

This is perplexing to me, because from what I remember and have read, the assembly mov command should have no problems handling a word size variable. I am wanting to generate a variable frequency pulsetrain and having a word size variable would be of great benefit. I was wondering if there is a patch or some fix to this problem. Like I said, I would like to fix this problem, but I can work with the bytes if necessary.

Thank.
BC Baker

Comments

  • pjvpjv Posts: 1,903
    edited 2009-07-18 02:58
    Hello Baker;

    In assembly you will have to work with two separate bytes. You must be remebering incorrectly; there is no concept of a WORD with the MOV instructions. Everything works through the W register, and that is 8 bits.

    Cheers,

    Peter (pjv)
  • natpienatpie Posts: 35
    edited 2009-07-18 22:54
    You may have been thinking of IREAD.·· At allows you to read all 12bits in a memory addres, but this only loads the value into the M and W registers.
  • JonnyMacJonnyMac Posts: 9,298
    edited 2009-07-19 00:19
    @BC: It would be easier to assist if we could see your code.
Sign In or Register to comment.