What is the difference between stack based VM and register based VM?

28th Dec 2016, 3:37 AM
Arpitha G R
Arpitha G R - avatar
1 Answer
+ 1
The stack based VM use a memory structure where the operands are stored in a stack data structure. They generally use the LIFO to push and POP value to do the operations. This mean that the VM don't really care about the operands addresses because the POP will give the next one. And the register based implementation is the oposite. They are ni PUSH or POP operation. The instruction need to contains the addresses (the registers) of the operands. Simple exemple of an addition with assembler look alike code: Stack base: POP 2 # get value POP 3 # get Value ADD 2, 2, result # make the addition PUSH result # store the value Register based: ADD R1, R2, R3 ; # We had the contant of R1 and R2 in R3
28th Dec 2016, 9:21 AM
Florian Castelain
Florian Castelain - avatar