home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / FPC225_2.ZIP / MISC.ZIP / DOSEDIT.SEQ next >
Encoding:
Text File  |  1988-11-03  |  3.7 KB  |  110 lines

  1. comment:
  2.  
  3.     The following is Mike Sperl's original NEW-EXPECT
  4. modified for prefix assembler.  Mike's comments follow:
  5.  
  6. ------------------------------------------------------------
  7.  
  8. This word uses dos interrupt 21h for all keyboard input except
  9. where KEY is explicitly called by another word.  It doesn't
  10. replace KEY.  It simply doesn't call KEY.  This gives PF the
  11. use of keypad and function keys on the PC and allows DOSEDIT,
  12. CED and similar programs to work within PF, thus bringing more
  13. of the power of the PC to PF.
  14.     This shouldn't interfere with any word that uses KEY.
  15. Don't try to expect to a variable, like "tag 4 expect" - only use !
  16.  
  17. NOTE: SED will work with this expect if you first open the file
  18. and then use ED to call up the editor.  The word SED in the editor
  19. will force you to exit to DOS with a CTL-C when done editing, and
  20. would be easy to modify to work properly with this expect, but I
  21. haven't found a need to do this yet.
  22.  
  23. ------------------------------------------------------------
  24.  
  25. comment;
  26.  
  27. only forth also definitions
  28.  
  29. hex
  30.  
  31. code _new-expect  ( addr +n -- )
  32.                         \ Read input via DOS buffered keyboard input
  33.     mov bx, sp
  34.     sub bx, # 0100      \ buffer 256 bytes below stack
  35.     pop ax              \ ax = count
  36.     mov 0 [bx], al      \ 1st byte buffer = chars to read
  37.     mov dx, bx          \ dx = ^buffer
  38.     mov ah, # 0A        \ buffered keyboard input
  39.     int 021             \ DOS function call
  40.     xor cx, cx          \ zero out cx
  41.     inc bx              \ bx = ^#chars read
  42.     mov cl, 0 [bx]      \ cx = #chars read
  43.     mov #) span cx      \ update SPAN
  44.                         \ Move input to where Forth wants it:
  45.     pop di              \ di = Forth address
  46.     inc bx              \ bx = ^buffer
  47.     mov dx, si          \ dx saves si
  48.     mov ax, es          \ ax saves es
  49.     mov si, bx          \ si = DOS address
  50.     mov bx, ds
  51.     mov es, bx          \ set es = ds
  52.     cld                 \ move down
  53.     repnz movsb         \ move it
  54.     mov si, dx          \ restore si
  55.     mov es, ax          \ restore es
  56.                         \ Take care of #out, #line, & spacing
  57.     mov #) #out cx      \ cx = 0 after move!
  58.     cmp #) #line # 24   \ are we on line 24?
  59. 0<> if
  60.         inc #) #line    \ no  - bump line
  61.     then
  62.     mov dl, # 0A        \ LF char
  63.     mov ah, # 02        \ character output
  64.     int 021             \ DOS function call
  65.     next    end-code
  66.  
  67. decimal
  68.  
  69. comment:        \ not needed now, as EXPECT is defered
  70.  
  71. \ Switches colon defs - can switch back as well!
  72. \ A Forth double transplant operation - takes two words and
  73. \ switches heads and bodies!!
  74.  
  75. code switch  ( cfa1 cfa2 -- )
  76.     pop bx              \ bx = cfa2
  77.     pop di              \ di = cfa1
  78.     mov ax, 3 [bx]      \ ax = value of body of cfa2
  79.     mov cx, 3 [di]      \ cx = value of body of cfa1
  80.     mov 3 [di], ax      \ cfa1 has cfa2's body
  81.     mov 3 [bx], cx      \ cfa2 has cfa1's body
  82.     next    end-code
  83.  
  84. : new-expect _new-expect ;  \ make colon def for switch
  85.  
  86. ' expect ' new-expect switch    \ now using buffered input
  87.  
  88. comment;
  89.  
  90. defer new-expect ' _new-expect is new-expect
  91.  
  92. : dos-toggle    ( --- )
  93.                 @> expect @> new-expect is expect is new-expect ;
  94.  
  95. dos-toggle      \ Enable the DOS command line editing.
  96.  
  97. \s      Slight mods by Tom Zimmer for F-PC       07/22/88 17:42:12.19
  98.  
  99.         Removed the use of GOTO labeling in line 59, replaced with the
  100.         standard PASM label mechanism to get it to compile.
  101.  
  102.         Added DOS-TOGGLE to switch back and forth.
  103.  
  104.  
  105.         11/03/88 00:21:47.50 by T. Zimmer
  106.  
  107.         Correction for the change to make EXPECT a DEFERed word.
  108.  
  109.  
  110.