Questions tagged [vm-implementation]

Design and implementation of virtual machines, interpreters, automata, Turing machines. **DO NOT** use this tag for virtualized computers (VirtualBox, VMWare, ...), unless the question address the implementation of such tools.

294 questions
0
votes
0 answers

C Virtual machine Command with same opcode

Im attempting to put together a basic C Virtual machine that will read a binary file from an assembler program and use that file to execute commands based on the binary data in that file. Im at the point where i need to decode values into its hex…
Bret Hasel
  • 303
  • 1
  • 11
0
votes
1 answer

Decoding instruction of hypothetical CPU

Before I created the following question I've read a some similar questions on SO, but I didn't find the answer of my question. Lets assume that I have the following bits stream 010001 01000 1010100 01100 010001 -> represents the instruction add…
bielu000
  • 1,826
  • 3
  • 21
  • 45
0
votes
1 answer

Type of a stack entry (in a virtual machine)

There is something that I can't quite really understand about stack-based virtual machines: What is the type of the value that is stored in the stack? What I mean is that for example, if I pushed an integer onto the stack, it's clear that it's type…
Kai
  • 398
  • 2
  • 11
0
votes
1 answer

Add nested-function support in a language the based on a stack-machine

Suppose I have a simple C-like programming language: int foo() { int x = 10; int bar(y int) { return y * 2 } return bar() + x } Like you can see, it supports nested functions. I already implemented the lexing-parsing…
mux
  • 455
  • 5
  • 10
0
votes
3 answers

C++ Coding virtual machine

I haven't done much coding in C++, but I? noticed that I have to run these build scripts for everything. HOw do people do these on windows machines? I am thinking about running a virtual machine anyway, so I don't have to fill my machine with python…
ari_aaron
  • 43
  • 5
0
votes
2 answers

Simple Interpreted Language Design & Implementation

I need some resources for implementing a simple virtual machine and interpreted language. Something that is pratical is most useful. I have read the Virtual Machine Implementation book and found that it is quite old and doesn't represent the vms I…
Gavin
0
votes
1 answer

How to implement fast runtime errors in a virtual machine?

So I made a basic stack-based virtual machine and a compiler that compiles bytecode for it, but I've run into an issue that I have no idea how to solve. I need to check for things like dividing by zero and stack overflows and throw runtime errors,…
Alex
  • 846
  • 6
  • 16
0
votes
1 answer

Implement Stack for Virtual Machine C++

Recently for fun I have decided to build a toy programming, compiler and vm. While starting to implement the virtual machine I got stuck. The stack which holds the variables and structs I implemented as separate arrays for each type. The problem is…
Coder3000
  • 130
  • 7
0
votes
1 answer

broken push instruction for vm

I am developing a virtual machine and have a problem with my push instruction. It pushes an explicit value and not what is held in the referenced register e.g: 0x0064 //this line puts hexadecimal for 100 into register 0 0x4000 //this is the…
user5464295
0
votes
1 answer

Dalvik registers higher than 256

Dalvik documentation says that "some instructions have variants that allow for much larger register counts, including a pair of catch-all move instructions that can address registers in the range v0 – v65535." But I can't see such move instructions…
Andrey Kon
  • 747
  • 2
  • 6
  • 16
0
votes
3 answers

Is it misleading to say that intermediate code runs in a virtual machine

If I am correct in understanding what I've read a virtual machine is essentially a compiler for intermediate code. But it is never said that Delphi (as an example of unmanaged code) runs in its compiler. Would it be less confusing to just describe a…
0
votes
1 answer

Difference between PyPy and JVM

From my understanding the default Python interpreter (CPython) compiles source code into bytecode and then interprets the bytecode into machine code. PyPy on the other hand makes use of JIT to optimize often interpreted bytecode into compiled…
BubbleTree
  • 566
  • 5
  • 11
  • 23
0
votes
2 answers

Programmatic introspection/reflection - easier in VMs?

What makes programmatic introspection/reflection easier in virtual machines rather than native code? I read somewhere that VMs by nature allow for better introspection/reflection capabilities but I cannot find more information about it online. Would…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
2 answers

How to implement tail calls in a custom VM

How can I implement tail calls in a custom virtual machine? I know that I need to pop off the original function's local stack, then it's arguments, then push on the new arguments. But, if I pop off the function's local stack, how am I supposed to…
Puppy
  • 144,682
  • 38
  • 256
  • 465
0
votes
0 answers

Efficient runtime representation of setter/getter functions

For a class declaration like (using a dynamically typed language I am develop): class Foo { var bar { get { return bar; } set(value) { bar = value; } } } User can the write something like: var f = New Foo(); f.bar =…
Marco
  • 783
  • 5
  • 21