Hacker Virtual Machine IDE
Hacker Virtual Machine IDE
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
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
-
- Posts: 273
- Joined: Thu Apr 10, 2008 9:47 pm
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:
!
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:
!
-
- Posts: 273
- Joined: Thu Apr 10, 2008 9:47 pm
-
- Posts: 273
- Joined: Thu Apr 10, 2008 9:47 pm
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!!
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!!
I'm happy to hear that my tool is actually of use for you.
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
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
new version 0.9.2
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?
- 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?
-
- Posts: 273
- Joined: Thu Apr 10, 2008 9:47 pm
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.
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.
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.
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.
-
- Posts: 273
- Joined: Thu Apr 10, 2008 9:47 pm
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...
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...