//#include "./cygwin.h"

#define ticDROP ticDROP_V
#define ticDUP ticDUP_V

#define LastCFA  INIT
//#define LastCFA  LWRD

//#define LastNFA  INIT-(4)
#define LastNFA  LASTWORD-(9)
#define reserve Mreserve-main_task
// ���� ᫮��

#define def(name,len,flags,next) \
 .int  .+4+4+1+len+4; \
 .int flags;	\
 .int  next-1; \
 .byte len;	\
 .ascii name

#define mdef(name,len,flags,next,xt) \
 .int  .+4+4+1+len+4; \
 .int flags;	\
 .int  next-1;	\
 .byte len;	\
 .ascii name;	\
 .globl xt; xt:
DEFLAST=0

#define fordef(name,len,flags,xt) \
 .int  xt; \
 .int flags; \
 .int  DEFLAST;	\
 DEFLAST=.; \
 .byte len;	\
 .ascii name;

#define fdef(name,len,flags,xt) \
 .int  xt; \
 .int flags;	\
 .int  DEFLAST;	\
DEFLAST=.; \
 .byte len;	\
 .ascii name;	\
 .globl xt; xt:

#define jdef(name,len,flags,xt,xt1) \
 .int  xt; \
 .int flags;	\
 .int  DEFLAST;	\
DEFLAST=.; \
 .byte len;	\
 .ascii name;	\
 .globl xt; xt: \
  mov %eax,%r12d; \
  call xt1; \
  mov %r12d,%eax; \
  ret

// ������� �⥪�� � ���஢ FORTH ��⥬�
#define TIB_SIZE 1027
#define PAD_SIZE 1027
#define HERE_SIZE 102400
#define VOCABULARY_POOL 10240000
#define STACK_SIZE 20480

fftst:
   push %rbp
  callq f_tst1
   pop %rbp
   ret

.globl tst0
	shl    $0x20,%rax
tst0:
.globl amain
amain:
        push %rbp
        push %rbx

#ifdef GUI
	mov	$WXTYPE,%eax
	mov	%eax,TYPE+5
	mov	$WXACCEPT,%eax
	mov	%eax,ACCEPT+5
	mov	$WXKEY,%eax
	mov	%eax,KEY+5
//	mov	$WXKEYQ,%eax
//	mov	%eax,KEYque+5
	mov	$WXEMIT,%eax
	mov	%eax,EMIT+5
#endif

        movl $_Stekc+STACK_SIZE-0x1C,%ebp
        movl %esp,T_R0
		movl $main_task,%r14d

   		mov		%rsp,%rax
		and $0xffffffff80000000,%rax
		mov		%rax,HSPSAVE

        call	LastCFA
		pop %rbx
        pop %rbp
		ret
xxx:
     pop %rbx
        pop %rbp
		ret

.data

mdef("TT",2,0,NNN-0x3,TT)
  ret

#ifdef GUI
fdef("?GUI",4,0,QGUI)
call _CONSTANTsubCODE+0x0
	.int -1

fdef("ZTYPE",5,0,ZTYPE)
		mov		%eax,%edi
		call	_Z8WX_ZTYPEPc
		mov		 (%rbp),%eax
		lea		4(%rbp),%ebp
		ret

#else

fdef("?GUI",4,0,QGUI)
call _CONSTANTsubCODE+0x0
	.int 0

fdef("ZTYPE",5,0,ZTYPE)
		jmp	ZTYPE1

#endif

#ifdef GUI

fdef("WXACCEPT",8,0,WXACCEPT)
		mov		(%rbp),%edi
		mov		%eax,%esi
		call	_Z9WX_ACCEPTPvm
		lea		4(%rbp),%rbp
		ret

fdef("WXEMIT",6,0,WXEMIT)
		mov		%eax,%edi
		call	_Z7WX_EMITc
		mov		 (%rbp),%eax
		lea		4(%rbp),%ebp
		ret

fdef("WXKEY",5,0,WXKEY)
		lea    -4(%ebp), %ebp
		mov		%eax,(%ebp)
		jmp		_Z5C_KEYv

jdef("WXSPACE",7,0,WXSPACE,_Z8WX_SPACEv)

#endif

fdef("NBESTH",6,0,NBESTH)
call _CONSTANTsubCODE+0x0
  .int nBestHeight
 call _TOVALUEsubCODE+0x0

fdef("PCTAB",5,0,PCTAB)
call _CONSTANTsubCODE+0x0
 .int pCallTable
 call _TOVALUEsubCODE+0x0


fdef("WALLETMAIN",10,0,WALLETMAIN)
call _CONSTANTsubCODE+0x0
.int pwalletMain
call _TOVALUEsubCODE+0x0

fdef("WALLETBALANS",10,0,WALLETBALANS)
	lea    -4(%rbp), %rbp
	mov		%eax,(%rbp)
	call _ZNK7CWallet10GetBalanceEv
	ret

fdef("HELLO",5,0,HELLO)
        movl    $5+3, %edx
        movl    $.LC5, %esi
        movl    $1, %edi
        call    write
		ret
.LC5:  .string "Hello!!!"

