PDA

View Full Version : [resolved][puzzle] upside-down

kuroneko
10-28-2011, 02:25 PM
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):

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?

Phil Pilgrim (PhiPi)
10-28-2011, 05:08 PM
This seems to work:

DAT

xor jmpinstr,xorinstr
xor xorinstr,jmpinstr
xor jmpinstr,xorinstr

jmpinstr jmp #\$

:)

-Phil

Phil Pilgrim (PhiPi)
10-28-2011, 07:46 PM
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

MagIO2
10-28-2011, 07:57 PM
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)
10-28-2011, 08:58 PM
Ah, good point. This would be better, even though I'm sure it violates the spirit of the puzzle:

DAT

xor xorinstr,jmpinstr
xor jmpinstr,xorinstr
xor xorinstr,jmpinstr

jmpinstr jmp #\$

-Phil

kuroneko
10-29-2011, 12:31 AM
Nice try Phil! Reminds me a bit of Andy's method (TM). As for vscl, yes, no code at that doomed location. Isn't that annoying? :)

Phil Pilgrim (PhiPi)
10-29-2011, 07:41 AM
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

kuroneko
10-29-2011, 09:23 AM
... 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.

kuroneko
10-29-2011, 11:43 AM
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)
10-29-2011, 03:16 PM
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 Schwabe
10-31-2011, 04:21 AM
Would this be cheating? :-)

mov \$, \$+2
jmp #\$-1

kuroneko
10-31-2011, 04:37 AM
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).

kuroneko
11-01-2011, 02:50 AM
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)
11-01-2011, 03:42 AM
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

StefanL38
11-01-2011, 06:00 AM
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

kuroneko
11-01-2011, 06:32 AM
keep the questions puzzles
Is your brain still SPIN'ing? :)

StefanL38
11-01-2011, 08:04 AM
keep the questions puzzles

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

After debugging

keep the puzzles coming :smile:

kuroneko
11-01-2011, 08:10 AM
keep the puzzles coming
See if you can handle Escape, it's still open.