Make virtual machine and compiler for the following instruction set.
LOD - Load into accumulator
STR - Store into memory
ADD - Add acc+mem
NEG - accumulator=accumulator*-1
INP - Input number to accumulator
OUT - Output
JMP - Jump to memory location
JNZ - Jump if accumulator non zero
If you do this, I WILL be impressed.
Name:
Anonymous2007-10-09 18:35
If you do this, I WILL be impressed.
And you'll probably pass whatever this is homework for. Which really shouldn't happen.
>>1 see >>6
There are so many missing implementation details that, with the right assumptions, the assignment is trivial. In which case you're just an idiot.
>>1
Virtual machines are not hard. I have implemented a few now (register based, stack based, fixed length instructions, variable length instructions, etc). Then again, I'm quite interested in this topic, so I guess I would look into such things. I also do compiler construction in uni.
Name:
Anonymous2007-10-09 20:46
>>11
Stack based? Sounds interesting. Mind sharing a bit of your code?
Name:
Anonymous2007-10-09 20:53
>>12
How the hell is that interesting? Naive stack based virtual machines are just about the easiest programmable thing you can code.
This reminds me of the time when I assigned almost the exact same assignment to my languages class. More than half of the class didn't finish, some barely finished, and one guy wrote a full assembler, disassembler, compiler, and decompiler for the virtual machine in the same amount of time.
>>20
my point exactly, /prog/ is saturated with EXPERT PROGRAMMERS discussing ''ABSTRACT BULLSHITE``, not writing silly little compilers (I wrote an ANSI C compiler when I was 12).
Name:
Anonymous2007-10-10 11:06
>>1
Great, you missed 90% of the specifications you faggot!
>>21
when you were 12 the standards for ANSI C were probably just the specifications for ``printf''
Name:
Anonymous2007-10-10 12:49
>>12 (Im >>11)
Its fairly simple actually. I did two, a forth-like interpreter and a stack based virtual machine.
The firth-like one simply read in a word at a time and performed some stack operation (though i had multiple stacks, I cant remember exactly, maybe 8). So, it reads a word from standard input and does something. For example, if it reads "+" it pops the top two values off the stack, adds them and pushes the result to the stack. Very simple. It only worked with integers too, because I was lazy.
The virtual machine one executed bytecode. Instead of operating on virtual registers however, it operates on a stack. So, the instruction set consisted of stack operations and other operations, the others operating on the top values of the stack.
Personally, I think stack based interpreters and VM's are easier to write than VM ones. Not that register based ones are hard. The hard part is ensuring that it's all efficient and performance is reasonable.. If performance doesn't matter, it's all extremely easy.
Name:
Anonymous2007-10-10 14:04
I have a much more challenging project for you, but only enterprise programmers can solve it. /prog/ doesn't seem to have many.
Name:
Anonymous2007-10-10 14:10
Now ITT we're discussing implementation of LISP-machines.
Name:
Anonymous2007-10-10 14:28
Here is your project:
1. Design a language M that is capable of describing any virtual machine.
2. Put the description of a virtual machine written in M at the beginning of the file, followed by the virtual machine program, and XOR the entire file with a key, the length of which is divisible by the length of the entire file. This will be the key to decrypt the file so the program can run.
Get coding, 'experts'.
Name:
Anonymous2007-10-10 21:24
Ok, I have designed such a language
X,Y,Z can be any of these addressing modes : absolute, indirect, register (including instruction pointer), or immediate
NOP - Do nothing
MOVE X,Y - Copy data from X to Y
AND X,Y,Z
OR X,Y,Z
NOT X,Z
Logical operation, result stored in Z
IFZ X
Execute next instruction only if X is zero
The End. Touring-Complete.
Name:
Anonymous2007-10-10 21:25
Oh, and throw in an XOR
Name:
Anonymous2007-10-10 21:40
this is trivial if you've read sicp.
No, it's not just another pointless reference. I'm telling the truth!
Preferably, slowly and painful. Barbed wire is a good option to start unstoppable bleeding. Make sure to go slow so you will suffer the must amount of pain for the longest period of time.
Name:
Anonymous2007-10-11 13:24
>>39
HAHAHAHAHAHAHAHHAHAHAHAAHAHAAAA!!!
you think your funny huh?
Name:
Anonymous2007-10-11 16:07
>>40
Make sure to go slow so you will suffer the must amount of pain for the longest period of time.
suffer the must amount of pain
must
>>56
im not sure about making the VM too esoteric, ideally it would be reasonably easy to program in it.
im thinking of instructions to operate the engines (move and turn), sensors (copy input into memory somewhere) and actuator (interact with environment)..