;; ;; $Id: stack.asm,v 1.1 2001/03/05 03:48:20 james Exp $ ;; ;; stack.asm, code that would belong in stack.inc perhaps ;; Copyright (C) 2001 James Cameron (quozl@us.netrek.org) ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;; ;;; ;;; pick ;;; ;;; Delve into the stack by "depth" items and copy the selected item to ;;; the top of the stack. FORTH-like. ;;; pick ; ( depth -- value ) movf fsr,w ; fetch the stack pointer movwf r_ephemeral ; save it for later popw ; pop off the depth addwf fsr,f ; dig into the stack peekw ; pull out the value movwf r_temporary ; save in temporary movf r_ephemeral,w ; restore the stack pointer movwf fsr ; and set it movf r_temporary,w ; pull out the value pokew ; overwrite the depth with it return