Initial stab at implementing some new memory funcs.

Borrowed from JPCSP, kept simple.  Need to do tests.
Merge pull request #1216 from unknownbrackets/alloc-func

Initial stab at implementing some new memory funcs