🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.forth
Article #20

<CMOVE

#20
From: utzoodecvaxucbvaxucbcadtektronix...
Date: Thu, 31 Mar 1983 09:36
33 lines
1515 bytes
: <CMOVE
  ( Copy n bytes starting at addr1 to addr2. The move )
  ( proceeds from high memory to low memory. )
  ( addr1 addr1 n --- )
DUP ROT +        ( Calculate addr2 + n )
SWAP ROT         (  and put it on bottom of stack )
1 -              ( DO-LOOP end = addr1 - 1 )
DUP ROT +        ( DO-LOOP start = addr1 + N - 1 )
DO
 1 -             ( Decrement last string 2 address )
 I C@            ( Fetch next byte from string 1 )
 OVER C!         (  and copy it to string 2 )
 -1              ( Decrement index )
+LOOP
DROP ;           ( Discard the string 2 address )

: CMOVE$
  ( Copy n bytes starting at addr1 to addr2. If addr2 )
  ( is forward of addr1, the move proceeds from high )
  ( memory to low memory; otherwise the move proceeds )
  ( from low memory to high memory. )
OVER 4 PICK       ( Copy addr2 addr1 on top of stack )
>                 ( Copying to a higher address? )
IF <CMOVE         ( if so, use <CMOVE )
ELSE CMOVE        ( if not, use CMOVE )
THEN ;

( if you don't have PICK ... )
: PICK
2 * SP@ + @ ;     ( without comments )

( these were taken ( except PICK ) from a book by LEO J. SCANLON )
( a HOWARD SAMS book ISBN 0-672-22007-5 $16.95 suggested price.)
Technical Details
Message-ID: <bnews.teklabs.1864>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
From: utzoo!decvax!ucbvax!ucbcad:tektronix!teklabs!paulba
Newsgroups: net.lang.forth
Title: <CMOVE
Article-I.D.: teklabs.1864
Posted: Thu Mar 31 09:36:18 1983
Received: Sat Apr  2 07:01:30 1983
Subject: <CMOVE
Date: Thu, 31 Mar 1983 09:36:18 +0000
Message-ID: <bnews.teklabs.1864>