Shop OBEX P1 Docs P2 Docs Learn Events
Paradox — Parallax Forums

Paradox

Armored CarsArmored Cars Posts: 172
edited 2005-11-12 19:47 in General Discussion
What I am trying to do is copy a single bit into a variable through IND.· I have run into a brick wall and am hoping I'm wrong about something here.

Here FSR is changed when temp is accessed, changing FSR to temp before currentX can be written to.

mov·fsr,currentX
mov·w,temp
and·w,#%00000001
snz
setb·· IND.0
sz
clrb·· IND.0

Try to change FSR after accesing temp changes w.

mov·w,temp
mov fsr,currentX
and·w,#%00000001
snz
setb·· IND.0
sz
clrb·· IND.0

Try to change FSR after w is accessed messes up the zero flag.

mov·w,temp
and·w,#%00000001
mov fsr,currentX
snz
setb·· IND.0
sz
clrb·· IND.0

So far as I can tell there is no way this code will work.· I'm hoping some of my logic here is flawed or otherwise it will be back to the drawing board for me.
·

Comments

  • BeanBean Posts: 8,129
    edited 2005-11-09 14:34
    I would use the carry flag,

    movb c,temp.0
    mov fsr,currentX
    movb IND.0,c

    Also you don't have the whole program, but make sure you don't need "mov fsr,#currentX".

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    Those that would give up freedom for security will have neither.
    ·
  • Armored CarsArmored Cars Posts: 172
    edited 2005-11-09 15:03
    Carry flag works. The only problem is now, looking at it that code, I realize I am in way over my head and right now I really don't know how to use it anyway.

    I attatched a picture of the problem. I have two sets of registers and need to "translate" the contents of one set into another set. Hopefully you can get this from the pricture.

    Post Edited By Moderator (Ryan Clarke (Parallax)) : 11/11/2005 7:14:18 PM GMT
    100 x 75 - 2K
  • PJMontyPJMonty Posts: 983
    edited 2005-11-09 20:21
    Armored Cars,

    How accurate is your picture? Is it just a hypothetical example or is it the actual swap you need to do? If I am reading your picture correctly, you have four 8 bit registers, and you basically need to move groups of 4 bits (a nibble) from one register location to another, and sometimes you have to swap the high/low positions of the nibbles. Is this correct or am I reading too much into the picture??
      Thanks, PeterM

    PS - Next time you post a picture, make it a JPG so it's tinier. I have attached your image as a JPG to show you that it still looks fine. I did nothing more complicated than load you image in MsPaint (in Win2K) and then save it as a JPG. You'll notice that your 675 kb file became a 38 kb file.

    Post Edited By Moderator (Ryan Clarke (Parallax)) : 11/11/2005 7:13:30 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-11-09 20:45
    As an aside, let's not use profanity when naming attachments, other words can be used to convey the same meaning. There are quite a few minors on the forums, though most of them don't participate in this forum that often.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Lord SteveLord Steve Posts: 206
    edited 2005-11-09 21:25
      mov w, #4
      mov loopCount, w
     
      mov w, #0x11
      mov mask, w
     
    :loop
      clr indf
      clrb carry
      
      mov w, r0
      and w, mask
      or indf, w
      rl indf
      mov w, r1
      and w, mask
      or indf, w
      rl indf
      mov w, r2
      and w, mask
      or indf, w
      rl indf
      mov w, r3
      and w, mask
      or indf, w
      rl indf
      
      inc fsr
      rl mask
      
      decsz loopCount
      jmp :loop
    


    I'm sure someone will correct me if that code is wrong.
  • Armored CarsArmored Cars Posts: 172
    edited 2005-11-10 14:12
    Sombody will have to explain the #0x11 to me later... I tested it in the debugger and found it for now. And... I think you got it. I never saw that pattern. Thanks man, that is going to help me alot. Even if the code has errors, I know the pattern and what to do now.

    Oh yeah, the file name was my initial reaction when I realized how horribly I messed up the display. I just didn't think to change it when I posted it. As far as minors in this forum, I'd like to meet them. I'm in highschool and this just absolutely sucks (as far as difficulty.)· Nobody here has the slightest idea what I'm doing so I think it'd be cool to meet someone my age who is·knows this also.

    Post Edited (Armored Cars) : 11/10/2005 2:15:42 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-11-10 19:04
    There are a few around, though most don't go around announcing thier age.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • PJMontyPJMonty Posts: 983
    edited 2005-11-11 18:43
    Steve,

    Very cool of you to take the time to write the code sample. One suggestion for next time is to comment it to death. You should always assume that if someone has a code problem they can't solve on their own, then reading un-commented code makes it harder for them to fully comprehend the solution. Since the goal is always to help people learn and move on to the next level, clear and abundant comments really help.
      Thanks, PeterM
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-11 19:15
    Just changed the graphic name.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-11-11 19:55
    Hmm, whatever you did Ryan, made the pix no longer availible, perhaps the link to the pic was changed, but not the name of the file itself? Don't know dotBB well enough to know the specific cause.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • PJMontyPJMonty Posts: 983
    edited 2005-11-11 20:55
    Ryan,

    Good idea, but slightly flawed execution.

    1 - The picture is now completely gone and the renamed link is not even a link but just some text.

    2 - It's spelled "defecation", so the correct new name is "ohdefecation.jpg". You could also use the simpler "poop" which creates the (I think) easier to read "ohpoop.jpg."
      Thanks, PeterM
  • Lord SteveLord Steve Posts: 206
    edited 2005-11-11 22:47
    PJMonty,

    Comments are great.· However, I thought it·would·be more beneficial to Mr. Cars·if he·had to figure out for himself what·the code·did.· (I believe he did this by running it through the debugger.)· That was just my take on it.· Que sera'.

    Armored Cars,· what do you think?· Was it more betterer to NOT have the comments?
    ·
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-12 03:39
    The spelling was intentional [noparse];)[/noparse] The linking problem was not intentional...still trying to figure out why the link broke....

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • PJMontyPJMonty Posts: 983
    edited 2005-11-12 19:47
    Steve,

    Again, it was awfully nice of you to take the time to write that code sample. However, did you actually write the code sample and conciously choose to have no comments in it? Were you thinking as you wrote it, "I'll intentionally leave off comments because this will force him to try and figure out how this code works," or did you just write it without comments because it was quicker and easier?

    I think you might be a coder who believes that comments are for wimps, sissys, etc, and that you simply always write code with little to no comments. A friend of mine always refers to un-commented assembly as "Write Only Code." Perhaps you disagree with him. Que Sera'.
      Thanks, PeterM
Sign In or Register to comment.