\ REQUIRE INCLUDED_L ~mak/listing3.f 
\ S" _mak/djgpp/gdis.f" INCLUDED
: XLIT
  R> DUP CELL+ >R @ ;

REQUIRE GTYPE _mak/djgpp/gdis.f

0 VALUE TOUSER-VALUE-CODE
0 VALUE ---CODE

0 VALUE DO-OFF
0 VALUE ?DO-OFF

0 VALUE OFF-LOOP
0 VALUE OFF-+LOOP

0 VALUE  'DUP_V
0 VALUE 'DROP_V

' DUP TO 'DUP_V
' DROP TO 'DROP_V

:  'DUP  'DUP_V ;
: 'DROP 'DROP_V ;

: M\  POSTPONE \  ; IMMEDIATE
: OS\ POSTPONE \ ; IMMEDIATE

: [>T]  ; IMMEDIATE
:  >T   ; IMMEDIATE

TRUE VALUE J_OPT?
: TT ;

DIS-OPT
 S" src/macroopt.f" INCLUDED

 TRUE TO ?C-JMP
\ 0    TO ?C-JMP

: TC-COMPILE,  \ 94 CORE EXT
\ �������������: ��������� �� ����������.
\ ����������: ( xt -- )
\ �������� ��������� ���������� �����������, �������������� xt, �
\ ��������� ���������� �������� �����������.
    CON>LIT 
    IF  INLINE?
      IF     INLINE,
      ELSE   _COMPILE,
      THEN
    THEN
;

: _DABS ( d -- ud ) \ 94 DOUBLE
\ ud ���������� �������� d.
  DUP 0< IF DNEGATE THEN
;



: DABS ( d -- ud ) \ 94 DOUBLE
\ ud ���������� �������� d.
  DUP 0< IF DNEGATE THEN
;

0 VALUE TSAVE_LIMIT

: TSAVE (  ADDR LEN -- )
 H-STDOUT  >R R/W  CREATE-FILE    THROW
 TO H-STDOUT
  UNIX-LINES
 CR ." MUSEROFFS=0x" USER-HERE RESERVE - H.
 CR
 HERE >R
 CONTEXT @ @
 BEGIN
 CR ." def(" DUP COUNT ATYPE ." ,0x"
             DUP C@    H.   ." ,0x"
             DUP 1- C@ H.   ." ,"
             DUP CDR DUP COUNT GTYPE ." -0x"
                         C@ H. ." )"
 CR  ." .globl " DUP COUNT GTYPE 
 CR  DUP COUNT GTYPE ." :" 
 R> OVER NAME> GDIS
 DUP NAME>C >R
 CDR 
 DUP TSAVE_LIMIT U<
 UNTIL DROP RDROP CR
 H-STDOUT CLOSE-FILE  THROW R> TO H-STDOUT 
;

: RN> CHAR SWAP WordByAddr DROP C! ;

' CR CONSTANT '_CR

: LOOP   \ 94
  ?COMP 
  0x24 0x4FF W, C, \ inc dword [esp]
  HERE 2+ - DUP SHORT?   SetOP SetJP
  IF
    0x71 C, C, \ jno short 
  ELSE
    4 - 0xF C, 0x81 C, , \ jno near
  THEN    SetOP
  0x48 C, 0x1824648D , \ lea 0x18(%rsp),%rsp
  DP @ SWAP !
; IMMEDIATE


: ADD[ESP],TOS
  R> SWAP
  ['] ADD[ESP],EAX INLINE,  
  DROP >R
;

: XDO
[
 0xBA C, 0x80000000 , 
 0x2B C, 0x55 C, 0x0 C, 
 0x8D C, 0x1C C, 0x2 C, 
 0x8B C, 0x45 C, 0x4 C,
 0x8D C, 0x6D C, 0x8 C,
 ]
 ;

: DO
 ['] XDO _COMPILE, 
   0x68 C, DP @ 4 ALLOT
   0x52 C,    \ PUSH EDX
   0x53 C,    \ PUSH EBX
  4 ALIGN-NOP
  DP @ \ DUP TO :-SET
; IMMEDIATE


: +LOOP    \ 94
   ?COMP  
   ['] ADD[ESP],TOS  _COMPILE,
\   ['] DROP _COMPILE,
   HERE 2+  - 
   DUP  SHORT?   SetOP SetJP
  IF    0x71 C, C, \ jno short 
  ELSE    4 - 0xF C, 0x81 C, , \ jno near
  THEN      SetOP
   0x48 C, 0x1824648D , \ lea esp, 0c [esp]
  DP @ SWAP   !
; IMMEDIATE


: I   \ 94
  R> 2R@  - SWAP >R ;


: CC-2RDROP
[ 0x48 C, 0x83 C, 0xc4 C, 0x10 C, \	add    $0x10,%rsp
]	;

: 2RDROP ['] CC-2RDROP INLINE, ;   IMMEDIATE

: UNLOOP
  0x48 C, 0x1824648D , \ lea 0x18(%rsp),%rsp
; IMMEDIATE

: LEAVE    \ 94
\ �������������: ��������� ������������.
\ ����������: ( -- ) ( R: loop-sys -- )
\ ������ ������� ��������� �����. �������������� �������� ���������, ���� 
\ ��� ����������. ���������� ���������� ����� �� ������ ����������� DO ... LOOP 
\ ��� DO ... +LOOP.
  0x48 C, 0x1024648D , \ lea esp, 0x10 [esp]
  0xC3 C,  \ ret
; IMMEDIATE

: RDROP
  0x48 C, 0x83 C, 0xc4 C, 0x8 C, \ add $0x8,%rsp
; IMMEDIATE

: MDUMP DUMP ;

 0xE9 ' COMPILE, C! 
 ' TC-COMPILE, ' COMPILE, - 5 -  ' COMPILE, 1+ !
 
 : ['] ' LIT, ; IMMEDIATE


:  QBRANCH
 [ 0xC00B W, ] 
  DROP  ;

: M?BRANCH, ( ADDR -> )
\ ?BRANCH, EXIT
  ['] QBRANCH _COMPILE,
  0x84 \ TO J_COD
  0x0F     \  ����� �� JX
  C, C,
  DUP IF DP @ CELL+ - THEN , \ DP @ TO LAST-HERE
;

: IF 
  ?COMP DP @ M?BRANCH, >MARK 1
; IMMEDIATE

\ EOF  

: >R  R> SWAP >R >R ;
: R>  R> R> SWAP >R ;  

: XLIT, ( N -- )
  ['] XLIT _COMPILE, , ;


  0xE9 ' LIT, C! 
  ' XLIT, ' LIT, - 5 -  ' LIT, 1+ !
