diff --git a/calculator.asm b/calculator.asm index 6e0c31e..3f38680 100644 --- a/calculator.asm +++ b/calculator.asm @@ -78,6 +78,26 @@ stEmit: store ffff, r1 ret +; ------------------------------------------------------------------ +; Stack manipulation +; ------------------------------------------------------------------ + +; a - a a +stDup: + cleq r0, r0, peekWord + breq r0, r0, pushWord + +; a b -- a b a +stOver: + cleq r0, r0, popWord + cleq r0, r0, tmpStoreWord01 + cleq r0, r0, peekWord + cleq r0, r0, tmp2StoreWord01 + cleq r0, r0, tmpLoadWord01 + cleq r0, r0, pushWord + cleq r0, r0, tmp2LoadWord01 + breq r0, r0, pushWord + ; ================================================================== ; Low-level functions ; ==================================================================