Docstoc

Simulator

Document Sample
Simulator Powered By Docstoc
					 Simulator

How to interface
    Expressoo Calling Conventions

   Expressoo procedures expect parameters
    to be passed as values on the stack
   Example
       integer proc1(integer a, integer b)
       expects b to be the top value of the stack
       a to be the second from the top
       etc.
                                Example
                                        Stack Top
                                                     High Mem
integer proc1(integer a, integer b)    integer b

                                       integer a

                                      return value




                                                     Low Mem
                Example For Sheldon

integer proc1(integer a, integer b)
                                                     Low Mem




                                      return value

                                       integer a

                                       integer b
                                                     High Mem
                                       Stack Top
                         MemAlloc
memAlloc
   Vector Address:       0x02
   Registers Used:       r0, r1
Input Parameters:
   r1  requested memory size in words (4 bytes)
   r2  address of avail pointer
Returned Value(s):
   r1  address on the heap
   r0  failed = 0 succeeded = 1
Operation(s): The number words in r1 are allocated from the heap
   and the address of the allocated memory is returned in r1. Allocated
   memory is initialized to 0x0’s. Success or failure is in r0.
             Wrapping a Procedure
   New makes a call to MemAlloc
   If your function is named alloc
    integer^ alloc(int size,int^ avail)
   You need to set up the stack for this call
    push 0       # make space for the return value
    push r1      # the size
    push r2      # the avail pointer
   When alloc returns
    pop          # get rid of parameter
    pop          # get rid of parameter
    pop r1       # save return value of function in r1
    ret                  # from memAlloc

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:6
posted:8/15/2012
language:English
pages:6