fdef("DUP",3 ,0x0 ,DUP)
		lea    -4(%rbp),%rbp
		mov		%eax,(%rbp)
		ret

fdef("OVER",4,0x0 ,OVER)
		lea		-4(%rbp),%ebp
		mov		%eax,0(%rbp)
		mov		4(%rbp),%eax
		retq

fdef("SWAP",4,0x0 ,SWAP)
		mov		(%rbp),%edx
		mov		%eax,(%rbp)
		mov		%edx,%eax
		retq

fdef("ROT",3,0x0 ,ROT)
		mov		(%rbp),%edx
		mov		%eax,(%rbp)
		mov		4(%rbp),%eax
		mov		%edx,4(%rbp)
		retq

fdef("-ROT",4,0x0 ,subROT)
		mov		4(%rbp),%edx
		mov		%eax,4(%rbp)
		mov		(%rbp),%eax
		mov		%edx,(%rbp)
		retq


fdef("DROP",4,0x0 ,DROP)
DgreatS:
		mov		(%rbp),%eax
NIP:	lea		4(%rbp), %rbp
		ret

fordef("D>S",3,0x0 ,DROP)
fordef("NIP",3,0x0 ,NIP)

fdef("2DUP",4,0x0 ,_2DUP)
		mov		(%rbp),%edx
		mov		%eax,-4(%rbp)
		mov		%edx,-8(%rbp)
		lea    -8(%rbp), %rbp
		ret

fdef("2DROP",5,0x0 ,_2DROP)
		mov		4(%rbp),%eax
		lea		8(%rbp),%ebp
		retq

fdef("2SWAP",5,0x0 ,_2SWAP)
		mov 0x0(%rbp),%ecx
		mov 0x4(%rbp),%rdx
		mov 0x8(%rbp),%ebx
		mov %ecx,0x8(%rbp)
		mov %eax,0x4(%rbp)
		mov %ebx,0x0(%rbp)
		mov %edx,%eax
		retq

fdef("PICK",4,0x0 ,PICK)
		mov (%ebp,%eax,4),%eax
		retq

fdef("TUCK",4,0x0 ,TUCK)
		lea -0x4(%rbp),%ebp
		mov 0x4(%rbp),%edx
		mov %eax,0x4(%rbp)
		mov %edx,0x0(%rbp)
		retq

fdef("@",1,0,load)
/* a-addr -- x */
		mov    (%eax),%eax
		ret

fdef("C@",2,0,Cload)
/* a-addr -- x */
		movzbl 	(%eax),%eax
		ret

fdef("W@",2,0,Wload)
		movzwl	(%rax),%eax
		retq

fdef("2@",2,0,_2load)
		mov		4(%ebp),%edx
		lea		-4(%ebp),%ebp
		mov		%edx,(%ebp)
		mov		(%eax),%eax
		ret

fdef("!",1,0,save)
/* x a-addr --  */
		mov    (%rbp),%edx
		movl	%edx,(%rax)
		mov    4(%rbp),%eax
		lea    8(%rbp),%rbp
		ret

fdef("+!",2,0,addsave)
/* x a-addr --  */
		mov    (%rbp),%edx
		addl	%edx,(%rax)
		mov    4(%rbp),%eax
		lea    8(%rbp),%rbp
		ret

fdef("C!",2,0,Csave)
/* c a-addr --  */
		movb    (%rbp),%dl
		movb 	%dl,(%rax)
		mov    4(%rbp),%eax
		lea    8(%rbp),%rbp
		ret

fdef("w!",2,0,Wsave)
/* w a-addr --  */
		mov		(%rbp),%edx
		mov		%dx,(%rax)
		mov		4(%rbp),%eax
		lea		8(%rbp),%ebp
		retq

fdef("0!",2,0,_0save)
/*  a-addr --  */
//		mov		$0,(%rax)
		movl	$0,(%rax)
		mov     (%rbp),%eax
		lea    4(%rbp),%rbp
		ret

fdef("1+!",3,0,_1addsave)
/*  a-addr --  */
		incl	(%rax)
		mov     (%rbp),%eax
		lea    4(%rbp),%rbp
		ret

fdef("=",1,0,equ)
		xor		(%rbp),%eax
		lea    4(%rbp), %rbp
		sub		$1,%eax
		sbb		%eax,%eax
		ret

fdef("D0=",3,0,D0equ)
		or		(%rbp),%eax
		lea		4(%rbp),%ebp
_0equ:	sub		$1,%eax
		sbb		%eax,%eax
		retq
fordef("0=",2,0,_0equ)

fdef("UMIN",4,0,UMIN)
		cmp		(%rbp),%eax
		ja		DROP
		lea		4(%rbp),%ebp
		retq
fdef("UMAX",4,0,UMAX)
		cmp		(%rbp),%eax
		jb		DROP
		lea		(%rbp),%ebp
		retq
fdef("MIN",3,0,MIN)
		cmp		(%rbp),%eax
		jg		DROP
		lea		4(%rbp),%ebp
		retq
fdef("MAX",3,0,MAX)
		cmp		(%rbp),%eax
		jl		DROP
		lea		4(%rbp),%ebp
		retq

