Shop OBEX P1 Docs P2 Docs Learn Events
[resolved][puzzle] upside-down — Parallax Forums

[resolved][puzzle] upside-down

kuronekokuroneko Posts: 3,623
edited 2011-11-01 01:10 in Propeller 1
Admittedly it's an old idea but it came alive again only recently (didn't work out though). Let's generate a square wave at clkfreq/16 (setup omitted):
xor     outa, mask
jmp     #$-1
So far so good. Now lets swap both instructions (xor comes last). You may have to adjust the jump but how can you keep this 2-insn-loop (jmp & xor) running and the square wave alive at that frequency?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-28 10:08
    This seems to work:
    DAT
    
    clock         mov       dira,mask
                  xor       jmpinstr,xorinstr
                  xor       xorinstr,jmpinstr
                  xor       jmpinstr,xorinstr
    
    jmpinstr      jmp       #$
    xorinstr      xor       outa,mask
    
    mask          long      1
    

    :)

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-28 12:46
    BTW, putting the XOR in VCFG and a JMP to VCFG at location zero works, but the period is 24 clocks, not 16. Doing the same with VSCL doesn't produce any output (for reasons that, IIRC, have been covered here somewhere).

    -Phil
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-10-28 12:57
    I think the first loop will do something different, as you changed the next instruction. 1 NOP is needed before jmpinstr. But is this the intended solution? ;o)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-28 13:58
    Ah, good point. This would be better, even though I'm sure it violates the spirit of the puzzle:
    DAT
    
    clock         mov       dira,mask
                  xor       xorinstr,jmpinstr
                  xor       jmpinstr,xorinstr
                  xor       xorinstr,jmpinstr
    
    jmpinstr      jmp       #$
    xorinstr      xor       outa,mask
    
    mask          long      1
    

    -Phil
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-28 17:31
    Nice try Phil! Reminds me a bit of [post=963715]Andy's method (TM)[/post]. As for vscl, yes, no code at that doomed location. Isn't that annoying? :)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-29 00:41
    In the quest to come up with a clever solution, I ended up creating a simple software loop that oscillates an output pin at clkfreq / 8 instead of clkfreq / 16.

    -Phil
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-29 02:23
    ... I ended up creating a simple software loop that oscillates an output pin at clkfreq / 8 instead of clkfreq / 16.
    Welcome to the club :) I assume something along the lines of neg/djnz or add/djnz.
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-29 04:43
    Hint: The important criteria here are xor comes last (i.e. at a higher address) and 2-insn-loop. Phil already considered moving both insns apart from each other - without me complaining - and placing them at opposite ends of the memory so that an address wrap closes the loop again. This would've been a valid solution except for the fact that code at $1FF doesn't usually work.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-29 08:16
    kuroneko wrote:
    I assume something along the lines of neg/djnz or add/djnz.
    I used a pair of jmprets. It works only for lower-order bits of outa and, depending upon which bit, has a limited number of cog addresses where it can be placed.

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-10-30 21:21
    Would this be cheating? :-)
            mov             dira,   mask
            mov             $,      $+2
            jmp             #$-1
            xor             outa,   mask
    
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-30 21:37
    Would this be cheating?
    Definitely :) The (active) xor doesn't sit on the higher address.

    Todays hint: The number 512/8 = 64 plays an important role (in one of my solutions).
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-31 19:50
    With one exception all these puzzles had a solution before having been posted. Same here, but I wasn't very happy with it. So I came up with another one which should at least silence some potential complaints which I expect re: the initial solution (*stretched*). I post both of them as an attachment which makes it your choice whether you look at it now, later or never.

    At least Phil got something out of it (even if unrelated).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-31 20:42
    Once again, phsx abuse at its finest!

    The Propeller counters are a powerful drug, kuroneko, and we, your fellow forumistas, are becoming concerned as you get pulled ever more deeply to their dark side. We care enough for your well-being that some sort of intervention may be called for. :)

    -Phil
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-10-31 23:00
    Once again, phsx abuse at its finest!
    second what PhiPi said.

    I could follow the concept - more or less. Wow that's what I call
    tweaking-freakin-freaks doing things that make the brains of other assembler-tweaking-freaks SPIN in twisted-circles

    keep the questions puzzles
    best regards
    Stefan
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-31 23:32
    StefanL38 wrote: »
    keep the questions puzzles
    Is your brain still SPIN'ing? :)
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-11-01 01:04
    keep the questions puzzles

    self modified code oh no wait ! self modified text. Not debugged ;-)

    After debugging

    keep the puzzles coming :smile:
  • kuronekokuroneko Posts: 3,623
    edited 2011-11-01 01:10
    StefanL38 wrote: »
    keep the puzzles coming
    See if you can handle [thread=125650]Escape[/thread], it's still open.
Sign In or Register to comment.