Administrator
|
Depends on what you mean by "clearing the stack".
The usual way is simply set the stack pointer to the bottom of the stack.
@256
D=A
@SP
M=D
Consider that, when you first start the machine, you don't go through as set the contents of all of the memory cells in the stack to zero -- so they start out with whatever random junk they had when the machine powered up (or would in the real world). So if your design can tolerate that, it can tolerate it when that "junk" happens to be the leftovers from prior computations.
Now, it is important to realize that leaving that junk there IS a potential security risk since it leaks information. Some software deals with this by specifically zeroing out (or writing random garbage) into cells whose values are no longer needed. But there's a significant performance penalty to pay for that added security.
|