fdef("ABS",3,0,ABS)
		or		%eax,%eax
		js		NEGATE
		retq

fdef("NEGATE",6,0,NEGATE)
		neg		%eax
		retq

fdef("INVERT",6,0,INVERT)
		not		%eax
		retq

fdef("1+",2,0,_1add)
CHARadd:
		inc		%eax
		ret
fordef("CHAR+",5,0,_1add)

fdef("1-",2,0,_1sub)
		lea		-1(%rax),%eax
		retq

fdef("2-",2,0,_2sub)
		lea -0x2(%rax),%eax
		retq

fdef("2+",2,0,_2add)
		lea 0x2(%rax),%eax
		retq

fdef("CELLS",5,0,CELLS)
		lea		(,%eax,4),%eax
		retq
fdef("CELL-",5,0,CELLsub)
		lea		-4(%rax),%eax
		retq
fdef("CELL+",5,0,CELLadd)
		lea		4(%rax),%eax
		retq

fdef("COUNT",5,0,COUNT)
		lea    -4(%rbp), %rbp
		lea    1(%rax), %rdx
		movzbl  (%rax),%eax
		movl    %edx, (%rbp)
		ret

fdef("U>D",3,0,UgreatD)
		lea		-4(%rbp),%ebp
		mov		%eax,(%rbp)
		xor		%eax,%eax
		retq

fdef("S>D",3,0,SgreatD)
		cltd
		lea		-4(%rbp),%ebp
		mov		%eax,(%rbp)
		mov		%edx,%eax
		retq

fdef("H-STDOUT",8,0,HsubSTDOUT)
		call	DUP
		mov		$1,%eax
		ret

fdef("UM/MOD",6,0,UMrslMOD)
		mov		%eax,%ecx
		mov		(%rbp),%edx
		mov		4(%rbp),%eax
		div		%ecx
		lea		4(%rbp),%ebp
		mov		%edx,(%rbp)
		mov		%eax,%eax
		retq

fdef("U/",2,0,Ursl)
		mov %eax,%ecx
		mov 0(%rbp),%eax
		xor %edx,%edx
		lea 4(%rbp),%ebp
		div %ecx
		retq

fdef("U*",2,0,UMmul)
		mull	(%rbp)
		mov		%eax,(%rbp)
		mov		%edx,%eax
		retq

fdef("*",1,0,mul)
		mov		%eax,%eax
		imull	(%rbp)
		lea		4(%rbp),%ebp
		retq

fdef("/",1,0,rsl)
	mov %eax,%ecx
	mov (%ebp),%eax
	cltd
	idiv %ecx
	lea 4(%ebp),%ebp
	ret

fdef("MOD",3,0,MOD)
		mov		%eax,%ecx
		mov		(%rbp),%eax
		cltd
		idiv	%ecx
		lea		4(%rbp),%ebp
		mov		%edx,%eax
		retq

//		mov %ecx,%edx
//		mov %ecx,%eax
//		sar $0x1f,%edx
//		idivl (%rsi)
//		ret
fdef("?DUP",4,0,queDUP)
		or %eax,%eax
		jne DUP
		retq

fdef(">",1,0,great)
		cmp		(%rbp),%eax
		setge	%al
		and		$1,%eax
		dec		%eax
		lea		4(%rbp),%rbp
		ret
fdef("<",1,0,less)
		cmp		(%rbp),%eax
		setle	%al
		and		$1,%eax
		dec		%eax
		lea		4(%rbp),%rbp
		ret

fdef("<>",2,0,lessgreat)
		xor		(%rbp),%eax
		neg		%eax
		sbb		%eax,%eax
		lea		4(%rbp),%rbp
		ret

fdef("0<>",3,0,_0lessgreat)
		neg		%eax
		sbb		%eax,%eax
		ret

fdef("0>",2,0,_0great)
		neg		%eax
_0less:	sar		$0x1f,%eax
		retq
fordef("0<",2,0,_0less)

fdef("U>",2,0,Ugreat)
		cmp		(%rbp),%eax
		sbb		%eax,%eax
		lea		4(%rbp),%ebp
		retq

fdef("U<",2,0,Uless)
		cmp		%eax,(%rbp)
		sbb		%eax,%eax
		lea		4(%rbp),%ebp
		retq

fdef("OR",2,0,OR)
		or		(%rbp),%eax
		lea		4(%rbp),%rbp
		ret

fdef("AND",3,0,AND)
		and		(%rbp),%eax
		lea		4(%rbp),%rbp
		ret

fdef("-",1,0,sub)
//sub:
		neg		%eax
add:	add		(%rbp),%eax
		lea		4(%rbp),%rbp
		ret
fordef("+",1,0,add)

fdef("DNEGATE",7,0,DNEGATE)
		mov (%rbp),%edx
		neg %eax
		neg %edx
		sbb $0,%eax
		mov %edx,(%rbp)
		retq

fdef("D+",2,0,Dadd)
		mov 0x0(%rbp),%edx
		add %edx,0x8(%rbp)
		adc 0x4(%rbp),%eax
		lea 0x8(%rbp),%ebp
		retq

