Post Reply 
Scientific RPN Calculator (with ATTINY85)
03-06-2018, 09:22 PM
Post: #9
RE: Scientific RPN Calculator (with ATTINY85)
(03-06-2018 02:23 PM)deetee Wrote:  One thing to save memory is to use local variables. So I did with declaring the stack variables (xyzu) local. So I have to send to the push and pop subroutine the 4 variable pointers.
But I use this subroutine relative often - and did not check if it is worth to declare the stack as global variables. I will check.

Checking is easy (pull is similar):
Code:
#define push(a,b,c,d) push_stack()
static void push_stack(void) { // Push stack
  *u = *z; *z = *y; *y = *x;
}

I declared the function static because some compilers can do better knowing they are always local. Improved calling conventions etc. I don't think I seen a case where doing so produced larger code.

Another trick that sometimes works is to reduce the optimisation level used when compiling -- paradoxically smaller/faster code is sometimes produced.


Another thought that came overnight is to not use the library mathematical function -- they usually trade space for speed, check for edge cases in detail and probably implement the IEEE standard.


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Scientific RPN Calculator (with ATTINY85) - Paul Dale - 03-06-2018 09:22 PM



User(s) browsing this thread: 2 Guest(s)