hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
SuperHack
Goto page 1, 2, 3  Next
 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
SuperHack
Author Message
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post SuperHack Reply with quote
Just trying to understand the instructions.

The '@' instruction i have a little trouble understanding. In the following example.

Code:
@\!
 $


I'm assume that the direction and PC stored by the first '@' is "right" and (0,1).. meaning the position stored is the position after the PC has been advanced.

After the '$' returns, we end up at (0,2) however? Its as if the PC gets advanced an extra time upon returning?

Theres no more drop top of the stack instruction?? Seems kinda cumbersome to try and get something off the stack now.
Mon Dec 29, 2008 6:07 pm View user's profile Send private message
adum



Joined: 19 Apr 2007
Posts: 391

Post Re: SuperHack Reply with quote
MerickOWA wrote:
Just trying to understand the instructions.

The '@' instruction i have a little trouble understanding. In the following example.

Code:
@\!
 $


I'm assume that the direction and PC stored by the first '@' is "right" and (0,1).. meaning the position stored is the position after the PC has been advanced.

After the '$' returns, we end up at (0,2) however? Its as if the PC gets advanced an extra time upon returning?

Theres no more drop top of the stack instruction?? Seems kinda cumbersome to try and get something off the stack now.


you can use '[' to get something off the stack (because stack and memory are the same thing.)

your @ example is right. the reason you advance a step on the $ is to avoid infinite loops.
Mon Dec 29, 2008 7:03 pm View user's profile Send private message Visit poster's website
m!nus



Joined: 28 Jul 2007
Posts: 202
Location: Germany

Post Reply with quote
HackVM was fun, this isn't. Seriously, no.

edit: i take that back Smile


Last edited by m!nus on Tue Dec 30, 2008 1:12 am; edited 1 time in total
Mon Dec 29, 2008 8:43 pm View user's profile Send private message
therethinker



Joined: 28 Mar 2008
Posts: 144
Location: #hacker.org on Freenode

Post Reply with quote
I'm excited for this Razz

I already raved in the "String Reversal" Solved thread, but I'm becoming confused...

Here's how I'm interpreting it. Please correct me.

HVM had 3, 1D stacks: "the stack", memory, and the call stack (for use w/ c/$).

Now, there is a single 2D stack that is used for both "the stack" and memory.
Memory acts like a 2D stack, whereas "the stack" is only seen one dimension at a time, the 2nd dimension, the X coord., corresponds to the thread.
The call stack remains about the same.

Where is the top of "the stack" in memory? Is it at (0,0), or is it at the high end?
And what does the memory pointer do? How does [ take something off the stack?

And is there a way to drop the top value on the stack in a single instruction? I can only do it in 2...
Mon Dec 29, 2008 8:54 pm View user's profile Send private message AIM Address
lechat



Joined: 27 Feb 2008
Posts: 12

Post Reply with quote
adum,
can you please make the implementation of the SuperHack VM available? I'm not always connected to the internet...
thx Smile
Mon Dec 29, 2008 8:58 pm View user's profile Send private message
therethinker



Joined: 28 Mar 2008
Posts: 144
Location: #hacker.org on Freenode

Post Reply with quote
Download http://hacker.org/sh/index.html to your hard drive, and then you can open it up with a web browser and it will still work.
Mon Dec 29, 2008 9:16 pm View user's profile Send private message AIM Address
adum



Joined: 19 Apr 2007
Posts: 391

Post Reply with quote
therethinker -- you're pretty much on target.

yeah, a drop takes two instructions, but it's more flexible this way.

instead of trying to explain everything here, it's probably easiest just to read the javascript source for the VM. it will explain better than i can. i know it's a bit confusing -- it still confuses me =)
Mon Dec 29, 2008 11:13 pm View user's profile Send private message Visit poster's website
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Reply with quote
I see, user input is separate from memory where as in HVM user input was always in the first X locations of memory.
Tue Dec 30, 2008 2:23 am View user's profile Send private message
snibril



Joined: 26 Oct 2008
Posts: 31

Post Reply with quote
Two things: with the g/w instruktions, you can modify your program at runtime?
Second, thee is no "drop" instruktion like "d" in HVM?
Tue Dec 30, 2008 5:30 am View user's profile Send private message
adum



Joined: 19 Apr 2007
Posts: 391

Post Reply with quote
you can use '[' to drop.

yes, you can modify code at runtime.
Tue Dec 30, 2008 5:53 am View user's profile Send private message Visit poster's website
m!nus



Joined: 28 Jul 2007
Posts: 202
Location: Germany

Post Reply with quote
how about changing & so that it doesnt throw an exception when 32 threads are reached.
if it just would continue (advance current thread 1 step and jsut create no new one) this would be a nice way to create lots of worker threads Smile
Tue Dec 30, 2008 2:28 pm View user's profile Send private message
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Reply with quote
I think theres a bug in how threads/memory pointers work.

In both examples
UserInput:
Code:
97,98


Code:
Code:
&},P!


Javascript implementation prints 'ab'
Php implementation prints 'bb'???

Theoretically, if I understand how this works. I created a new thread who then immedately shifts its memory/stack pointer down (giving it its own stack).

The 2 threads run the same code in parallel then which is effectively ",,PP" which should print 'ab'.
However it appears as tho the '}' instruction is affect thread 0 & 1??

That's my best guess anyway.


Last edited by MerickOWA on Tue Dec 30, 2008 8:10 pm; edited 1 time in total
Tue Dec 30, 2008 8:06 pm View user's profile Send private message
therethinker



Joined: 28 Mar 2008
Posts: 144
Location: #hacker.org on Freenode

Post Reply with quote
I think it makes sense... possibly the javascript version has thread 2 run before thread 1, whereas PHP does it the other way around?
Tue Dec 30, 2008 8:10 pm View user's profile Send private message AIM Address
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Reply with quote
If it simply executed the threads in a different order, then it should print 'ba' not 'bb'.

My guess is that the '}' instruction affects both threads, or possibly thread 0 is executing this instruction too?

If the code is
Code:
& ,P!


Then both implementations give 'bb'. The two threads are overwriting each other's stack in memory, so thread 1's read of userinput overwrites thread '0' result. Since poping off the stack just adjusts the memory pointer they both pop off the same/only value.
Tue Dec 30, 2008 8:14 pm View user's profile Send private message
adum



Joined: 19 Apr 2007
Posts: 391

Post Reply with quote
sorry, there was a bug in the PHP. should be fixed now. thanks!
Tue Dec 30, 2008 8:29 pm View user's profile Send private message Visit poster's website
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.