hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Hacker Virtual Machine IDE
Goto page 1, 2  Next
 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
Hacker Virtual Machine IDE
Author Message
Col. Dump



Joined: 31 Oct 2008
Posts: 8

Post Hacker Virtual Machine IDE Reply with quote
Hi all,

I wrote a prototypical IDE for the hacker virtual machine. It's a small java application available at http://sites.google.com/site/hvmide/.

Happy hacking,
Col. Dump
Thu Nov 20, 2008 2:06 am View user's profile Send private message
Allosentient



Joined: 10 Apr 2008
Posts: 273

Post Reply with quote
Very nice of you to post this, thank you. I was just going to post JUST NOW that I am working on one not a full IDE, but a command line assembler. I dont know if this will ruin the challenges for everyone else though since the purpose of these is to be a challenge

Sample program:

start:
50>0; Initialize counter = 5 [a]
next:
6 [a, 6]
+; [a += 6]
0<; [a, counter]
1-; [a, --counter]
0^0>; [a, counter] (counter stored in mem)
jz end;
call next;
end:
!
Thu Nov 20, 2008 2:09 am View user's profile Send private message
adum



Joined: 19 Apr 2007
Posts: 391

Post Reply with quote
we actually have a policy of not allowing sharing of HVM assemblers. the IDE is just about the max we allow. it's so people get the joy of developing their own techniques =)
Thu Nov 20, 2008 2:17 am View user's profile Send private message Visit poster's website
Allosentient



Joined: 10 Apr 2008
Posts: 273

Post Reply with quote
I dont have any assemblers to share (only going to give a hint as to what a program should look like!), but that IDE he posted actually has a pretty nice debugger in it, so I dont know if that is allowed
Thu Nov 20, 2008 2:17 am View user's profile Send private message
Allosentient



Joined: 10 Apr 2008
Posts: 273

Post Reply with quote
I have been using this, it got rid of my headaches.

Now I do have one question, the IDE throws an error if you try to read memory that isn't assigned, but I don't believe this is really illegal, as all memory has 0 by default. Is there a way to turn that off?

Few more things:
'do nothing' doesn't count toward program length

Able to put values into negative memory locations

would be nice to have a "run to X program cycles"

Great program!!
Sat Nov 22, 2008 5:25 am View user's profile Send private message
Col. Dump



Joined: 31 Oct 2008
Posts: 8

Post Reply with quote
I'm happy to hear that my tool is actually of use for you. Smile

You are right with respect to the machine behaviour: both negative memory addresses as well as memory initialization should work as you described. I will fix that briefly...

[Edit] I have to correct myself - write access to negative memory addresses results in an error of the reference implementation, too:

@0 1 [1]
@1 0 [1, 0]
@2 1 [1, 0, 1]
@3 - [1, -1]
@4 > !ERROR: exception while executing I=> PC=4 STACK_SIZE=1
memory write access violation @-1
Sat Nov 22, 2008 2:03 pm View user's profile Send private message
Col. Dump



Joined: 31 Oct 2008
Posts: 8

Post new version 0.9.2 Reply with quote
You can find a new release at the old location, which now
- has a new run command "run to cycle X"
- returns 0 for read operations on uninitialized memory instead of throwing an exception
- doesn't ignore whitespace outside of comments anymore, i.e. both spaces and newlines count to program length now
- initializes new VMs with the standard reference memory size (16384)
- has several GUI bugs fixed (confirm dialog now only pops up if really necessary, F8 doesn't jump to split pane any more, ...)

How would you implement access to negative memory addresses? Python-like, starting from the end of the memory? Or simply have one half of the memory in negative address space?
Sat Nov 22, 2008 3:00 pm View user's profile Send private message
Allosentient



Joined: 10 Apr 2008
Posts: 273

Post Reply with quote
Thanks for the update! I am not sure what you mean by your question, since negative memory addresses aren't supposed to work in HVM at all, but if I were to do it anyway, I would have half the memory in negative address space. It is hard to use HVM memory as storage when the challenge says that the first X number of memory spots is filled.

I stayed up nearly all night trying to finish King Mouse, but I am having a hard time. This is harder to me than the really small hello world problem.
Sat Nov 22, 2008 4:06 pm View user's profile Send private message
m!nus



Joined: 28 Jul 2007
Posts: 202
Location: Germany

Post Reply with quote
wow, this is really nice, the GUI makes it even better than mine (commandline and simple web interface)
http://minus.denn1s.cn/hacker.org/hvm.html that's what it looks like (goto parsing not yet really implemented)
line breaks are ignored, spaces aren't, comments work with ; at line ends, memory supports strings
~620 lines of code, ~15KB of PHP; not much yet.

as I can see from this VM a GUI really really helpful (especially the step-in/over) so i might also create one using PHP-Gtk2


btw, something seems to be wrong about your IDE Col. Dump: 005c!1^... -- program terminated by command "!" at instruction 4 which is obviously wrong since i call to position 5 before
EDIT: some very strange behavior: now: 005c!1^1^82**+0^ at the last ^ it says end of program reached at instruction 15. i am confused. really.
Sun Nov 23, 2008 3:21 pm View user's profile Send private message
Allosentient



Joined: 10 Apr 2008
Posts: 273

Post Reply with quote
The 005c!1^ code works correctly for me, maybe you have a leading space?
Sun Nov 23, 2008 6:55 pm View user's profile Send private message
Mütze



Joined: 26 Oct 2008
Posts: 23

Post Reply with quote
I found out, that the hackvm.py script outputs -1 when executing "01-2/p".
Your ide outputs 0.


Last edited by Mütze on Mon Nov 24, 2008 9:43 am; edited 1 time in total
Sun Nov 23, 2008 10:01 pm View user's profile Send private message
Col. Dump



Joined: 31 Oct 2008
Posts: 8

Post Reply with quote
Thank you for the tip! Looks like the result of -1/2 depends on how the languages treat rounding in integer division.

Python: result is the next smaller integer, positive and negative
>>> -1/2
-1

Java: result is the next smaller absolute integer with the corresponding sign
System.out.println(-1/2);
0

I changed the code so that the IDE behaves exactly like the reference implementation (i.e. "push((int)Math.floor((double)s1/s0));").

You can download the fixed version at the usual URL.

BTW: line breaks are now also ignored, spaces not.

EDIT: 005c!1^1^82**+0^ works in my 0.9.3 as expected, i.e. termination at 16...
Mon Nov 24, 2008 1:39 am View user's profile Send private message
Mütze



Joined: 26 Oct 2008
Posts: 23

Post Reply with quote
Thank you! That was fast.
Mon Nov 24, 2008 9:45 am View user's profile Send private message
sigi



Joined: 26 Oct 2008
Posts: 37

Post Reply with quote
Whoa, that IDE looks like some serious amount of work already. You've even picked nice icons. Are you sharing the source code for it? We might want to plug in our own assemblers into the IDE.
Mon Nov 24, 2008 10:29 pm View user's profile Send private message
Col. Dump



Joined: 31 Oct 2008
Posts: 8

Post Reply with quote
If I find the time, I will make a code fork and clean it up so it can be released.
Thu Nov 27, 2008 3:44 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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.