kolibrios/programs/develop/SPForth/src/spf_forthproc_hl.f
Kirill Lipatov (Leency) 09488af869 KolSPForth12 uploaded to SVN
git-svn-id: svn://kolibrios.org@4867 a494cfbc-eb01-0410-851d-a64ba20cac60
2014-04-21 19:22:58 +00:00

105 lines
2.9 KiB
Forth
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

( Žá⠢訥áï á«®¢  "ä®àâ-¯à®æ¥áá®à " ¢ ¢¨¤¥ ¢ë᮪®ã஢­¥¢ëå ®¯à¥¤¥«¥­¨©.
Copyright [C] 1992-1999 A.Cherezov ac@forth.org
<EFBFBD>८¡à §®¢ ­¨¥ ¨§ 16 §à來®£® ¢ 32 §àï¤­ë© ª®¤ - 1995-96££
<EFBFBD>¥¢¨§¨ï - ᥭâï¡àì 1999
)
0 CONSTANT FALSE ( -- false ) \ 94 CORE EXT
\ ‚¥à­ãâì ä« £ "«®¦ì".
-1 CONSTANT TRUE ( -- true ) \ 94 CORE EXT
\ ‚¥à­ãâì ä« £ "¨á⨭ ", ï祩ªã á® ¢á¥¬¨ ãáâ ­®¢«¥­­ë¬¨ ¡¨â ¬¨.
4 CONSTANT CELL
: */ ( n1 n2 n3 -- n4 ) \ 94
\ “¬­®¦¨âì n1 ­  n2, ¯®«ãç¨âì ¯à®¬¥¦ãâ®ç­ë© ¤¢®©­®© १ã«ìâ â d.
\ <20> §¤¥«¨âì d ­  n3, ¯®«ãç¨âì ç áâ­®¥ n4.
*/MOD NIP
;
: CHAR+ ( c-addr1 -- c-addr2 ) \ 94
\ <20>ਡ ¢¨âì à §¬¥à ᨬ¢®«  ª c-addr1 ¨ ¯®«ãç¨âì c-addr2.
1+
;
: CHARS ( n1 -- n2 ) \ 94
\ n2 - à §¬¥à n1 ᨬ¢®«®¢.
; IMMEDIATE
: MOVE ( addr1 addr2 u -- ) \ 94
\ …᫨ u ¡®«ìè¥ ­ã«ï, ª®¯¨à®¢ âì ᮤ¥à¦¨¬®¥ u ¡ ©â ¨§ addr1 ¢ addr2.
\ <20>®á«¥ MOVE ¢ u ¡ ©â å ¯®  ¤à¥áã addr2 ᮤ¥à¦¨âáï ¢ â®ç­®á⨠⮠¦¥,
\ çâ® ¡ë«® ¢ u ¡ ©â å ¯®  ¤à¥áã addr1 ¤® ª®¯¨à®¢ ­¨ï.
>R 2DUP SWAP R@ + U< \ ­ §­ ç¥­¨¥ ¯®¯ ¤ ¥â ¢ ¤¨ ¯ §®­ ¨áâ®ç­¨ª  ¨«¨ «¥¢¥¥
IF 2DUP U< \ ˆ <20>… «¥¢¥¥
IF R> CMOVE> ELSE R> CMOVE THEN
ELSE R> CMOVE THEN ;
: ERASE ( addr u -- ) \ 94 CORE EXT
\ …᫨ u ¡®«ìè¥ ­ã«ï, ®ç¨áâ¨âì ¢á¥ ¡¨âë ª ¦¤®£® ¨§ u ¡ ©â ¯ ¬ïâ¨,
\ ­ ç¨­ ï á  ¤à¥á  addr.
0 FILL ;
: BLANK ( addr len -- ) \ fill addr for len with spaces (blanks)
BL FILL ;
: DABS ( d -- ud ) \ 94 DOUBLE
\ ud  ¡á®«îâ­ ï ¢¥«¨ç¨­  d.
DUP 0< IF DNEGATE THEN
;
255 CONSTANT MAXCOUNTED \ maximum length of contents of a counted string
\ : 0X BASE @ HEX >R BL WORD ?LITERAL
\ R> BASE ! ; IMMEDIATE
: "CLIP" ( a1 n1 -- a1 n1' ) \ clip a string to between 0 and MAXCOUNTED
MAXCOUNTED AND ;
: PLACE ( addr len dest -- )
SWAP "CLIP" SWAP
2DUP C! CHAR+ SWAP CHARS MOVE ;
: +PLACE ( addr len dest -- ) \ append string addr,len to counted
\ string dest
>R "CLIP" MAXCOUNTED R@ C@ - MIN R>
\ clip total to MAXCOUNTED string
2DUP 2>R
COUNT CHARS + SWAP MOVE
2R> +! ;
: C+PLACE ( c1 a1 -- ) \ append char c1 to the counted string at a1
DUP 1+! COUNT + 1- C! ;
: STR>R ( addr u -- addr1 u)
\ <20>®«®¦¨âì áâபã addr u ­  á⥪ ¢®§¢à â®¢
\ ‚®§¢à â¨âì addr1  ¤à¥á ­®¢®© áâப¨
;
0 VALUE DOES-CODE
: $! ( addr len dest -- )
PLACE ;
: ASCII-Z ( addr len buff -- buff-z ) \ make an ascii string
DUP >R $! R> COUNT OVER + 0 SWAP C! ;
: 0MAX 0 MAX ;
: ASCIIZ> ZCOUNT ;
: R> ['] C-R> INLINE, ; IMMEDIATE
: >R ['] C->R INLINE, ; IMMEDIATE
: 2CONSTANT ( d --- )
\ Create a new definition that has the following runtime behavior.
\ Runtime: ( --- d) push the constant double number on the stack.
CREATE HERE 2! 8 ALLOT DOES> 2@ ;
: U/MOD 0 SWAP UM/MOD ;
: 2NIP 2SWAP 2DROP ;
: ON TRUE SWAP ! ;
: OFF ( a--) 0! ;