fdef("PF.",3,0,PFdot)
		call	DUP
	mov %rsp,%rbx
//	and $-0x10,%rbx
	and $8,%rbx
	je	F_dot1
		push	%rbx
		call F_dot_STR
		pop		%rbx
		ret
F_dot1:
		jmp F_dot_STR

fdef("ZTOFLOAT",8,0,ZTOFLOAT)
		movl    %eax,%edi
		call	ZTO_FLOAT
		ret

jdef("F+",2,0,Fadd,f_plus)
jdef("F-",2,0,Fsub,f_minus)
jdef("F*",2,0,Fmul,f_star)
jdef("F/",2,0,Frsl,f_slash)
jdef("1e",2,0,_1e,x1e)
jdef("DIFF",4,0,DIFF,_Z4DIFFv)

fdef("F!",2,0,Fsave)
		movl    %eax,%edi
		call	f_store
		ret

fdef("F@",2,0,Fload)
		movl    %eax,%edi
		call	f_fetch
		ret

fdef("F>D",3,0,FgreatD)
		lea		-8(%rbp),%ebp
		mov		%eax,4(%rbp)
		call	f_to_d
		mov		%eax,(%rbp)
		shr		$32,%rax
		ret

fdef("D>F",3,0,DgreatF)
        movl    (%rbp), %edi
		shl		$32,%rax
		or		%rax, %rdi
		lea		8(%rbp), %rbp
		jmp		d_to_f

//sub:


fdef("R@",2,0,Rload)
		lea		-4(%rbp),%ebp
		mov		%eax,(%rbp)
		mov		8(%rsp),%eax
		retq

fdef("R>",2,0,Rgreat)
		mov		(%rsp),%rbx
		lea    -4(%rbp), %rbp
		mov		%eax,(%rbp)
		mov		8(%rsp),%eax
		lea		0x10(%rsp),%rsp
		jmpq	*%rbx

fdef(">R",2,0,greatR)
		pop		%rbx
		push	%rax
		mov		(%rbp),%eax
		lea		4(%rbp), %rbp
		jmpq	*%rbx

fdef("2R>",3,0,_2Rgreat)
		mov		(%rsp),%rbx
		mov		%eax,-4(%rbp)
		mov		0x10(%rsp),%ecx
		mov		8(%rsp),%eax
		mov		%ecx,-8(%rbp)
		lea		-8(%rbp),%ebp
		lea		0x18(%rsp),%rsp
		jmpq	*%rbx

fdef("2>R",3,0,_2greatR)
		pop		%rbx
		pushq	(%rbp)
		push	%rax
		lea		8(%ebp),%ebp
		mov		-4(%ebp),%eax
		jmpq *%rbx

fdef("2R@",3,0,_2Rload)
		mov		%eax,-4(%rbp)
		mov		8(%rsp),%eax
		mov		0x10(%rsp),%ebx
		mov		%ebx,-8(%rbp)
		lea		-8(%rbp),%ebp
		retq

fdef("SP@",3,0,SPload)
		lea		-4(%rbp),%ebp
		mov		%eax,(%rbp)
		mov		%ebp,%eax
		retq

fdef("SP!",3,0,SPsave)
		lea		4(%rax),%ebp
		mov		-4(%rbp),%eax
		retq

fdef("RP!",3,0,RPsave)
		pop %rbx
		or HSPSAVE,%rax
		mov %rax,%rsp
		mov 0x0(%rbp),%eax
		lea 0x4(%rbp),%ebp
		jmpq *%rbx

fdef("CDR",3,0,CDR)
 // ( NFA1 -> NFA2 )
		or		%eax,%eax
		jz		cdr1
		mov		-4(%eax),%eax
cdr1:	ret

fdef("NAME>",5,0,NAMEgreat)
		mov		-0xC(%eax),%eax
		retq

fdef("NAME>F",6,0,NAMEgreatF)
		lea		-8(%eax),%eax
		retq

fdef("FILL",4,0,FILL)
		mov		%edi,%edx
		mov		%eax,%eax
		mov		(%rbp),%ecx
		mov		4(%rbp),%edi
		cld
		mov		%ecx,%ebx
		and		$3,%ebx
		jne		FILL49
		mov		%eax,%ebx
		shl		$8,%eax
		or		%ebx,%eax
		shl		$8,%eax
		or		%ebx,%eax
		shl		$8,%eax
		or		%ebx,%eax
		mov		%ecx,%ebx
		sar		$0x2,%ecx
		rep		stos %eax,%es:(%rdi)
		mov		%ebx,%ecx
		and		$0x3,%ecx
FILL49:	rep		stos %al,%es:(%rdi)
		mov		%edx,%edi
		lea		0xc(%rbp),%ebp
		mov		-4(%rbp),%eax
		retq

fdef("CMOVE>",6,0,CMOVEgreat)
		mov		%edi,%edx
		mov		%eax,%ecx
		mov		(%rbp),%edi
		mov		4(%rbp),%esi
		std
		add		%ecx,%edi
		add		%ecx,%esi
		dec		%esi
		dec		%edi
		rep movsb %ds:(%rsi),%es:(%rdi)
		cld
		mov		%edx,%edi
		lea		0xc(%rbp),%ebp
		mov		-4(%rbp),%eax
		retq

