Category : Forth Source Code
Archive   : SMILY46B.ZIP
Filename : DOSEDIT.SEQ

 
Output of file : DOSEDIT.SEQ contained in archive : SMILY46B.ZIP
comment:
\ Fixed cmp #) #line # $18 \ are we on line 24? 22Feb89

The following is Mike Sperl's original NEW-EXPECT
modified for prefix assembler. Mike's comments follow:

------------------------------------------------------------

This word uses dos interrupt 21h for all keyboard input except
where KEY is explicitly called by another word. It doesn't
replace KEY. It simply doesn't call KEY. This gives PF the
use of keypad and function keys on the PC and allows DOSEDIT,
CED and similar programs to work within PF, thus bringing more
of the power of the PC to PF.
This shouldn't interfere with any word that uses KEY.
Don't try to expect to a variable, like "tag 4 expect" - only use !

NOTE: SED will work with this expect if you first open the file
and then use ED to call up the editor. The word SED in the editor
will force you to exit to DOS with a CTL-C when done editing, and
would be easy to modify to work properly with this expect, but I
haven't found a need to do this yet.

------------------------------------------------------------

comment;

only forth also definitions

\ Read input via DOS buffered keyboard input
CODE NEW-EXPECT ( addr +n -- ) \ mps
MOV BX, SP
SUB BX, # $100 \ buffer 256 bytes below stack
POP AX \ ax = count
MOV 0 [BX], AL \ 1st byte buffer = chars to read
MOV DX, BX \ dx = ^buffer
MOV AH, # $A \ buffered keyboard input
INT $21 \ DOS function call
XOR CX, CX \ zero cx
INC BX \ bx = ^#chars read
MOV CL, 0 [BX] \ cx = #chars read
MOV #) SPAN CX \ update SPAN
\ Move input to where Forth wants it:
POP DI \ di = Forth address
INC BX \ bx = ^buffer
MOV DX, SI \ dx saves si
MOV AX, ES \ ax saves es
MOV SI, BX \ si = DOS address
MOV BX, DS
MOV ES, BX \ set es = ds
\ cld \ move down, the default!
REPNZ MOVSB \ move it
MOV SI, DX \ restore si
MOV ES, AX \ restore es
\ Take care of #out, #line, & spacing
MOV #) #OUT CX \ cx = 0 after move!
CMP #) #LINE # 24 \ are we on line 24?
0<> IF
INC #) #LINE \ no - bump line
THEN
MOV DL, # $A \ LF char
MOV AH, # 2 \ character output
INT $21 \ DOS function call
ES: LODSW \ next
JMP AX
END-CODE

\ Get a string from the terminal and place it in the buffer provided.
\ DEFER EXPECT
' NEW-EXPECT IS EXPECT

comment: \ not needed now, as EXPECT is defered

\ Switches colon defs - can switch back as well!
\ A Forth double transplant operation - takes two words and
\ switches heads and bodies!!

code switch ( cfa1 cfa2 -- )
pop bx \ bx = cfa2
pop di \ di = cfa1
mov ax, 3 [bx] \ ax = value of body of cfa2
mov cx, 3 [di] \ cx = value of body of cfa1
mov 3 [di], ax \ cfa1 has cfa2's body
mov 3 [bx], cx \ cfa2 has cfa1's body
next end-code

: new-expect _new-expect ; \ make colon def for switch

' expect ' new-expect switch \ now using buffered input

comment;

comment:

defer new-expect ' _new-expect is new-expect

: dos-toggle ( --- )
@> expect @> new-expect is expect is new-expect ;

dos-toggle \ Enable the DOS command line editing.

\s Slight mods by Tom Zimmer for F-PC 07/22/88 17:42:12.19

Removed the use of GOTO labeling in line 59, replaced with the
standard PASM label mechanism to get it to compile.

Added DOS-TOGGLE to switch back and forth.


11/03/88 00:21:47.50 by T. Zimmer

Correction for the change to make EXPECT a DEFERed word.

comment;



  3 Responses to “Category : Forth Source Code
Archive   : SMILY46B.ZIP
Filename : DOSEDIT.SEQ

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/