RaghavendraK 70574 wrote:
> Because all the modern CPU are Register based.

All modern *physical* CPUs are register-based; however, most modern *virtual* CPUs (virtual machines) are stack-based. Parrot is unique because it's a register-based *virtual* CPU.

Regster Based: Each Instruction will have to carry a destination along with the 
operands.
Stack Based: Instruction is free of operands meaining operands are saved in the stack.

These definitions are subtly incorrect.

Stack-based: each instruction takes its operands off the stack, operates on them, and pushes the result onto the stack. There are no operands in the bytecode stream, except for opcodes that push constants onto the stack. (Or something along those lines.)

    # bar=1+foo
    push_num 1
    push_str "foo"
    get_var
    add
    push_str "bar"
    set_var

Register-based: each instruction operates on its operands.

    # bar=1+foo
    get_var r0, "foo"
    add r1, 1, r0
    set_var "bar", r1

Note that the above examples are just pseudocode.

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.

Reply via email to