fdef("CMOVE",5,0,CMOVE)
		mov		%edi,%edx
		mov		%eax,%ecx
		mov		(%rbp),%edi
		mov		4(%rbp),%esi
		cld
		rep movsb %ds:(%rsi),%es:(%rdi)
		mov		%edx,%edi
		lea		0xc(%rbp),%ebp
		mov		-4(%rbp),%eax
		retq

fdef("LCMOVE",6,0,LCMOVE)
		mov		%eax,%ecx
		mov		(%rbp),%rdi
		mov		8(%rbp),%rsi
		cld
		rep movsb %ds:(%rsi),%es:(%rdi)
		lea		20 (%rbp),%ebp
		mov		-4(%rbp),%eax
		retq

fdef("ASCIIZ>",7,0,ASCIIZgreat)
		lea		-4(%rbp),%ebp
		mov		%eax,%edx
ASCg:	mov		(%rax),%cl
		lea		1(%rax),%eax
		or		%cl,%cl
		jne		ASCg
		lea		-1(%rax),%eax
		sub		%edx,%eax
		mov		%edx,(%rbp)
		retq

fdef("EXECUTE",7,0,EXECUTE)
		mov		%eax,%edx
		mov		(%rbp),%eax
		lea		4(%rbp),%ebp
		jmpq	*%rdx

fdef("_SLITERAL-CODE",0xA ,0x0 ,_SLITERALsubCODE)
        lea    -8(%rbp), %rbp
   		movl    %eax, 4(%rbp)
		pop		%rbx
		movzbl  (%rbx),%eax
		inc		%rbx
		mov		%ebx,(%rbp)
		addl    %eax,%ebx
		inc		%ebx
		jmp		%rbx

HHdot:
		movl    %eax,%edi
		call	HPOINT
		call	DROP
		ret

fdef("NOOP",0x4 ,0x0 ,NOOP)
		ret

fdef("RP@",3 ,0x0 ,RPload)
		lea    -4(%rbp), %rbp
		mov		%eax,(%rbp)
		lea    8(%esp), %eax
//		mov		%esp,%eax
		ret

fdef("I",1 ,0x0 ,I)
		lea -4(%rbp),%rbp
		mov %eax,(%rbp)
		mov 8(%rsp),%eax
		sub 16(%rsp),%eax
		retq

fdef("ADD[ESP],TOS",12 ,0x0 ,ADDxESPycomTOS)
		add %eax,8(%rsp)
		mov	(%rbp),%eax
		lea	4(%rbp),%rbp
		ret

fdef("XDO",3 ,0x0 ,XDO)
	mov		$0x80000000,%edx
	sub		(%rbp),%edx
	lea		(%rdx,%rax,1),%ebx
	mov		4(%rbp),%eax
	mov		%edx,%edx
	lea		8(%rbp),%ebp
	ret


fdef("QBRANCH",7 ,0x0 , QBRANCH)
		or %eax,%eax
		mov	(%rbp),%eax
		lea	4(%rbp),%rbp
		ret

fdef("XLIT",4 ,0x0 , XLIT)
 	sub		$4,%ebp
	mov		%eax,(%rbp)
	pop		%rdx
	mov		(%rdx),%eax
 	add		$4,%rdx
	jmpq	*%rdx

fdef("ACCEPT1",7,0x0 ,ACCEPT1)
		mov    (%rbp),%esi
		mov    %eax,%edx
		xor    %edi,%edi
		call	read
		lea		4(%rbp),%ebp
		retq

fdef("WRITE-FILE",0xA ,0x0 ,WRITEsubFILE)
        movl    4(%rbp), %esi
        movl    (%rbp), %edx
		movl    %eax, %edi
        call    write
        addq    $8, %rbp
		ret

fdef("READ-FILE",9,0 ,READsubFILE)
		mov    4(%rbp),%esi
		mov    (%rbp),%edx
		mov    %eax,%edi
		call	read

//		mov    4(%rbp),%esi
		mov		%eax,4(%rbp)

		cmp		%esi,%eax
		setle	%al
		and		$1,%eax
		dec		%eax

		lea		4(%rbp),%ebp
		retq

fdef("REPOSITION-FILE",9,0 ,REPOSITIONsubFILE)
		mov		4(%rbp),%esi
//		mov		4(%rbp),%edx
		mov		%eax,%edi

		call	rmlseek

		mov		%eax,4(%rbp)

		cmp		%esi,%eax
		setle	%al
		and		$1,%eax
		dec		%eax

		lea		8(%rbp),%ebp
		retq



fdef("ZOPEN-FILE",10,0x0 ,ZOPENsubFILE)
		mov		(%rbp),%edi
		mov		%eax,%esi
		callq 	LOPEN
		mov		%eax,(%rbp)
		inc		%eax
		sbb		%eax,%eax
		not		%eax

//		lea		4(%rbp),%ebp

		retq

