Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack(s), Registers in ActionScript ByteCode AVM2, which all are there?

From the AVM2 Overview PDF I encountered references to two types of stacks - Scope Stack and Operand Stack.

1) I assume these are two different memory stacks, each handling different things. Are there even more stacks?

2) pushstring "hello" - this would push a start of memory address where "hello" string is located onto Operand Stack. Right?

3) setlocal 0 - this would store a value from the stack (above) into register0 by popping it off. Right?

4) PushScope() - hmm, docs say pop value of stack, push value onto Scope Stack. Why?

I know a little bit of NASM but ABC seems more complex than that. Especially I'm confused about Scope Stack and the whole concept of multiple stacks.

like image 624
Ska Avatar asked Mar 24 '11 16:03

Ska


1 Answers

I am no AVM2 expert, but here's what I know:

  1. There are only 2 stacks, the two you mention: scope and operand.
  2. Yes, pushstring "hello" will push the string onto the operand stack.
  3. Also, correct. setlocal0 will pop "hello" off the stack and store it in reg 0.
  4. The scope stack is used by all operations that require a name lookup for scope, for instance closures and exceptions. Often in ASM code you'll see getlocal_0 immediately followed by a pushscope. This is pretty common. You can kind of think of it as adding the "this" object to the scope stack for future reference in method calls, scope for closures, etc.

I highly recommend downloading the Tamarin source and playing with the decompiler there. Also, Yogda looks to be pretty handy for learning: http://www.yogda.com/

like image 149
svoisen Avatar answered Oct 12 '22 21:10

svoisen