Stack manipulation



      ckheight      ckheight_n      dup      dup2
      dup_n      dup_word_n      local_alloc      pop
      pop2      pop_n      squash 


 ckheight 
  ·  OperationCheck the height of the stack
  ·  Format
ckheight
0
0
0
0
  ·  Direct Format
{ckheight}
0
  ·  Forms ckheight = 64 (0x40)
   · Description Check that the stack has at least 8 words of space available for pushing values.
   · Notes This instruction is used at the start of a method to check that that there is sufficient stack space to hold the local variables and temporary stack values used by the method.

The opcode is followed by 4 zero bytes so that this instruction has the same length as ckheight_n. This makes it easier to back-patch the height after translating the method.

   · Exceptions System.StackOverflowException -- Raised if there is insufficient space available on the stack.


 ckheight_n 
  ·  OperationCheck the height of the stack for N words of available space
  ·  Format
ckheight_n
N[4]
  ·  Direct Format
{ckheight_n}
N
  ·  Forms ckheight_n = 65 (0x41)
   · Description Check that the stack has at least N words of space available for pushing values.
   · Notes This instruction is used at the start of a method to check that that there is sufficient stack space to hold the local variables and temporary stack values used by the method.
   · Exceptions System.StackOverflowException -- Raised if there is insufficient space available on the stack.


 dup 
  ·  OperationDuplicate the top of stack
  ·  Format
dup
  ·  Direct Format
{dup}
  ·  Forms dup = 56 (0x38)
  ·  Stack..., value => ..., value, value
   · Description Pop the single-word value from the stack, and then push it twice.


 dup2 
  ·  OperationDuplicate the top two stack words
  ·  Format
dup2
  ·  Direct Format
{dup2}
  ·  Forms dup2 = 57 (0x39)
  ·  Stack..., value1, value2 => ..., value1, value2, value1, value2
   · Description Pop the words value1 and value2 from the stack and then push them twice.


 dup_n 
  ·  OperationDuplicate the top N stack words
  ·  Format
dup_n
N[1]
wide
dup_n
N[4]
  ·  Direct Format
{dup_n}
N
  ·  Forms dup_n = 58 (0x3A)
  ·  Stack..., value1, ..., valueN => ..., value1, ..., valueN, value1, ..., valueN
   · Description Pop the top N words from the stack and then push them twice.
   · Notes This is typically used for value type instances that are larger than 2 words in size.


 dup_word_n 
  ·  OperationDuplicate a stack word that is N words down the stack
  ·  Format
dup_word_n
N[1]
wide
dup_word_n
N[4]
  ·  Direct Format
{dup_word_n}
N
  ·  Forms dup_word_n = 59 (0x3B)
  ·  Stack..., value, word1, ..., wordN => ..., value, word1, ..., wordN, value
   · Description Retrieve the value that is N words down the stack and push it onto the top of the stack.


 local_alloc 
  ·  OperationAllocate local stack space
  ·  Format
prefix
local_alloc
  ·  Direct Format
{local_alloc}
  ·  Forms local_alloc = 255, 92 (0xFF, 0x5C)
  ·  Stack..., size => ..., pointer
   · Description Pop size from the stack as type uint, and then push a pointer to a block of memory of size bytes in size.
   · Notes The block is not expected to last beyond the lifetime of the current method, but implementations may allocate longer-term memory if it is difficult to do direct stack allocation.
   · Exceptions System.OutOfMemoryException -- Raised if there is insufficient memory to allocate the block.


 pop 
  ·  OperationPop the top-most word from the stack
  ·  Format
pop
  ·  Direct Format
{pop}
  ·  Forms pop = 60 (0x3C)
  ·  Stack..., value => ...
   · Description Pop the single-word value from the stack.


 pop2 
  ·  OperationPop the top two words from the stack
  ·  Format
pop2
  ·  Direct Format
{pop2}
  ·  Forms pop2 = 61 (0x3D)
  ·  Stack..., value1, value2 => ...
   · Description Pop the two stack words value1 and value2 from the stack.


 pop_n 
  ·  OperationPop the top N words from the stack
  ·  Format
pop_n
N[1]
wide
pop_n
N[4]
  ·  Direct Format
{pop_n}
N
  ·  Forms pop_n = 62 (0x3E)
  ·  Stack..., value1, ..., valueN => ...
   · Description Pop the top N stack words from the stack.


 squash 
  ·  OperationSquash a number of words out of the stack
  ·  Format
squash
N[1]
M[1]
wide
squash
N[4]
M[4]
  ·  Direct Format
{squash}
N
M
  ·  Forms squash = 63 (0x3F)
  ·  Stack..., word1, ..., wordM, value1, ..., valueN => ..., value1, ..., valueN
   · Description Remove the M words from the stack, N words down the stack.


Copyright © Southern Storm Software Pty Ltd 2002
Licensed under GNU FDL