fdef("CLOSE-FILE",10,0 ,CLOSEsubFILE)
		mov    %eax,%edi
		call	read
		retq

fdef("FILE-POSITION",13,0 ,FILEsubPOSITION)
		mov    %eax,%edi
		lea		-8(%rbp),%ebp
		call	mtell
		cmp		$-1,%eax
		je		FILEP
		mov		%eax,4(%rbp)
		movl	$0,(%rbp)
		xor		%eax,%eax
		ret
FILEP:	mov		%eax,4(%rbp)
		mov		%eax,(%rbp)
		ret

fdef("FILE-SIZE",9,0 ,FILEsubSIZE)
		mov    %eax,%edi
		lea		-8(%rbp),%ebp
		call	mtell
		cmp		$-1,%eax
		je		FILES
		mov		%eax,4(%rbp)
		movl	$0,(%rbp)
		xor		%eax,%eax
		ret
FILES:	mov		%eax,4(%rbp)
		mov		%eax,(%rbp)
		ret

HALT:	mov		%eax,%edi
		jmp		exit

fdef("LALLOCATE",9,0 ,LALLOCATE)
		mov    %eax,%edi
		call	malloc
		lea		-8(%rbp),%ebp
		mov		%rax,(%rbp)
		cmp		$0,%rax
		je		ALL770
		mov		$0,%eax
		ret
ALL770:	mov		$-300,%eax
		ret

fdef("LFREE",4,0 ,LFREE)
		mov		(%rbp),%edi
		shl		$0x20,%rdi
		or     %eax,%eax
		or     %rax,%rdi
		call	free
		lea		4(%rbp),%ebp
		mov		$0,%eax
		ret

fdef("ZCD",3,0 ,ZCD)
		mov    %eax,%edi
		jmp		chdir@plt


fdef("VECT-CODE",9,0,VECTsubCODE)
 call _CONSTANTsubCODE
 .int _VECTsubCODE
 call _TOVALUEsubCODE

fdef("'DUP_V",6,0,ticDUP_V )
 call _CONSTANTsubCODE+0x0
 .int DUP
 call _TOVALUEsubCODE+0x0

fdef("'DROP_V",7,0,ticDROP_V )
 call _CONSTANTsubCODE+0x0
 .int DROP
 call _TOVALUEsubCODE+0x0

fdef("'(ABORT'')",7,0,ticcABORTdticcend)
 call _CONSTANTsubCODE+0x0
 .int cABORTdticcend
 call _TOVALUEsubCODE+0x0


fdef("'TYPE",7,0,ticTYPE )
 call _CONSTANTsubCODE+0x0
 .int TYPE
 call _TOVALUEsubCODE+0x0

mdef("NNN",3 ,0x0 ,WsubCNT-0x5, NNN)
 call _USERsubCODE+0x0 
 .int T_NNN-main_task
mdef("W-CNT",0x5 ,0x0 ,greatOUT-0x4, WsubCNT)
 call _USERsubCODE+0x0 
 .int 0xD2C 
mdef(">OUT",0x4 ,0x0 ,CONTEXT-0x7, greatOUT)
 call _USERsubCODE+0x0 
 .int T_greatOUT-main_task 
mdef("CONTEXT",0x7 ,0x0 ,SsubO-0x3, CONTEXT)
 call _USERsubVALUEsubCODE+0x0 
 .int T_CONTEXT-main_task
 call _TOUSERsubVALUEsubCODE+0x0 

mdef("S-O",0x3 ,0x0 ,CURRENT-0x7 ,SsubO)
 call _USERsubCODE+0x0 
 .int T_SsubO-main_task
mdef("CURRENT",0x7 ,0x0 ,WBWsubOFFS-0x8,CURRENT)
 call _USERsubCODE+0x0 
 .int T_CURRENT-main_task
mdef("WBW-OFFS",0x8 ,0x0 ,BASE-0x4,WBWsubOFFS)
 call _USERsubCODE+0x0 
 .int T_WBWsubOFFS-main_task

mdef("BASE",0x4 ,0x0 ,WBWsubNFA-0x7,BASE)
 call _USERsubCODE+0x0 
 .int T_BASE-main_task
mdef("WBW-NFA",0x7 ,0x0 ,CURSTR-0x6,WBWsubNFA)
 call _USERsubCODE+0x0 
 .int T_WBWsubNFA-main_task
mdef("CURSTR",0x6 ,0x0 ,SOURCEsubID-0x9,CURSTR)
 call _USERsubCODE+0x0 
 .int T_CURSTR-main_task
mdef("SOURCE-ID",0x9 ,0x0 , PAD-0x3,SOURCEsubID)
 call _USERsubVALUEsubCODE+0x0 
 .int T_SOURCEsubID-main_task
 call _TOUSERsubVALUEsubCODE+0x0
 
mdef("PAD",0x3 ,0x0 ,ATIB-0x4,PAD)
 call _USERsubCODE+0x0 
 .int T_PAD-main_task
mdef("ATIB",0x4 ,0x0 ,TIB-0x3,ATIB)
 call _USERsubCODE+0x0 
 .int T_ATIB-main_task

