View Single Post
Old 31st August 2008, 15:04   #24  |  Link
Oopho2ei
Guest
 
Posts: n/a
Quote:
Originally Posted by bmnot View Post
Regarding the functionality of commands 36-3A, there are still operations missing to store values in memory, to perform systems calls and to execute native code.
I have updated commands 0x31-0x35 (improved syntax) and added the remaining commands 0x36-0x3A.

Quote:
Originally Posted by bmnot View Post
It would be interesting to know how the VM deals with arithmetic overflows (ADD, MUL)... or if they are simply not allowed in BD+.
Exceptions are handled by the interpreter but i haven't documented them yet.

Quote:
Originally Posted by bmnot View Post
Is the PC counted in bytes or words? In the below implementation it's bytes (as in your tutorial). However, this would unnecessarily restrict the range of jump commands.
Actually the PC is double word (32 bit) aligned. Every instruction is 32 bit long anyway. In my notes the PC is 4 bytes but the lower and higher bits are masked (PC & 0x3FFFFC). Have a look at what the dispatcher does:
Code:
previous instruction handler returns (has maybe changed PC)
...
command dispatcher is called: 
...
PC = PC AND 0x3FFFFC; // make it dword aligned
I = mem[PC] ^ instruction_filter_value;
PC = PC + 4;
...
command_handler(I >> 0x1A);
....
command handler returns and dispatcher is called again. and so on...
Ignore the "instruction_filter_value". It's set by command ??? and is zero in my case.

Quote:
Originally Posted by bmnot View Post
Below is a simple, experimental C++ implementaion of the BD+ VM based on your specs (compiles, but not tested). Targets were keeping it short, maintainable and close to your notation. Hope I got all the signs right... Not sure about the commands for loading values from memory...
Great!
But you should probably use your own notation and keep my weird looking/confusing notations as comments.

I will record a trace of the first few commands executed by the virtual machine. Like
Code:
0000:1000 b0 00 00 40 -> PC = 0x1044
0000:1044 bc 00 ff fc -> no change
0000:1048 ...
We will use this for debugging. The 00000.svm is here: http://uploaded.to/?id=jqstc8

Edit: please use "cmd" for command and not "C" because i use "C" already otherwise. thanks.

Last edited by Oopho2ei; 2nd September 2008 at 22:08. Reason: 0x3FFFFFFC should have been 0x3FFFFC
  Reply With Quote