kolibrios/programs/develop/SPForth/src/spf_forthproc.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

1385 lines
31 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
)
( <EFBFBD>¥ «¨§ æ¨ï ¤«ï ¯®¤¯à®£à ¬¬­®£® è¨â®£® ª®¤ .
ESP - 㪠§ â¥«ì á⥪  ¢®§¢à â®¢
EBP - 㪠§ â¥«ì á⥪  ¤ ­­ëå
EDI - á®åà ­ï¥¬ë© à¥£¨áâà [㪠§ â¥«ì ¤ ­­ëå ¯®â®ª  ¢ SPF]
)
HEX
\ ================================================================
\ ‘⥪®¢ë¥ ¬ ­¨¯ã«ï樨
?HS
Code DUP ;( x -- x x ) \ 94
; <EFBFBD>த㡫¨à®¢ âì x.
LEA EBP, [EBP-4]
mov [ebp],eax
RET
EndCode
\ ' DUP TO 'DUP_V
Code ?DUP ;( x -- 0 | x x ) \ 94
; <EFBFBD>த㡫¨à®¢ âì x, ¥á«¨ ­¥ ­®«ì.
OR EAX, EAX
JNZ { ' DUP }
RET
EndCode
Code 2DUP ;( x1 x2 -- x1 x2 x1 x2 ) \ 94
; <EFBFBD>த㡫¨à®¢ âì ¯ àã ï祥ª x1 x2.
MOV EDX, [EBP]
MOV [EBP-4], EAX
MOV [EBP-8], EDX
LEA EBP, [EBP-8]
RET
EndCode
Code DROP ;( x -- ) \ 94
; “¡à âì x á® á⥪ .
mov eax,[ebp]
LEA EBP, [EBP+4]
RET
EndCode
\ ' DROP TO 'DROP_V
Code MAX ;( n1 n2 -- n3 ) \ 94
; n3 - ¡®«ì襥 ¨§ n1 ¨ n2.
CMP EAX, [EBP]
JL { ' DROP }
LEA EBP, [EBP+4]
RET
EndCode
Code MIN ;( n1 n2 -- n3 ) \ 94
; n3 - ¬¥­ì襥 ¨§ n1 ¨ n2.
CMP EAX, [EBP]
JG { ' DROP }
LEA EBP, [EBP+4]
RET
EndCode
Code UMAX ;( u1 u2 -- n3 ) \ RETurn the lesser of unsigned u1 and
; unsigned u2
CMP EAX, [EBP]
JB { ' DROP }
LEA EBP, [EBP+4]
RET
EndCode
Code UMIN ;( u1 u2 -- n3 ) \ RETurn the lesser of unsigned u1 and
; unsigned u2
CMP EAX, [EBP]
JA { ' DROP }
LEA EBP, [EBP+4]
RET
EndCode
Code 2DROP ;( x1 x2 -- ) \ 94
; “¡à âì á® á⥪  ¯ àã ï祥ª x1 x2.
MOV EAX , [EBP+4]
ADD EBP , 8
RET
EndCode
Code SWAP ;( x1 x2 -- x2 x1 ) \ 94
; ¯®¬¥­ïâì ¬¥áâ ¬¨ ¤¢  ¢¥àå­¨å í«¥¬¥­â  á⥪ 
; XCHG EAX { EBP }
MOV EDX, [EBP]
MOV [EBP], EAX
MOV EAX, EDX
RET
EndCode
Code 2SWAP ;( x1 x2 x3 x4 -- x3 x4 x1 x2 ) \ 94
; <EFBFBD>®¬¥­ïâì ¬¥áâ ¬¨ ¤¢¥ ¢¥àå­¨¥ ¯ àë ï祥ª.
MOV ECX, [EBP]
MOV EBX, [EBP+4]
MOV EDX, [EBP+8]
MOV [EBP+8], ECX
MOV [EBP+4], EAX
MOV [EBP], EDX
MOV EAX, EBX
RET
EndCode
Code OVER ;( x1 x2 -- x1 x2 x1 ) \ 94
; <EFBFBD>®«®¦¨âì ª®¯¨î x1 ­  ¢¥à設ã á⥪ .
LEA EBP, [EBP-4]
MOV [EBP], EAX
MOV EAX, [EBP+4]
RET
EndCode
Code 2OVER ;( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) \ 94
; Š®¯¨à®¢ âì ¯ àã ï祥ª x1 x2 ­  ¢¥à設ã á⥪ .
MOV EDX, [EBP+8]
MOV [EBP-4], EAX
MOV [EBP-8], EDX
MOV EAX, [EBP+4]
LEA EBP, [EBP-8]
RET
EndCode
Code NIP ;( x1 x2 -- x2 ) \ 94 CORE EXT
; “¡à âì ¯¥à¢ë© í«¥¬¥­â ¯®¤ ¢¥à設®© á⥪ .
ADD EBP, 4
RET
EndCode
Code ROT ;( x1 x2 x3 -- x2 x3 x1 ) \ 94
; <EFBFBD>பàãâ¨âì âਠ¢¥àå­¨å í«¥¬¥­â  á⥪ .
; XCHG EAX [EBP]
; XCHG EAX 4 [EBP]
MOV EDX, [EBP]
MOV [EBP], EAX
MOV EAX, [EBP+4]
MOV [EBP+4], EDX
RET
EndCode
Code -ROT ;( x1 x2 x3 -- x3 x1 x2 ) ; !!!!!
; Ž¡à â­®¥ ROT
MOV EDX, [EBP+4]
MOV [EBP+4], EAX
MOV EAX, [EBP]
MOV [EBP], EDX
RET
EndCode
Code PICK ;( ... +n -- ... w ) \ Copy the nth stack item to tos.
MOV EAX, [EBP + EAX*4 ]
RET
EndCode
Code ROLL ;( xu xu-1 ... x0 u -- xu-1 ... x0 xu ) \ 94 CORE EXT
; “¡à âì u. <EFBFBD>®¢¥à­ãâì u+1 í«¥¬¥­â ­  ¢¥à設¥ á⥪ .
; <EFBFBD>¥®¯à¥¤¥«¥­­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ ¯¥à¥¤ ¢ë¯®«­¥­¨¥¬ ROLL
; ­  á⥪¥ ¬¥­ìè¥ ç¥¬ u+2 í«¥¬¥­â®¢.
OR EAX, EAX
JZ SHORT LL1
MOV ECX, EAX
LEA EAX, [EAX*4]
MOV EDX, EBP
ADD EDX, EAX
MOV EBX, [EDX]
LL2: LEA EDX, [EDX-4]
MOV EAX, [EDX]
MOV [EDX+4], EAX
DEC ECX
JNZ SHORT LL2
MOV EAX, EBX
JMP SHORT LL3
LL1: MOV EAX, [EBP]
LL3: LEA EBP, [EBP+4]
RET
EndCode
Code TUCK ;( x1 x2 -- x2 x1 x2 ) \ 94
LEA EBP, [EBP-4]
MOV EDX, [EBP+4]
MOV [EBP], EDX
MOV [EBP+4], EAX
RET
EndCode
\ ================================================================
\ ‘⥪ ¢®§¢à â®¢
Code 2>R ; 94 CORE EXT
; ˆ­â¥à¯à¥â æ¨ï: ᥬ ­â¨ª  ­¥®¯à¥¤¥«¥­ .
; ‚믮«­¥­¨¥: ;( x1 x2 -- ) ;( R: -- x1 x2 )
; <EFBFBD>¥à¥­¥á⨠¯ àã ï祥ª x1 x2 ­  á⥪ ¢®§¢à â®¢. ‘¥¬ ­â¨ç¥áª¨
; íª¢¨¢ «¥­â­® SWAP >R >R.
POP EBX
PUSH DWORD PTR [EBP]
PUSH EAX
LEA EBP, [EBP+8]
MOV EAX, [EBP-4]
JMP EBX
EndCode
Code 2R> ; 94 CORE EXT
; ˆ­â¥à¯à¥â æ¨ï: ᥬ ­â¨ª  ­¥®¯à¥¤¥«¥­ .
; ‚믮«­¥­¨¥: ;( -- x1 x2 ) ;( R: x1 x2 -- )
; <EFBFBD>¥à¥­¥á⨠¯ àã ï祥ª x1 x2 á® á⥪  ¢®§¢à â®¢. ‘¥¬ ­â¨ç¥áª¨
; íª¢¨¢ «¥­â­® R> R> SWAP. \ !!!!
LEA EBP, [EBP-8]
POP EBX
MOV [EBP+4], EAX
POP EAX
POP DWORD PTR [EBP]
PUSH EBX
RET
EndCode
Code R@ ; 94
; ˆá¯®«­¥­¨¥: ;( -- x ) ;( R: x -- x )
; ˆ­â¥à¯à¥â æ¨ï: ᥬ ­â¨ª  ¢ ०¨¬¥ ¨­â¥à¯à¥â æ¨¨ ­¥®¯à¥¤¥«¥­ .
LEA EBP, [EBP-4]
MOV [EBP], EAX
MOV EAX, [ESP + 4 ]
RET
EndCode
Code 2R@ ; 94 CORE EXT
; ˆ­â¥à¯à¥â æ¨ï: ᥬ ­â¨ª  ­¥®¯à¥¤¥«¥­ .
; ‚믮«­¥­¨¥: ;( -- x1 x2 ) ;( R: x1 x2 -- x1 x2 )
; Š®¯¨à®¢ âì ¯ àã ï祥ª x1 x2 á® á⥪  ¢®§¢à â®¢. ‘¥¬ ­â¨ç¥áª¨
; íª¢¨¢ «¥­â­® R> R> 2DUP >R >R SWAP.
LEA EBP, [EBP-8]
MOV [EBP+4], EAX
MOV EAX, [ESP + { 2 CELLS } ]
MOV DWORD PTR [EBP], EAX
MOV EAX, [ESP + 4 ]
RET
EndCode
\ ================================================================
\ Ž¯¥à æ¨¨ á ¯ ¬ïâìî
Code @ ;( a-addr -- x ) \ 94
; x - §­ ç¥­¨¥ ¯®  ¤à¥áã a-addr.
MOV EAX, [EAX ]
RET
EndCode
Code ! ;( x a-addr -- ) \ 94
;  ¯¨á âì x ¯®  ¤à¥áã a-addr.
MOV EDX, [EBP]
MOV DWORD PTR [EAX ], EDX
MOV EAX , [EBP+4]
ADD EBP , 8
RET
EndCode
Code C@ ;( c-addr -- char ) \ 94
; <EFBFBD>®«ãç¨âì ᨬ¢®« ¯®  ¤à¥áã c-addr. <EFBFBD>¥§­ ç é¨¥ áâ à訥 ¡¨âë ï祩ª¨ ­ã«¥¢ë¥.
MOVZX EAX, BYTE PTR [EAX ]
RET
EndCode
Code C! ;( char c-addr -- ) \ 94
;  ¯¨á âì char ¯®  ¤à¥áã a-addr.
MOV EDX, [EBP]
MOV BYTE PTR [EAX ], DL
MOV EAX , [EBP+4]
ADD EBP , 8
RET
EndCode
Code W@ ;( c-addr -- word )
; <EFBFBD>®«ãç¨âì word ¯®  ¤à¥áã c-addr. <EFBFBD>¥§­ ç é¨¥ áâ à訥 ¡¨âë ï祩ª¨ ­ã«¥¢ë¥.
MOVZX EAX, WORD PTR [EAX ]
RET
EndCode
Code W! ;( word c-addr -- )
;  ¯¨á âì word ¯®  ¤à¥áã a-addr.
MOV EDX, [EBP]
MOV WORD PTR [EAX ], DX
MOV EAX , [EBP+4]
ADD EBP , 8
RET
EndCode
Code 2@ ;( a-addr -- x1 x2 ) \ 94
; <EFBFBD>®«ãç¨âì ¯ àã ï祥ª x1 x2, § ¯¨á ­­ãî ¯®  ¤à¥áã a-addr.
; x2 ¯®  ¤à¥áã a-addr, x1 ¢ á«¥¤ãî饩 ï祩ª¥.
; <EFBFBD> ¢­®á¨«ì­® DUP CELL+ @ SWAP @
MOV EDX, [EAX + 4 ]
LEA EBP, [EBP-4]
MOV DWORD PTR [EBP], EDX
MOV EAX, DWORD PTR [EAX ]
RET
EndCode
Code 2! ;( x1 x2 a-addr -- ) \ 94
;  ¯¨á âì ¯ àã ï祥ª x1 x2 ¯®  ¤à¥áã a-addr,
; x2 ¯®  ¤à¥áã a-addr, x1 ¢ á«¥¤ãîéãî ï祩ªã.
; <EFBFBD> ¢­®á¨«ì­® SWAP OVER ! CELL+ !
MOV EDX, [EBP]
MOV [EAX], EDX
MOV EDX, [EBP+4]
MOV [EAX+4], EDX
LEA EBP, [EBP+0CH]
MOV EAX, [EBP-4]
RET
EndCode
Code D@ ;( a-addr -- x1 x2 )
; 2@ SWAP
MOV EDX, [EAX]
LEA EBP, [EBP-4]
MOV DWORD PTR [EBP], EDX
MOV EAX, DWORD PTR [EAX+4]
RET
EndCode
Code D! ;( x1 x2 a-addr -- )
; >R SWAP R> 2!
MOV EDX, [EBP]
MOV [EAX+4], EDX
MOV EDX, [EBP+4]
MOV [EAX], EDX
LEA EBP, [EBP+0CH]
MOV EAX, [EBP-4]
RET
EndCode
Code EBX@ ;( -- EBX )
LEA EBP, [EBP-4]
mov [ebp],eax
MOV EAX,EBX
RET
EndCode
\ ================================================================
\ ‚ëç¨á«¥­¨ï
Code 1+ ;( n1|u1 -- n2|u2 ) \ 94
; <EFBFBD>ਡ ¢¨âì 1 ª n1|u1 ¨ ¯®«ãç¨âì á㬬ã u2|n2.
LEA EAX, [EAX+1]
RET
EndCode
Code 1- ;( n1|u1 -- n2|u2 ) \ 94
; ‚ëç¥áâì 1 ¨§ n1|u1 ¨ ¯®«ãç¨âì à §­®áâì n2|u2.
LEA EAX, [EAX-1]
RET
EndCode
Code 2+ ;( W -> W+2 )
LEA EAX, [EAX+2]
RET
EndCode
Code 2- ;( W -> W-2 )
LEA EAX, [EAX-2]
RET
EndCode
Code 2* ;( x1 -- x2 ) \ 94
; x2 - १ã«ìâ â ᤢ¨£  x1 ­  ®¤¨­ ¡¨â ¢«¥¢®, á § ¯®«­¥­¨¥¬
; ­ ¨¬¥­¥¥ §­ ç¨¬®£® ¡¨â  ­ã«¥¬.
; SHL EAX
; LEA EAX, [EAX+EAX]
LEA EAX, [EAX*2]
RET
EndCode
Code CELL+ ;( a-addr1 -- a-addr2 ) \ 94
; ‚ëç¥áâì à §¬¥à ï祩ª¨ ª a-addr1 ¨ ¯®«ãç¨âì a-addr2.
LEA EAX, [EAX+4]
RET
EndCode
Code CELL- ;( a-addr1 -- a-addr2 ) \ 94
; ‚ëç¥áâì à §¬¥à ï祩ª¨ ª a-addr1 ¨ ¯®«ãç¨âì a-addr2.
LEA EAX, [EAX-4]
RET
EndCode
Code CELLS ;( n1 -- n2 ) \ 94
; n2 - à §¬¥à n1 ï祥ª.
LEA EAX, DWORD PTR [EAX *4 ]
RET
EndCode
Code + ;( n1|u1 n2|u2 -- n3|u3 ) \ 94
; ‘«®¦¨âì n1|u1 ¨ n2|u2 ¨ ¯®«ãç¨âì á㬬ã n3|u3.
ADD EAX, DWORD PTR [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code D+ ;( d1|ud1 d2|ud2 -- d3|ud3 ) \ 94 DOUBLE
; ‘«®¦¨âì d1|ud1 ¨ d2|ud2 ¨ ¤ âì á㬬ã d3|ud3.
MOV EDX, DWORD PTR [EBP]
ADD DWORD PTR [EBP + { 2 CELLS } ], EDX
ADC EAX, DWORD PTR [EBP +4 ]
LEA EBP, [EBP+8]
RET
EndCode
Code D- ;( d1 d2 -- d3 ) \ 94 DOUBLE
; perform a double subtract (64bit)
MOV EDX, DWORD PTR [EBP]
SUB DWORD PTR [EBP + { 2 CELLS } ], EDX
SBB [EBP+4], EAX
MOV EAX, DWORD PTR [EBP +4 ]
LEA EBP, [EBP+8]
RET
EndCode
Code - ;( n1|u1 n2|u2 -- n3|u3 ) \ 94
; ‚ëç¥áâì n2|u2 ¨§ n1|u1 ¨ ¯®«ãç¨âì à §­®áâì n3|u3.
NEG EAX
ADD EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code 1+! ;( A -> )
INC DWORD PTR [EAX ]
MOV EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code 0! ;( A -> )
MOV DWORD PTR [EAX ], 0
MOV EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code COUNT ;( c-addr1 -- c-addr2 u ) \ 94
; <EFBFBD>®«ãç¨âì áâபã ᨬ¢®«®¢ ¨§ áâப¨ á® áç¥â稪®¬ c-addr1.
; c-addr2 -  ¤à¥á ¯¥à¢®£® ᨬ¢®«  §  c-addr1.
; u - ᮤ¥à¦¨¬®¥ ¡ ©â  c-addr1, ïî饥áï ¤«¨­®© áâப¨ ᨬ¢®«®¢,
; ­ ç¨­ î饩áï á  ¤à¥á  c-addr2.
LEA EBP, [EBP-4]
LEA EDX, DWORD PTR [EAX +1 ]
MOV DWORD PTR [EBP], EDX
MOVZX EAX, BYTE PTR [EAX ]
RET
EndCode
Code * ;( n1|u1 n2|u2 -- n3|u3 ) \ 94
; <EFBFBD>¥à¥¬­®¦¨âì n1|u1 ¨ n2|u2 ¨ ¯®«ãç¨âì ¯à®¨§¢¥¤¥­¨¥ n3|u3.
IMUL DWORD PTR [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code AND ;( x1 x2 -- x3 ) \ 94
; x3 - ¯®¡¨â®¢®¥ "ˆ" x1 ¨ x2.
AND EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code OR ;( x1 x2 -- x3 ) \ 94
; x3 - ¯®¡¨â®¢®¥ "ˆˆ" x1 ¨ x2.
OR EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code XOR ;( x1 x2 -- x3 ) \ 94
; x3 - ¯®¡¨â®¢®¥ "¨áª«îç î饥 ˆˆ" x1 ¨ x2.
XOR EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code INVERT ;( x1 -- x2 ) \ 94
; ˆ­¢¥àâ¨à®¢ âì ¢á¥ ¡¨âë x1 ¨ ¯®«ãç¨âì «®£¨ç¥áªãî ¨­¢¥àá¨î x2.
NOT EAX
RET
EndCode
Code NEGATE ;( n1 -- n2 ) \ 94
; n2 -  à¨ä¬¥â¨ç¥áª ï ¨­¢¥àá¨ï n1.
NEG EAX
RET
EndCode
Code ABS ;( n -- u ) \ 94
; u -  ¡á®«îâ­ ï ¢¥«¨ç¨­  n.
TEST EAX, EAX
JS { ' NEGATE }
RET
EndCode
Code DNEGATE ;( d1 -- d2 ) \ 94 DOUBLE
; d2 १ã«ìâ â ¢ëç¨â ­¨ï d1 ¨§ ­ã«ï.
MOV EDX, [EBP]
NEG EAX
NEG EDX
SBB EAX, 0
MOV DWORD PTR [EBP], EDX
RET
EndCode
Code NOOP ;( -> )
RET
EndCode
Code S>D ;( n -- d ) \ 94
; <EFBFBD>८¡à §®¢ âì ç¨á«® n ¢ ¤¢®©­®¥ ç¨á«® d á ⥬ ¦¥ ç¨á«®¢ë¬ §­ ç¥­¨¥¬.
LEA EBP, [EBP-4]
MOV [EBP], EAX
CDQ
MOV EAX, EDX
RET
EndCode
Code D>S ;( d -- n ) \ 94 DOUBLE
; n - íª¢¨¢ «¥­â d.
; ˆáª«îç¨â¥«ì­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ d ­ å®¤¨âáï ¢­¥ ¤¨ ¯ §®­ 
; §­ ª®¢ëå ®¤¨­ à­ëå ç¨á¥«.
MOV EAX, [EBP]
ADD EBP, 4
RET
EndCode
Code U>D ;( U -> D ) \ à áè¨à¨âì ç¨á«® ¤® ¤¢®©­®© â®ç­®á⨠­ã«¥¬
LEA EBP, [EBP-4]
MOV [EBP], EAX
XOR EAX, EAX
RET
EndCode
Code C>S ;( c -- n ) \ à áè¨à¨âì CHAR
MOVSX EAX, AL
RET
EndCode
Code UM* ;( u1 u2 -- ud ) \ 94
; ud - ¯à®¨§¢¥¤¥­¨¥ u1 ¨ u2. ‚ᥠ§­ ç¥­¨ï ¨  à¨ä¬¥â¨ª  ¡¥§§­ ª®¢ë¥.
MUL DWORD PTR [EBP]
MOV [EBP], EAX
MOV EAX, EDX
RET
EndCode
Code / ;( n1 n2 -- n3 ) \ 94
; „¥«¨âì n1 ­  n2, ¯®«ãç¨âì ç áâ­®¥ n3.
; ˆáª«îç¨â¥«ì­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ n2 à ¢¥­ ­ã«î.
; …᫨ n1 ¨ n2 à §«¨ç îâáï ¯® §­ ªã - ¢®§¢à é ¥¬ë© १ã«ìâ â § ¢¨á¨â ®â
; ॠ«¨§ æ¨¨.
MOV ECX, EAX
MOV EAX, [EBP]
CDQ
IDIV ECX
LEA EBP, [EBP+4]
RET
EndCode
Code U/ ;( W1, W2 -> W3 ) \ ¡¥§§­ ª®¢®¥ ¤¥«¥­¨¥ W1 ­  W2
MOV ECX, EAX
MOV EAX, [EBP]
XOR EDX, EDX
LEA EBP, [EBP+4]
DIV ECX
RET
EndCode
Code +! ;( n|u a-addr -- ) \ 94 \ !!!!!
; <EFBFBD>ਡ ¢¨âì n|u ª ®¤¨­ à­®¬ã ç¨á«ã ¯®  ¤à¥áã a-addr.
MOV EDX, [EBP]
ADD DWORD PTR [EAX ], EDX
MOV EAX, [EBP+4]
LEA EBP, [EBP+8]
RET
EndCode
Code MOD ;( n1 n2 -- n3 ) \ 94
; „¥«¨âì n1 ­  n2, ¯®«ãç¨âì ®áâ â®ª n3.
; ˆáª«îç¨â¥«ì­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ n2 à ¢¥­ ­ã«î.
; …᫨ n1 ¨ n2 à §«¨ç îâáï ¯® §­ ªã - ¢®§¢à é ¥¬ë© १ã«ìâ â § ¢¨á¨â ®â
; ॠ«¨§ æ¨¨.
MOV ECX, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
CDQ
IDIV ECX
MOV EAX, EDX
RET
EndCode
Code /MOD ;( n1 n2 -- n3 n4 ) \ 94
; „¥«¨âì n1 ­  n2, ¤ âì ®áâ â®ª n3 ¨ ç áâ­®¥ n4.
; <EFBFBD>¥®¤­®§­ ç­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ n2 ­ã«ì.
MOV ECX, EAX
MOV EAX, [EBP]
CDQ
IDIV ECX
MOV [EBP], EDX
RET
EndCode
Code UMOD ;( W1, W2 -> W3 ) \ ®áâ â®ª ®â ¤¥«¥­¨ï W1 ­  W2
MOV ECX, EAX
XOR EDX, EDX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
DIV ECX
MOV EAX, EDX
RET
EndCode
Code UM/MOD ;( ud u1 -- u2 u3 ) \ 94
; „¥«¨âì ud ­  u1, ¯®«ãç¨âì ç áâ­®¥ u3 ¨ ®áâ â®ª u2.
; ‚ᥠ§­ ç¥­¨ï ¨  à¨ä¬¥â¨ª  ¡¥§§­ ª®¢ë¥.
; ˆáª«îç¨â¥«ì­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ u1 ­®«ì ¨«¨ ç áâ­®¥
; ­ å®¤¨âáï ¢­¥ ¤¨ ¯ §®­  ®¤¨­ à­ëå ¡¥§§­ ª®¢ëå ç¨á¥«.
MOV ECX, EAX
MOV EDX, [EBP]
MOV EAX, [EBP+4]
DIV ECX
LEA EBP, [EBP+4]
MOV [EBP], EDX
RET
EndCode
Code 2/ ;( x1 -- x2 ) \ 94
; x2 - १ã«ìâ â ᤢ¨£  x1 ­  ®¤¨­ ¡¨â ¢¯à ¢® ¡¥§ ¨§¬¥­¥­¨ï áâ à襣® ¡¨â .
SAR EAX,1
RET
EndCode
Code */MOD ;( n1 n2 n3 -- n4 n5 ) \ 94
; “¬­®¦¨âì n1 ­  n2, ¯®«ãç¨âì ¯à®¬¥¦ãâ®ç­ë© ¤¢®©­®© १ã«ìâ â d.
; <EFBFBD> §¤¥«¨âì d ­  n3, ¯®«ãç¨âì ®áâ â®ª n4 ¨ ç áâ­®¥ n5.
MOV EBX, EAX
MOV EAX, [EBP]
MOV ECX, [EBP+4]
IMUL ECX
IDIV EBX
MOV [EBP+4], EDX
LEA EBP, [EBP+4]
RET
EndCode
Code M* ;( n1 n2 -- d ) \ 94
; d - §­ ª®¢ë© १ã«ìâ â 㬭®¦¥­¨ï n1 ­  n2.
IMUL DWORD PTR [EBP]
MOV [EBP], EAX
MOV EAX, EDX
RET
EndCode
Code LSHIFT ;( x1 u -- x2 ) ; 94
; ‘¤¢¨­ãâì x1 ­  u ¡¨â ¢«¥¢®. <EFBFBD>®¬¥áâ¨âì ­ã«¨ ¢ ­ ¨¬¥­¥¥ §­ ç¨¬ë¥ ¡¨âë,
; ®á¢®¡®¦¤ ¥¬ë¥ ¯à¨ ᤢ¨£¥.
; <EFBFBD>¥®¤­®§­ ç­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ u ¡®«ìè¥ ¨«¨ à ¢­®
; ç¨á«ã ¡¨â ¢ ï祩ª¥.
MOV ECX, EAX
MOV EAX, [EBP]
SHL EAX, CL
LEA EBP, [EBP+4]
RET
EndCode
Code RSHIFT ;( x1 u -- x2 ) \ 94
; ‘¤¢¨­ãâì x1 ­  u ¡¨â ¢¯à ¢®. <EFBFBD>®¬¥áâ¨âì ­ã«¨ ¢ ­ ¨¡®«¥¥ §­ ç¨¬ë¥ ¡¨âë,
; ®á¢®¡®¦¤ ¥¬ë¥ ¯à¨ ᤢ¨£¥.
; <EFBFBD>¥®¤­®§­ ç­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ u ¡®«ìè¥ ¨«¨ à ¢­®
; ç¨á«ã ¡¨â ¢ ï祩ª¥.
MOV ECX, EAX
MOV EAX, [EBP]
SHR EAX, CL
LEA EBP, [EBP+4]
RET
EndCode
Code SM/REM ;( d1 n1 -- n2 n3 ) \ 94
; <EFBFBD> §¤¥«¨âì d1 ­  n1, ¯®«ãç¨âì ᨬ¬¥âà¨ç­®¥ ç áâ­®¥ n3 ¨ ®áâ â®ª n2.
; ‚室­ë¥ ¨ ¢ë室­ë¥  à£ã¬¥­âë §­ ª®¢ë¥.
; <EFBFBD>¥®¤­®§­ ç­ ï á¨âã æ¨ï ¢®§­¨ª ¥â, ¥á«¨ n1 ­®«ì, ¨«¨ ç áâ­®¥ ¢­¥
; ¤¨ ¯ §®­  ®¤¨­ à­ëå §­ ª®¢ëå ç¨á¥«.
MOV EBX, EAX
MOV EDX, [EBP]
MOV EAX, [EBP+4]
IDIV EBX
LEA EBP, [EBP+4]
MOV [EBP], EDX
RET
EndCode
Code FM/MOD ;( d1 n1 -- n2 n3 ) \ 94
; Ðàçäåëèòü d1 íà n1, ïîëó÷èòü ÷àñòíîå n3 è îñòàòîê n2.
; Âõîäíûå è âûõîäíûå àðãóìåíòû çíàêîâûå.
; Íåîäíîçíà÷íàÿ ñèòóàöèÿ âîçíèêàåò, åñëè n1 íîëü, èëè ÷àñòíîå âíå
; äèàïàçîíà îäèíàðíûõ çíàêîâûõ ÷èñåë.
MOV ECX, EAX
MOV EDX, [EBP]
MOV EBX, EDX
MOV EAX, [EBP+4]
IDIV ECX
TEST EDX, EDX ; Îñòàòîê-òî åñòü?
JZ SHORT @@1
XOR EBX, ECX ; À àðãóìåíòû ðàçíîãî çíàêà?
JNS SHORT @@1
DEC EAX
ADD EDX, ECX
@@1: LEA EBP, [EBP+4]
MOV [EBP], EDX
RET
EndCode
\ ================================================================
\ ‘à ¢­¥­¨ï
Code = ;( x1 x2 -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  x1 ¯®¡¨â­® à ¢¥­ x2.
XOR EAX, [EBP]
SUB EAX, 1
SBB EAX, EAX
LEA EBP, [EBP+4]
RET
EndCode
Code <> ;( x1 x2 -- flag ) \ 94 CORE EXT
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  x1 ­¥ à ¢¥­ x2.
XOR EAX, [EBP]
NEG EAX
SBB EAX, EAX
LEA EBP, [EBP+4]
RET
EndCode
Code < ;( n1 n2 -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  n1 ¬¥­ìè¥ n2.
CMP [EBP], EAX
SETGE AL
AND EAX, 01
DEC EAX
LEA EBP, [EBP+4]
RET
EndCode
Code > ;( n1 n2 -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  n1 ¡®«ìè¥ n2.
CMP EAX, [EBP]
SETGE AL
AND EAX, 01
DEC EAX
LEA EBP, [EBP+4]
RET
EndCode
Code WITHIN ;( n1 low high -- f1 ) \ f1=true if ((n1 >= low) & (n1 < high))
MOV EBX, [EBP+4]
SUB EAX, [EBP]
SUB EBX, [EBP]
SUB EBX, EAX
SBB EAX, EAX
ADD EBP, 8
RET
EndCode
Code D< ;( d1 d2 -- flag ) \ DOUBLE
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  d1 ¬¥­ìè¥ d2.
MOV EBX, [EBP]
CMP DWORD PTR [EBP +8 ], EBX
SBB DWORD PTR [EBP +4 ], EAX
MOV EAX, 0
SIF <
DEC EAX
STHEN
ADD EBP, 0CH
RET
EndCode
Code D> ;( d1 d2 -- flag ) \ DOUBLE
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  d1 ¡®«ìè¥ d2.
MOV EBX, [EBP]
CMP EBX, [EBP+8]
SBB EAX, [EBP+4]
SAR EAX, 1FH
ADD EBP, 0CH
RET
EndCode
Code U< ;( u1 u2 -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  u1 ¬¥­ìè¥ u2.
CMP [EBP], EAX
SBB EAX, EAX
ADD EBP, 04
RET
EndCode
Code U> ;( u1 u2 -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  u1 ¡®«ìè¥ u2.
CMP EAX, [EBP]
SBB EAX, EAX
ADD EBP, 04
RET
EndCode
Code 0< ;( n -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  n ¬¥­ìè¥ ­ã«ï.
SAR EAX, 1F
RET
EndCode
Code 0= ;( x -- flag ) \ 94
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  x à ¢­® ­ã«î.
SUB EAX, 1
SBB EAX, EAX
RET
EndCode
Code 0<> ;( x -- flag ) \ 94 CORE EXT
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  x ­¥ à ¢­® ­ã«î.
NEG EAX
SBB EAX, EAX
RET
EndCode
Code D0= ;( xd -- flag ) \ 94 DOUBLE
; flag "¨á⨭ " ⮣¤  ¨ ⮫쪮 ⮣¤ , ª®£¤  xd à ¢¥­ ­ã«î.
OR EAX, [EBP]
SUB EAX, 1
SBB EAX, EAX
LEA EBP, [EBP+4]
RET
EndCode
Code D= ;( xd1 xd2 -- flag ) \ 94 DOUBLE
; flag is true if and only if xd1 is bit-for-bit the same as xd2
MOV EDX,[EBP]
XOR EAX,[EBP+4]
XOR EDX,[EBP+8]
OR EAX,EDX
SUB EAX,1
SBB EAX,EAX
LEA EBP,[EBP+0CH]
RET
EndCode
Code D2* ;( xd1 -- xd2 ) \ 94 DOUBLE
; xd2 is the result of shifting xd1 one bit toward the most-significant
; bit, filling the vacated least-significant bit with zero
SHL DWORD PTR [EBP], 1
RCL EAX, 1
RET
EndCode
Code D2/ ;( xd1 -- xd2 ) \ 94 DOUBLE
; xd2 is the result of shifting xd1 one bit toward the least-significant bit,
; leaving the most-significant bit unchanged
SAR EAX, 1
RCR DWORD PTR [EBP], 1
RET
EndCode
\ ================================================================
\ ‘âப¨
Code -TRAILING ;( c-addr u1 -- c-addr u2 ) \ 94 STRING
; …᫨ u1 ¡®«ìè¥ ­ã«ï, u2 à ¢­® u1, 㬥­ì襭­®¬ã ­  ª®«¨ç¥á⢮ ¯à®¡¥«®¢ ¢ ª®­æ¥
; ᨬ¢®«ì­®© áâப¨, § ¤ ­­®© c-addr ¨ u1. …᫨ u1 ­®«ì ¨«¨ ¢áï áâப  á®á⮨â
; ¨§ ¯à®¡¥«®¢, u2 ­®«ì.
PUSH EDI
MOV ECX, EAX
SIF C0<>
MOV EDI, DWORD PTR [EBP]
ADD EDI, ECX
DEC EDI
MOV AL, 20H
STD
REPZ SCASB
SIF 0<>
INC ECX
STHEN
CLD
MOV EAX, ECX
STHEN
POP EDI
RET
EndCode
Code COMPARE ;( c-addr1 u1 c-addr2 u2 -- n ) \ 94 STRING !!!!!
; ‘à ¢­¨âì áâபã, § ¤ ­­ãî c-addr1 u1, á® áâப®©, § ¤ ­­®© c-addr2 u2.
; ‘âப¨ áà ¢­¨¢ îâáï, ­ ç¨­ ï á § ¤ ­­ëå  ¤à¥á®¢, ᨬ¢®« §  ᨬ¢®«®¬, ¤® ¤«¨­ë
; ­ ¨¡®«¥¥ ª®à®âª®© ¨§ áâப ¨«¨ ¤® ­ å®¦¤¥­¨ï à §«¨ç¨©. …᫨ ¤¢¥ áâப¨
; ¨¤¥­â¨ç­ë, n ­®«ì. …᫨ ¤¢¥ áâப¨ ¨¤¥­â¨ç­ë ¤® ¤«¨­ë ­ ¨¡®«¥¥ ª®à®âª®© ¨§
; áâப, â® n ¬¨­ãá ¥¤¨­¨æ  (-1), ¥á«¨ u1 ¬¥­ìè¥ u2, ¨­ ç¥ ¥¤¨­¨æ  (1).
; …᫨ ¤¢¥ áâப¨ ­¥ ¨¤¥­â¨ç­ë ¤® ¤«¨­ë ­ ¨¡®«¥¥ ª®à®âª®© ¨§ áâப, â® n ¬¨­ãá
; ¥¤¨­¨æ  (-1), ¥á«¨ ¯¥à¢ë© ­¥á®¢¯ ¤ î騩 ᨬ¢®« áâப¨, § ¤ ­­®© c-addr1 u1
; ¨¬¥¥â ¬¥­ì襥 ç¨á«®¢®¥ §­ ç¥­¨¥, 祬 ᮮ⢥âáâ¢ãî騩 ᨬ¢®« ¢ áâப¥,
; § ¤ ­­®© c-addr2 u2, ¨ ¥¤¨­¨æ  ¢ ¯à®â¨¢­®¬ á«ãç ¥.
PUSH EDI
MOV ECX, EAX
SUB EAX, EAX
CMP ECX, [EBP +4 ]
SIF 0<>
SIF U<
INC EAX
SELSE
DEC EAX
MOV ECX, [EBP +4 ]
STHEN
STHEN
MOV ESI, [EBP + { 2 CELLS } ]
MOV EDI, [EBP]
REPE CMPSB
SIF 0<>
SIF U>=
MOV EAX, 1
SELSE
MOV EAX, -1
STHEN
STHEN
LEA EBP, [EBP + { 3 CELLS } ]
POP EDI
RET
EndCode
Code SEARCH ;( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 flag ) \ 94 STRING
; <EFBFBD>ந§¢¥á⨠¯®¨áª ¢ áâப¥, § ¤ ­­®© c-addr1 u1, áâப¨, § ¤ ­­®© c-addr2 u2.
; …᫨ ä« £ "¨á⨭ ", ᮢ¯ ¤¥­¨¥ ­ ©¤¥­® ¯®  ¤à¥áã c-addr3 á ®á⠢訬¨áï u3
; ᨬ¢®« ¬¨. …᫨ ä« £ "«®¦ì", ᮢ¯ ¤¥­¨ï ­¥ ­ ©¤¥­®, ¨ c-addr3 ¥áâì c-addr1,
; ¨ u3 ¥áâì u1. \ !!!!!
LEA EBP, [EBP-4]
MOV [EBP], EAX
PUSH EDI
CLD
MOV EBX, DWORD PTR [EBP]
OR EBX, EBX
SIF 0<>
MOV EDX, DWORD PTR [EBP + { 2 CELLS } ]
MOV EDI, DWORD PTR [EBP + { 3 CELLS } ]
ADD EDX, EDI
SBEGIN
MOV ESI, DWORD PTR [EBP +4 ]
LODSB
MOV ECX, EDX
SUB ECX, EDI
JECXZ LLD
REPNZ
SCASB
JNE SHORT LLD ; ¢® ¢á¥© áâப¥ ­¥â ¯¥à¢®£® ᨬ¢®«  ¨áª®¬®© áâப¨
CMP EBX, 1
JZ SHORT LLC ; ¨áª®¬ ï áâப  ¨¬¥«  ¤«¨­ã 1 ¨ ­ ©¤¥­ 
MOV ECX, EBX
DEC ECX
MOV EAX, EDX
SUB EAX, EDI
CMP EAX, ECX
JC SHORT LLD ; ®áâ â®ª áâப¨ ª®à®ç¥ ¨áª®¬®© áâப¨
PUSH EDI
REPZ CMPSB
POP EDI
SUNTIL 0=
LLC: DEC EDI ; ­ è«¨ ¯®«­®¥ ᮢ¯ ¤¥­¨¥
SUB EDX, EDI
MOV DWORD PTR [EBP + { 3 CELLS } ], EDI
MOV DWORD PTR [EBP + { 2 CELLS } ], EDX
STHEN
MOV EAX, -1
JMP SHORT LLA
LLD: XOR EAX, EAX
LLA: LEA EBP, [EBP+4]
MOV [EBP], EAX
POP EDI
MOV EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code CMOVE ;( c-addr1 c-addr2 u -- ) \ 94 STRING
; …᫨ u ¡®«ìè¥ ­ã«ï, ª®¯¨à®¢ âì u ¯®á«¥¤®¢ â¥«ì­ëå ᨬ¢®«®¢ ¨§ ¯à®áâà ­á⢠
; ¤ ­­ëå ­ ç¨­ ï á  ¤à¥á  c-addr1 ¢ c-addr2, ᨬ¢®« §  ᨬ¢®«®¬, ­ ç¨­ ï á
; ¬« ¤è¨å  ¤à¥á®¢ ª áâ à訬.
MOV EDX, EDI
MOV ECX, EAX
MOV EDI, DWORD PTR [EBP]
MOV ESI, DWORD PTR [EBP +4 ]
CLD
REPZ MOVSB
LEA EBP, [EBP+0CH]
MOV EAX, [EBP-4]
MOV EDI, EDX
RET
EndCode
: QCMOVE CMOVE ;
Code CMOVE> ;( c-addr1 c-addr2 u -- ) \ 94 STRING
; …᫨ u ¡®«ìè¥ ­ã«ï, ª®¯¨à®¢ âì u ¯®á«¥¤®¢ â¥«ì­ëå ᨬ¢®«®¢ ¨§ ¯à®áâà ­á⢠
; ¤ ­­ëå ­ ç¨­ ï á  ¤à¥á  c-addr1 ¢ c-addr2, ᨬ¢®« §  ᨬ¢®«®¬, ­ ç¨­ ï á®
; áâ àè¨å  ¤à¥á®¢ ª ¬« ¤è¨¬.
MOV EDX, EDI
MOV ECX, EAX
MOV EDI, [EBP]
MOV ESI, [EBP+4]
STD
ADD EDI, ECX
DEC EDI
ADD ESI, ECX
DEC ESI
REP MOVSB
MOV EDI, EDX
LEA EBP, [EBP+0CH]
MOV EAX, [EBP-4]
RET
EndCode
Code FILL ;( c-addr u char -- ) \ 94 \ !!!!!
; …᫨ u ¡®«ìè¥ ­ã«ï, § á« âì char ¢ u ¡ ©â®¢ ¯®  ¤à¥áã c-addr.
MOV EDX, EDI
MOV ECX, [EBP]
MOV EDI, [EBP+4]
CLD
REP STOSB
MOV EDI, EDX
LEA EBP, [EBP+0CH]
MOV EAX, [EBP-4]
RET
EndCode
Code ZCOUNT ;( c-addr -- c-addr u )
LEA EBP, [EBP-4]
MOV [EBP], EAX
XOR EBX, EBX
SBEGIN
MOV BL, BYTE PTR [EAX ]
INC EAX
OR BL, BL
SUNTIL 0=
DEC EAX
SUB EAX, [EBP]
RET
EndCode
\ ================================================================
\ “ª § â¥«¨ á⥪®¢
Code SP! ;( A -> )
LEA EBP, [EAX+4]
MOV EAX, [EBP-4]
RET
EndCode
Code RP! ;( A -> )
POP EBX
MOV ESP, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP EBX
EndCode
Code SP@ ;( -> A )
LEA EBP, [EBP-4]
MOV [EBP], EAX
MOV EAX, EBP
RET
EndCode
Code RP@ ;( -- RP )
LEA EBP, [EBP-4]
MOV [EBP], EAX
LEA EAX, [ESP + 4 ]
RET
EndCode
\ ================================================================
\ <20>¥£¨áâà ¯®â®ª  (§ ¤ ç¨ ¢­ãâਠä®àâ )
Code TlsIndex! ;( x -- ) \ 㪠§ â¥«ì «®ª «ì­®£® ¯ã«  ¯®â®ª 
MOV EDI, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code TlsIndex@ ;( -- x )
LEA EBP, [EBP-4]
MOV [EBP], EAX
MOV EAX, EDI
RET
EndCode
\ ================================================================
\ –¨ª«ë
Code C-J
LEA EBP, [EBP-4]
MOV [EBP], EAX
MOV EAX, DWORD PTR [ESP + { 3 CELLS } ]
SUB EAX, DWORD PTR [ESP + { 4 CELLS } ]
RET
EndCode
( inline'ë ¤«ï ª®¬¯¨«ï樨 横«®¢ )
Code C-DO
LEA EBP, [EBP+8]
MOV EDX, 80000000H
SUB EDX, [EBP-8]
LEA EBX, [EAX+EDX]
MOV EAX, [EBP-4]
MOV EDX, EDX ; FOR OPT
; PUSH EDX
; PUSH EBX
RET
EndCode
Code C-?DO
CMP EAX, [EBP-8]
SIF 0=
MOV EAX, [EBP-4]
JMP EBX
STHEN
PUSH EBX
MOV EBX , 80000000
SUB EBX, [EBP-8]
PUSH EBX ; 80000000h-to
ADD EBX, EAX
PUSH EBX ; 80000000H-to+from
MOV EAX, [EBP-4]
RET
EndCode
Code ADD[ESP],EAX
ADD [ESP] , EAX
RET
EndCode
Code C-I
LEA EBP, [EBP-4]
MOV [EBP], EAX
MOV EAX, DWORD PTR [ESP]
SUB EAX, [ESP+4]
RET
EndCode
Code C->R
PUSH EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
RET
EndCode
Code C-R>
LEA EBP, [EBP-4]
MOV [EBP], EAX
POP EAX
RET
EndCode
Code C-RDROP
ADD ESP, 4
RET
EndCode
Code C-2RDROP
ADD ESP, 8
RET
EndCode
Code C-3RDROP
ADD ESP, 0CH
RET
EndCode
TRUE [IF]
Code C-EXECUTE ;( i*x xt -- j*x ) \ 94
; “¡à âì xt á® á⥪  ¨ ¢ë¯®«­¨âì § ¤ ­­ãî ¨¬ ᥬ ­â¨ªã.
; „à㣨¥ ¨§¬¥­¥­¨ï ­  á⥪¥ ®¯à¥¤¥«ïîâáï á«®¢®¬, ª®â®à®¥ ¢ë¯®«­ï¥âáï.
MOV EDX, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
CALL EDX
RET
EndCode
[THEN]
Code EXECUTE ;( i*x xt -- j*x ) \ 94
; “¡à âì xt á® á⥪  ¨ ¢ë¯®«­¨âì § ¤ ­­ãî ¨¬ ᥬ ­â¨ªã.
; „à㣨¥ ¨§¬¥­¥­¨ï ­  á⥪¥ ®¯à¥¤¥«ïîâáï á«®¢®¬, ª®â®à®¥ ¢ë¯®«­ï¥âáï.
MOV EBX, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP EBX
EndCode
Code @EXECUTE ;( i*x xt -- j*x )
MOV EBX, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP [EBX]
EndCode
\ ================================================================
\ <20>®¤¤¥à¦ª  LOCALS
Code DRMOVE ;( x1 ... xn n*4 -- )
; ¯¥à¥­¥á⨠n ç¨á¥« á® á⥪  ¤ ­­ëå ­  á⥪ ¢®§¢à â®¢
POP EDX ;  ¤à¥á ¢®§¢à â 
MOV ESI, EAX
LL1:
PUSH DWORD PTR [EBP+ESI-4]
SUB ESI, 4
JNZ SHORT LL1
ADD EBP, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP EDX
EndCode
Code NR> ;( R: x1 ... xn n -- D: x1 ... xn n )
; <EFBFBD>¥à¥­¥á⨠n ç¨á¥« á® á⥪  ¢®§¢à â®¢ ­  á⥪ ¤ ­­ëå
; …᫨ n=0 ¢®§¢à â¨âì 0
POP EDX ;  ¤à¥á ¢®§¢à â 
LEA EBP, [EBP-4]
MOV [EBP], EAX
POP EAX
OR EAX, EAX
JNZ @@2
JMP EDX
@@2: LEA EAX, [EAX*4]
MOV ESI, EAX
@@1:
MOV EBX, EBP
SUB EBX, ESI
POP DWORD PTR [EBX]
SUB ESI, 4
JNZ SHORT @@1
SUB EBP, EAX
SAR EAX, 2
JMP EDX
EndCode
Code N>R ;( D: x1 ... xn n -- R: x1 ... xn n )
; ¯¥à¥­¥á⨠n ç¨á¥« á® á⥪  ¤ ­­ëå ­  á⥪ ¢®§¢à â®¢
LEA EBP, [EBP-4]
MOV [EBP], EAX
LEA EAX, [EAX*4+4]
POP EDX ;  ¤à¥á ¢®§¢à â 
MOV ESI, EAX
@@1:
PUSH DWORD PTR [EBP+ESI-4]
SUB ESI, 4
JNZ SHORT @@1
ADD EBP, EAX
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP EDX
EndCode
Code NRCOPY ;( D: i*x i -- D: i*x i R: i*x i )
; ᪮¯¨à®¢ âì n ç¨á¥« á® á⥪  ¤ ­­ëå ­  á⥪ ¢®§¢à â®¢
MOV ECX, EAX
LEA ECX, [ECX*4]
POP EDX ;  ¤à¥á ¢®§¢à â 
JECXZ @@2
MOV ESI, ECX
@@1:
PUSH DWORD PTR [ESI+EBP-4]
SUB ESI, 4
JNZ SHORT @@1
@@2:
PUSH EAX
JMP EDX
EndCode
Code RP+@ ;( offs -- x )
; ¢§ïâì ç¨á«® ᮠᬥ饭¨¥¬ offs ¡ ©â ®â ¢¥à設ë á⥪  ¢®§¢à â®¢ (0 RP+@ == RP@)
MOV EAX, [EAX+ESP+4]
RET
EndCode
Code RP+ ;( offs -- addr )
; ¢§ïâì  ¤à¥á ᮠᬥ饭¨¥¬ offs ¡ ©â ®â ¢¥à設ë á⥪  ¢®§¢à â®¢
LEA EAX, [EAX+ESP+4]
RET
EndCode
Code RP+! ;( x offs -- )
; § ¯¨á âì ç¨á«® x ¯® ᬥ饭¨î offs ¡ ©â ®â ¢¥à設ë á⥪  ¢®§¢à â®¢
MOV EBX, [EBP]
MOV [EAX+ESP+4], EBX
LEA EBP, [EBP+8]
MOV EAX, [EBP-4]
RET
EndCode
Code RALLOT ;( n -- addr )
; § à¥§¥à¢¨à®¢ âì n ï祥ª ­  á⥪¥ ¢®§¢à â®¢,
; ᤥ« ¥¬ á ¨­¨æ¨ «¨§ æ¨¥© (  â® ¥á«¨ ¡®«ìè¥ 8Š ¢ë¤¥«¨¬, exception ¬®¦¥â)
POP EDX
MOV ECX, EAX
XOR EAX, EAX
@@1: PUSH EAX
DEC ECX
JNZ SHORT @@1
MOV EAX, ESP
JMP EDX
EndCode
Code (RALLOT) ;( n -- )
; § à¥§¥à¢¨à®¢ âì n ï祥ª ­  á⥪¥ ¢®§¢à â®¢
POP EDX
MOV ECX, EAX
XOR EAX, EAX
@@1: PUSH EAX
DEC ECX
JNZ SHORT @@1
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP EDX
EndCode
Code RFREE ;( n -- )
; ¢¥à­ãâì n ï祥ª á⥪  ¢®§¢à â®¢
POP EDX
LEA ESP, [ESP+EAX*4]
MOV EAX, [EBP]
LEA EBP, [EBP+4]
JMP EDX
EndCode
Code (LocalsExit) ;( -- )
; ¢¥à­ãâì ¯ ¬ïâì ¢ á⥪ ¢®¢à â®¢, ç¨á«® ¡ ©â «¥¦¨â ­  á⥪¥
POP EBX
ADD ESP, EBX
RET
EndCode
Code TIMER@ ;( -- tlo thi ) \ ’®«ìª® ¤«ï Intel Pentium ¨ ¢ëè¥!!!
; ‚®§¢à â¨âì §­ ç¥­¨¥ â ©¬¥à  ¯à®æ¥áá®à  ª ª ud
MOV [EBP-4], EAX
RDTSC
MOV [EBP-8], EDX
LEA EBP, [EBP-8]
XCHG EAX, [EBP]
RET
EndCode
\ „«ï ®áâ «ì­ëå ¯à®æ¥áá®à®¢ à áª®¬¬¥­â¨àã©â¥:
\ : TIMER@ 0 GetTickCount ;
Code TRAP-CODE ;( D: j*x u R: i*x i -- i*x u )
; ‚ᯮ¬®£ â¥«ì­®¥ á«®¢® ¤«ï ¢®ááâ ­®¢«¥­¨ï §­ ç¥­¨©, á®åà ­¥­­ëå
; ¯¥à¥¤ CATCH ­  á⥪¥ ¢®§¢à â®¢
POP EDX
POP ESI
OR ESI, ESI
JZ @@2
LEA ESI, [ESI*4]
MOV ECX, ESI
@@1: MOV EBX, [ESI+ESP-4]
MOV [ESI+EBP-4], EBX
SUB ESI, 4
JNZ SHORT @@1
ADD ESP, ECX
@@2: JMP EDX
EndCode
DECIMAL