mdef("TIB",0x3 ,0x0 ,greatIN-0x3,TIB)
 call _USERsubVALUEsubCODE+0x0 
 .int T_TIB-main_task
 call _TOUSERsubVALUEsubCODE+0x0 
mdef(">IN",0x3 ,0x0 ,nTIB-0x4,greatIN)
 call _USERsubCODE+0x0 
 .int T_greatIN-main_task
mdef("#TIB",0x4 ,0x0 ,DOESgreatA-0x6,nTIB)
 call _USERsubCODE+0x0 
 .int T_nTIB-main_task
mdef("DOES>A",0x6 ,0x0 ,ERsubU-0x4,DOESgreatA)
 call _USERsubCODE+0x0 
 .int T_DOESgreatA-main_task
mdef("ER-U",0x4 ,0x0 ,ERsubA-0x4,ERsubU)
 call _USERsubCODE+0x0 
 .int T_ERsubU-main_task
mdef("ER-A",0x4 ,0x0 ,HANDLER-0x7,ERsubA)
 call _USERsubCODE+0x0 
 .int T_ERsubA-main_task
mdef("HANDLER",0x7 ,0x0 ,CURFILE-0x7,HANDLER)
 call _USERsubCODE+0x0 
 .int T_HANDLER-main_task
mdef("CURFILE",0x7 ,0x0 ,BLK-0x3,CURFILE)
 call _USERsubCODE+0x0 
 .int T_CURFILE-main_task
mdef("BLK",0x3 ,0x0 ,STATE-0x5,BLK)
 call _USERsubCODE+0x0 
 .int T_BLK-main_task
mdef("STATE",0x5 ,0x0 ,WARNING-0x7,STATE)
 call _USERsubCODE+0x0 
 .int T_STATE-main_task
mdef("WARNING",0x7 ,0x0 ,R_0-0x2,WARNING)
 call _USERsubCODE+0x0 
 .int T_WARNING-main_task
mdef("R0",0x2 ,0x0 ,S0-0x2,
R_0)
 call _USERsubCODE+0x0 
 .int T_R0-main_task
mdef("S0",0x2 ,0x0 ,TOVALUEsubCODE-0xC,
S0)
 call _USERsubCODE+0x0 
 .int T_S0-main_task

mdef("TOVALUE-CODE",0xC ,0x0 ,CONSTANTsubCODE-0xD,
TOVALUEsubCODE)
 call _CONSTANTsubCODE 
 .int _TOVALUEsubCODE
 call _TOVALUEsubCODE
mdef("CONSTANT-CODE",0xD ,0x0 ,USERsubCODE-0x9,CONSTANTsubCODE)
 call _CONSTANTsubCODE
 .int _CONSTANTsubCODE
 call _TOVALUEsubCODE
mdef("USER-CODE",0x9 ,0x0 ,CREATEsubCODE-0xB,USERsubCODE)
 call _CONSTANTsubCODE
 .int _USERsubCODE
 call _TOVALUEsubCODE
mdef("CREATE-CODE",0xB ,0x0 ,CLITERALsubCODE-0xD,
CREATEsubCODE)
 call _CONSTANTsubCODE
 .int _CREATEsubCODE
 call _TOVALUEsubCODE
mdef("CLITERAL-CODE",0xD ,0x0 ,_CLITERALsubCODE-0xE,
CLITERALsubCODE)
 call _CONSTANTsubCODE
 .int _CLITERALsubCODE
 call _TOVALUEsubCODE
mdef("_CLITERAL-CODE",0xE ,0x0 ,SLITERALsubCODE-0xD,
_CLITERALsubCODE)
   sub $0x4,%ebp
   mov %eax,0x0(%rbp)
   pop %rax
   movzbl (%rax),%ebx
   lea 0x2(%rbx,%rax,1),%ebx
   jmpq *%rbx
mdef("SLITERAL-CODE",0xD ,0 ,_TOUSERsubVALUEsubCODE-0x12,
SLITERALsubCODE)
 call _CONSTANTsubCODE
 .int _SLITERALsubCODE
 call _TOVALUEsubCODE
mdef("_TOUSER-VALUE-CODE",0x12 ,0 ,_TOVALUEsubCODE-0xD,
_TOUSERsubVALUEsubCODE)
		pop		%rbx
		sub		$9,%ebx
		mov		(%rbx),%ebx
		add		%r14d,%ebx
		mov		%eax,(%rbx)
		mov		(%rbp),%eax
		add		$4,%ebp
		retq
mdef("_TOVALUE-CODE",0xD ,0x0 ,_VECTsubCODE-0xA,_TOVALUEsubCODE)
		pop		%rbx
		lea		-9(%rbx),%ebx
		mov		%eax,(%rbx)
		mov		(%rbp),%eax
		lea		4(%rbp),%ebp
		retq

mdef("_VECT-CODE",0xA ,0x0 ,_USERsubVALUEsubCODE-0x10,
_VECTsubCODE)
		pop		%rbx
		mov		(%ebx),%ebx
		jmp		%rbx

