From d57a02efd8b6388c43c85078ccd20fd6bd7a8e37 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 1 Dec 2011 22:24:48 +0000 Subject: Update TODO, README and add notes for call convention --- notes.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 notes.txt (limited to 'notes.txt') diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..d2998c1 --- /dev/null +++ b/notes.txt @@ -0,0 +1,46 @@ +Build a table for a (x+1)-bit number and their signed values in binary/decimal +var a = [], x=4; +var zpad = (new Array(x+1)).join("0"), pad = (new Array(x+1)).join(" "); +for(var i=0;i<2< +2. For n parameters, do a PUSH. The last parameter is the first on the stack +3. Call subroutine (BRS: PUSH return address on stack and BRanch Always) +(after call when returned:) +4. Remove parameters from the stack: ADD SP n +5. Result is in R0 +6. (perhaps a CMP R0 0 or LOAD R0 R0 if in expression context?) + +Callee: +1. push R5 (base pointer "BP" in stack for local variables and parameters) +2. Store current stack pointer in R5 (LOAD R5 SP). [R5] now contains the return + address, [R5+i] the i-th parameter and [R5+-i] the i-th local var +3. Grow stack for local variables (by SUB SP n) if necessary +4. +5. LOAD SP R5 (clear local vars) +5. PULL R5 (restore the "BP" of the caller) +6. RTS (go back to caller) + +parameter access (i-th parameter): +LOAD R0 [R5+i] +local variable access (i-th local var) +LOAD R0 [R5+-i] +global variable access +LOAD R0 [GB+name] + + +Initially, the stack size on the PP2 is 240 words, but it can be adjusted with: +@STACKSIZE newsize +The constant 'stacksize' (lowercase) contains the previous stack size -- cgit v1.2.1