The Arithmetic Example Again

So here's what that arithmetic example from the start of the day would look like on an HC11:


start   lds  #$ff       * set the stack pointer

        ldaa #1         * push(1)
        psha

        ldaa #5         * push(5)
        psha

        pulb            * push(pop() + pop())
        pula
        aba
        psha

        ldaa #2         * push(2)
        psha

        ldaa #3         * push(3)
        psha

        pulb            * push(pop() + pop())
        pula
        aba
        psha

        pulb           * push (-pop() + pop())
        pula
        sba
        psha

eloop   bra  eloop

(as you simulate this code, you'll be able to watch the data getting put on the stack, but when a pop() happens you won't see the data disappear. Actually erasing the data from the stack would take extra time, and there's no need to actually do it, but you must never try to access data once it's been popped. It turns out interrupts make use of the stack also, and so the data above the stack pointer can get corrupted at any moment).


Last modified: Fri Feb 27 10:10:28 MST 2004