home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / loadexe.seq < prev    next >
Text File  |  1990-07-23  |  5KB  |  100 lines

  1. \ LOADEXE.SEQ
  2.  
  3. HEADERLESS
  4.  
  5. HEX
  6.  
  7. CREATE SUVEC  100 , 0 ,         \ A place to save the entry absolute
  8.                                 \ address of Forth. The zero gets plugged
  9.                                 \ with the current value of CS.
  10. VARIABLE DPSAVED                \ A place to save DP for restoral
  11. VARIABLE XDPSEGLEN              \ holds the relative value for XSEGLEN
  12. VARIABLE WITHHEADS              \ which is later adjusted in COLD to an
  13.          WITHHEADS ON           \ absolute value.
  14.  
  15. LABEL  SEXE
  16.         MOV SUVEC 2+ DS         \ Save DS=CS into setup vector for
  17.                                 \ use in running forth after all this
  18.                                 \ setup is done.
  19.  
  20.         MOV AX, DS                      \ move DS to AX
  21.         ADD AX, ' #CODESEGS >BODY       \ add CODE size
  22.         ADD AX, ' #OVSEGS   >BODY       \ add OVERLAY segments
  23.         ADD AX, ' #LISTSEGS >BODY       \ and LIST size to get to heads
  24.         MOV ES, AX                      \ move head seg to ES
  25.         MOV CX, YDP                     \ get contents of YDP to CX
  26.         MOV SI, CX                      \ COPY it into SI
  27.         DEC SI
  28.         MOV DI, SI              \ decrement SI and move to DI
  29.                                 \ We have set up the END addresses for a move
  30.                                 \ backwards, to assure no overlap during
  31.                                 \ expansion. THIS IS VERY IMPORTANT !!
  32.         SUB AX, AX              \ Clear AX
  33.         XCHG AX, YSTART         \ Exchange AX, and YSTART clearing it
  34.         ADD AX, SUVEC 2+        \ Add to setup vector, it contains
  35.         PUSH DS                 \ save DS
  36.         MOV DS, AX              \ move AX to DS
  37.         OR CX, CX 0<>           \ if YDP was not zero (0)
  38.         IF      STD             \ moving BACKWARDS !!!
  39.                 REPZ
  40.                 MOVSB           \ move HEADS to head space
  41.                 CLD
  42.         THEN
  43.         POP DS                  \ restore DS
  44.         MOV YSEG ES             \ set YSEG to ES
  45.         MOV DX, DS                      \ move DS to AX
  46.         ADD DX, ' #CODESEGS >BODY       \ Add CODE space segments and
  47.         ADD DX, ' #OVSEGS   >BODY       \ add OVERLAY segments to get
  48.                                         \ to the LIST segment start.
  49.         PUSH DX                 \ Save for later use bye ES
  50.         MOV CX, XDPSEGLEN       \ get contents of XSEGLEN which is the LENGTH
  51.                                 \ to move in SEGMENTS.
  52.  
  53.         MOV BX, DPSTART         \ mov LIST offset segment to BX
  54.                                 \ DPSTART in SAVEEXE holds the segment offset
  55.                                 \ from CS to where LIST section starts.
  56.         ADD BX, SUVEC 2+        \ Add this to the setup vector which holds
  57.                                 \ the current value of CS. The result is the
  58.                                 \ absolute segment address of start of LIST.
  59.         ADD BX, CX              \ Adjust source to end of move, will be
  60.         DEC BX                  \ plugged into DS later.
  61.         ADD DX, CX              \ Bump destination segment to end of move
  62.         DEC DX                  \ We are moving BACKWARDS to avoid any
  63.                                 \ possibility of an overlay.
  64.         PUSH DS                 \ save DS for later restoral
  65.         STD                     \ Yes we are moving BACKWARDS.
  66.         HERE
  67.                 MOV ES, DX      \ Destination segment is held in DX
  68.                 MOV DS, BX      \ Source segment is held in BX
  69.                 MOV AX, CX      \ Save the segment count in AX
  70.                 MOV CX, # 10    \ 10 HEX is 16 decimal, ONE segment
  71.                 MOV SI, CX      \ Set source and destination offsets.
  72.                 DEC SI
  73.                 MOV DI, SI
  74.                 REPZ            \ move one 16 byte segment of LIST
  75.                 MOVSB           \ to LIST space.
  76.                 DEC DX          \ Decrement source and destination holders
  77.                 DEC BX
  78.                 MOV CX, AX      \ restore CX for LOOP instruction.
  79.         LOOP
  80.         CLD
  81.         POP DS                  \ restore DS and ES
  82.         POP ES
  83.         MOV XSEG ES             \ set XSEG to ES
  84.         MOV AX, DPSAVED         \ Move DPSAVED into DPSTART,
  85.         MOV DPSTART AX          \ for use later in setting DP
  86.         MOV AX, XDPSEGLEN
  87.         MOV XSEGLEN AX          \ Set this for later adjustment to the
  88.                                 \ absolute XSEGment value.
  89.         MOV XMOVED # -1 WORD    \ Initialize LIST to already moved. so
  90.                                 \ the normal for bootup code wil not move
  91.                                 \ the LIST again.
  92.         JMP FAR [] SUVEC        \ Jump to forth cold entry.
  93.         END-CODE
  94.  
  95. DECIMAL
  96.  
  97. HEADERS
  98.  
  99.  
  100.