home .. forth .. colorforth mail list archive ..

[colorforth] NASM for colorforth


Hello John

On 09-Jul-02, you wrote:

> Hello Martin,
> 
> I'm familair with blocks.  I've used them since back
> in the Forth-79 days.  And Enth/Flux uses blocks
> also.  But Enth/Flux uses a different underlying
> coding scheme.  If I write code in Enth/Flux I'd
> like to be able to move my code over to ColorForth
> and recompile.  That's all I'm saying.  Maybe I'll
> just write what I need myself.
> 
> Regards,
> 
> John M. Drakendex.htm
> 

This may, or may not, be useful then.

It was written by Phil for JForth on the Amiga, but ignoring the Amiga
specific parts, it may be useful for analysis.

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

\ BLOCK2TEXT
\
\ Convert a Forth style BLOCK file to a normal text file.
\
\ Author: Phil Burk
\ Copyright 1991 Phil Burk

ANEW TASK-BLOCK2TEXT

\ hold file pointers
VARIABLE B2T-INFILE
VARIABLE B2T-OUTFILE

: B2T.NEXT  ( -- 0 | 1 | -1 , process next line in file )
    b2t-infile @ pad 64 fread 64 =
    IF
        b2t-outfile @
        pad 64 -trailing  \ remove trailing blanks
        dup>r
        fwrite
        r> =
        IF
            EOL pad c!  \ write line terminator
            b2t-outfile @
            pad 1
            fwrite
            1 = not
        ELSE
            true
        THEN
        \ -1 if error
    ELSE
        1 \ done
    THEN
;

: B2T.LOOP ( -- , loop through file )
    BEGIN
        b2t.next
        dup 0<
        IF
            ." B2T - Error writing file!" cr
        THEN
    UNTIL
;

: B2T.CLOSE ( -- , close both files )
    b2t-infile @ ?dup
    IF fclose b2t-infile off
    THEN
    b2t-outfile @ ?dup
    IF fclose b2t-outfile off
    THEN
;

: B2T.ERROR ( -- )
    ." Usage:  BLOCK2TEXT infile outfile" cr
    ."   INFILE  = file of Forth blocks" cr
    ."   OUTFILE = normal text file" cr
    b2t.close
;

: BLOCK2TEXT ( <infile> <outfile> -- )
    >newline
    ." Block2Text  by Phil Burk, written in JForth" cr
    fopen ?dup
    IF
        b2t-infile !
        new fopen ?dup
        IF
            b2t-outfile !
            b2t.loop
            ." File conversion complete." cr
        ELSE
            ." Could not open OUTPUT file!" cr
            b2t.error
        THEN
    ELSE
        ." Could not open INPUT file!" cr
        b2t.error
    THEN
    b2t.close
;

----------------------------
Regards...Martin
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com
Wiki page http://kristopherjohnson.net/wiki/ColorForth
ColorForth index http://www.users.qwest.net/~loveall/c4index.htm