mdef("_USER-VALUE-CODE",0x10 ,0x0 ,USERadd-0x5,
_USERsubVALUEsubCODE)
		sub $0x4,%ebp
		mov %eax,0x0(%rbp)
		pop %rax
		mov (%rax),%eax
		add %r14d,%eax
		mov (%rax),%eax
		retq
mdef("USER+",0x5 ,0x0 ,_USERsubCODE-0xA,
USERadd)
 .byte 0x3 ,0xC7 
 .byte 0xC3 
mdef("_USER-CODE",0xA ,0x0 ,_CONSTANTsubCODE-0xE,_USERsubCODE)
		sub $0x4,%ebp
		mov %eax,0x0(%rbp)
		pop %rax
		mov (%rax),%eax
		add %r14d,%eax
		retq
 mdef("_CONSTANT-CODE",0xE ,0x0 ,_CREATEsubCODE-0xC,_CONSTANTsubCODE)
 	sub $4,%ebp
	mov %eax,(%rbp)
	pop %rax
	mov (%rax),%eax
	retq

mdef("_CREATE-CODE",0xC ,0x0 ,VOCsubLIST-0x8,_CREATEsubCODE)
 	sub $0x4,%ebp
 	mov %eax,(%rbp)
 	pop %rax
	retq

mdef("VOC-LIST",0x8 ,0x0 ,BYE-0x3,
//mdef("VOC-LIST",0x8 ,0x0 ,5,
VOCsubLIST)
 call _CREATEsubCODE 
 .int T_FORTH

mdef("BYE",0x3 ,0x0 ,FORTHsubWORDLIST-14,BYE)
    call LBYE
/*  call refresh
  call endwin
 .byte 0x89 ,0x45 ,0xFC 
 .byte 0x33 ,0xC0 
 .byte 0x83 ,0xC5 ,0xFC 
 call HALT 
 .byte 0xC3 */

mdef("FORTH-WORDLIST",14 ,0x0 ,LAST-0x4,FORTHsubWORDLIST)
//mdef("FORTH-WORDLIST",14 ,0x0 ,5,FORTHsubWORDLIST)
 call _CONSTANTsubCODE 
 .int T_FORTH+4
 call _TOVALUEsubCODE 

mdef("LAST",4 ,0x0 , USERsubOFFS-0x9,LAST)
 call _CREATEsubCODE 
 .int LastNFA

mdef("USER-OFFS",9 ,0x0 ,UPPER_V-0x7,USERsubOFFS)
 call _CREATEsubCODE 
 .int reserve+MUSEROFFS

mdef("UPPER_V",0x7 ,0x0 ,TCYDP0-6,UPPER_V)
 call _CREATEsubCODE+0x0 
 .int NOOP

mdef("TCYDP0",6 ,0x0 ,IMAGEBEGIN-11,TCYDP0)
 call _CONSTANTsubCODE 
 .int T_YDP0
 call _TOVALUEsubCODE 

mdef("IMAGE-BEGIN",11 ,0x0 ,DP-2,IMAGEBEGIN)
 call _CONSTANTsubCODE 
 .int main
 call _TOVALUEsubCODE 

//mdef("DP",0x2 ,0x0 ,0+1,DP)
//mdef("DP",0x2 ,0x0 ,RPload-3,DP)
mdef("DP",0x2 ,0x0 ,DEFLAST+1,DP)
 call _CREATEsubCODE 
 .int DP_BUFF 

// =================================< ����� FORTH ��設�
main_task:
T_R0:		.int 0
T_S0:		.int _Stekc+STACK_SIZE-0x20
T_WARNING:	.int -1
T_STATE:	.int 0
T_BLK:		.int 0
T_CURFILE:	.int 0
T_HANDLER:	.int 0
T_HLD:		.int 0
T_BASE:		.int 0xA
		.space PAD_SIZE,0
T_PAD:		.space PAD_SIZE,0
T_ERsubA:	.int 0
T_ERsubU:	.int 0
T_DOESgreatA:	.int 0
//T_ALIGNsubBYTES:.int 0
T_nTIB:		.int 0
T_greatIN:	.int 0
T_TIB:		.int T_ATIB
T_ATIB:		.space TIB_SIZE,0
T_SOURCEsubID:	.int 0
T_CURSTR:	.int 0
T_WBWsubNFA:	.int 0
T_WBWsubOFFS:	.int 0
T_CURRENT:	.int T_FORTH+4
T_SsubO:	.int T_FORTH+4,T_FORTH+4,0,0,0,0,0,0,0,0,0,0,0,0
T_CONTEXT:	.int T_SsubO
T_greatOUT:	.int 0
T_WsubCNT:	.int 0
T_NNN:		.int 0
Mreserve:	.space 1000,0	// १��

T_FORTH:	.int 0			// ��� VOC-LIST
		.int LastNFA		// ���� ��᫥����� �����
                .int 0			// �।��
                .int 0			// �����

LastCFA1:
	call	_0Edot
 .byte 0xC3

#include "./img.s"
.comm HSPSAVE,8
.comm T_YDP0,0x4000
.comm DP_BUFF,VOCABULARY_POOL
.comm _Stekc,STACK_SIZE
