home *** CD-ROM | disk | FTP | other *** search
- \\ LINDEX.SEQ Build an index of pointers to source for each target address
-
- {
-
- also forth definitions
- }
- 2variable filepointer-1 \ kept equal to filepointer
- 2variable (filepointer) \ made equal to prior filepointer
-
- variable >IN-1 \ kept equal to >IN
- variable (>IN) \ made equal to prior >IN
- {
- variable A(>IN) \ made equal to prior (>IN) by assembler
-
- 0 value ,ing \ flag =0 for ! and c! =FFFF for , and c,
- 0 value callbyte \ flag =FFFF for the first byte of a hilevel call
- 0 value firstcodebyte \ flag =FFFF for the first byte of code
- 0 value othercodebyte \ flag =FFFF for other code bytes
- }
- : ?new>in ( -- ) \ keep track of the input buffer pointer ">in"
- >in @ >in-1 @
- 2dup <> if 2dup < if (>in) off
- drop
- else
- (>in) !
- then
- >in-1 !
- else
- 2drop
- then
- filepointer 2@ filepointer-1 2@
- 4dup d= if
- 2drop 2drop
- else
- (filepointer) 2!
- filepointer-1 2!
- then
- ;
-
-
- : lin-?stack
- defers ?stack
- ?new>IN
- ;
- ' lin-?stack is ?stack
- {
-
- handle flshndl \ file handle for files file
- handle indhndl \ file handle for index file
-
- : ?indexopen ( -- f1 ) \ are indexing files open, if not make them
- \ return f1=true if symbol file is open now
- flshndl >hndle @ 0<
- if
- flshndl hcreate dup
- if 0 " Could not make files file." "errmsg2 then
- 0=
- else
- true
- then
- indhndl >hndle @ 0<
- if
- indhndl hcreate dup
- if 0 " Could not make index file." "errmsg2 then
- 0=
- else
- true
- then
- and
- ;
-
-
- variable flspoint
- variable lastseq 30 allot
-
- : newseq
- flshndl curpointer drop flspoint ! \ pointer in files file
- seqhandle dup c@ 1+ flshndl hwrite drop \ file handle to files file
- $0A0D SP@ 2 flshndl hwrite 2drop
- seqhandle count 30 min lastseq swap cmove ;
-
- : ?moreindex ( d -- d ) \ d is the double number location we want to write at
- indhndl endfile
- 4dup d> if pad $400 $ff fill
- 4dup d-
- begin pad $400 indhndl hwrite drop \ add 1k
- at?
- " I/-\" drop spinval 2/ 3 and + 1 type
- at
- incr> spinval
- $400 0 d-
- 2dup 0 0 d< until
- 2drop
- then
- 2drop
- ;
- }
- Index record format
- 0,1 flspoint @ \ pointer to source file handle in TARGET.FLS
- ,ing $8000 and or \ and flag for comma or store
- \ this flag bit =1 for the first byte of
- \ an instruction
- \ =1 for of a c,
- \ =1 for the first byte of a ,
- \ =0 otherwise
-
- 2,3,4,5 (filepointer) 2@ \ line location in source file
-
- 6 (>IN) c@ \ location in source line ( < 255 )
- 7 lbyte or \ target byte value
-
- \ 8,9 LOADLINE @ \ line number in source file
- {
-
- 0 value lbyte \ the byte that is going to the target
-
- : file&flags ( -- n ) \ source file pointer and code flags
- flspoint @ \ source file pointer
- firstcodebyte $1000 and or \ flag first byte of code instruction
- othercodebyte $2000 and or \ flag other byte of code
- callbyte $4000 and or \ flag a hilevel call
- dup $7000 and
- 0= if ,ing $8000 and or then \ flag compiled by a , or c,
- ;
-
- : LINDEX ( n a -- n a ) \ patched into target c, and ,
- \ take address, offset into .sym file
- \ take file-line and write it in.
- \ take (>in) and write it in.
-
- \ ?new>in
- ?indexopen
- if seqhandle count 30 min lastseq swap compare
- 0<> if newseq then
- dup 8 *d \ 10 *d \ location in index file
- ?moreindex \ extend if necessary
- indhndl movepointer \ move to correct location in file
- \ LOADLINE @ \ line number in source file
- firstcodebyte \ get column in source line ( < 255 )
- if A(>IN) c@
- else >in_word c@ \ (>IN) c@
- then
- lbyte or \ target byte value
-
- \ (filepointer) 2@ \ line location in source file
- filepointer 2@ outbuf c@ 0 d-
-
- file&flags \ source file pointer and code flags
- sp@ ( 10) 8 indhndl hwrite 0= if ." WERR" cr then
- 2drop 2drop \ drop
- then ;
-
- : LINDEX1 ( byte a -- byte a ) \ patched into target c, ( c!-t )
- over $100 * !> lbyte
- lindex
- off> ,ing
- ;
- : LINDEX2 ( word a -- word a ) \ patched into target , ( !-t )
- lindex1
- over $FF00 and !> lbyte
- 1+ lindex 1-
- ;
-
-
- : lxc!-t ( char taddr -- )
- lindex1
- defers c!-t
- ;
- : lx!-t ( n taddr -- )
- lindex2
- defers !-t
- ;
- : lxc,-t ( char -- )
- on> ,ing
- defers c,-t
- ;
- : lx,-t ( n -- )
- on> ,ing
- defers ,-t
- ;
-
-
- : /ind ( -- ) \ put on command line to make an index file
-
- seqhandle indhndl $>handle " IND" ">$ indhndl $>ext
- seqhandle flshndl $>handle " FLS" ">$ flshndl $>ext
-
- ['] lxc!-t is c!-t \ link defered functions to defered words
- ['] lx!-t is !-t
- ['] lxc,-t is c,-t
- ['] lx,-t is ,-t
- ;
- previous definitions
- }
-
-