home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / FPC35_5.ZIP / FPCSRC.ZIP / LOADEXE.SEQ < prev    next >
Encoding:
Text File  |  1988-11-26  |  4.6 KB  |  98 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, ' #LISTSEGS >BODY       \ and list size to get to heads
  23.         MOV ES, AX                      \ move head seg to ES
  24.         MOV CX, YDP                     \ get contents of YDP to CX
  25.         MOV SI, CX                      \ COPY it into SI
  26.         DEC SI
  27.         MOV DI, SI              \ decrement SI and move to DI
  28.                                 \ We have set up the END addresses for a move
  29.                                 \ backwards, to assure no overlap during
  30.                                 \ expansion. THIS IS VERY IMPORTANT !!
  31.         SUB AX, AX              \ Clear AX
  32.         XCHG AX, YSTART         \ Exchange AX, and YSTART clearing it
  33.         ADD AX, SUVEC 2+        \ Add to setup vector, it contains
  34.         PUSH DS                 \ save DS
  35.         MOV DS, AX              \ move AX to DS
  36.         OR CX, CX 0<>           \ if YDP was not zero (0)
  37.         IF      STD             \ moving BACKWARDS !!!
  38.                 REPZ
  39.                 MOVSB           \ move HEADS to head space
  40.                 CLD
  41.         THEN
  42.         POP DS                  \ restore DS
  43.         MOV YSEG ES             \ set YSEG to ES
  44.         MOV DX, DS                      \ move DS to AX
  45.         ADD DX, ' #CODESEGS >BODY       \ Add CODE space segments to get
  46.                                         \ to the LIST segment start.
  47.         PUSH DX                 \ Save for later use bye ES
  48.         MOV CX, XDPSEGLEN       \ get contents of XSEGLEN which is the LENGTH
  49.                                 \ of move in SEGMENTS.
  50.  
  51.         MOV BX, DPSTART         \ mov LIST offset segment to BX
  52.                                 \ DPSTART in SAVEEXE holds the segment offset
  53.                                 \ from CS to where LIST section starts.
  54.         ADD BX, SUVEC 2+        \ Add this to the setup vector which holds
  55.                                 \ the current value of CS. The result is the
  56.                                 \ absolute segment address of start of LIST.
  57.         ADD BX, CX              \ Adjust source to end of move, will be
  58.         DEC BX                  \ plugged into DS later.
  59.         ADD DX, CX              \ Bump destination segment to end of move
  60.         DEC DX                  \ We are moving BACKWARDS to avoid any
  61.                                 \ possibility of an overlay.
  62.         PUSH DS                 \ save DS for later restoral
  63.         STD                     \ Yes we are moving BACKWARDS.
  64.         HERE
  65.                 MOV ES, DX      \ Destination segment is held in DX
  66.                 MOV DS, BX      \ Source segment is held in BX
  67.                 MOV AX, CX      \ Save the segment count in AX
  68.                 MOV CX, # 10    \ 10 HEX is 16 decimal, ONE segment
  69.                 MOV SI, CX      \ Set source and destination offsets.
  70.                 DEC SI
  71.                 MOV DI, SI
  72.                 REPZ            \ move one 16 byte segment of LIST
  73.                 MOVSB           \ to LIST space.
  74.                 DEC DX          \ Decrement source and destination holders
  75.                 DEC BX
  76.                 MOV CX, AX      \ restore CX for LOOP instruction.
  77.         LOOPNZ
  78.         CLD
  79.         POP DS                  \ restore DS and ES
  80.         POP ES
  81.         MOV XSEG ES             \ set XSEG to ES
  82.         MOV AX, DPSAVED         \ Move DPSAVED into DPSTART,
  83.         MOV DPSTART AX          \ for use later in setting DP
  84.         MOV AX, XDPSEGLEN
  85.         MOV XSEGLEN AX          \ Set this for later adjustment to the
  86.                                 \ absolute XSEGment value.
  87.         MOV XMOVED # -1 WORD    \ Initialize LIST to already moved. so
  88.                                 \ the normal for bootup code wil not move
  89.                                 \ the LIST again.
  90.         JMP FAR [] SUVEC        \ Jump to forth cold entry.
  91.         END-CODE
  92.  
  93. DECIMAL
  94.  
  95. HEADERS
  96.  
  97.  
  98.