开发者

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

开发者 https://www.devze.com 2023-02-20 02:21 出处:网络
From the AVM2 Overview PDF I encountered references to two types of stacks - Scope Stack and Operand Stack.

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 concep开发者_开发问答t of multiple stacks.


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消