compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth 
Author Message
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth

Hi everyone !

I am trying to get
ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
running on win32forth
I modified it to work without blocks ( without +thru)
but i am missing the following words
2+        i defined it : 2+ 2 + ; is this right ?
2-        i defined it : 2- 2 - ; is this right ?
LENGTH    I dont know how to define it

How is LENGTH defined ???? (am i to stupid ???)

__
my modified source: (of basic.txt)

: 2+ 2 + ;
: 2- 2 - ;

ONLY FORTH ALSO DEFINITIONS

VOCABULARY ARITHMETIC   ARITHMETIC ALSO DEFINITIONS
VOCABULARY LOGIC   VOCABULARY INPUTS   VOCABULARY OUTPUTS
: [   ASCII ] WORD DROP ;  IMMEDIATE
: GET   BL WORD NUMBER DROP  ;
CREATE #S  130 ALLOT
FORTH DEFINITIONS

\ Precedence                                          06Feb84map
VARIABLE ADDRESS   VARIABLE #(


   BEGIN  2OVER NIP OVER  >= WHILE   2SWAP DROP  ,  REPEAT ;




: NOTHING  ;
: START ( - n)   0 #( !  0 ADDRESS !  ['] NOTHING 0
   ARITHMETIC  ;

\ Variables                                           06Feb84map
: INTEGER   VARIABLE  IMMEDIATE  DOES>  [COMPILE] LITERAL

: (ARRAY) ( a a)  SWAP >R   7 DEFER  R> [COMPILE] LITERAL

: [+] ( a i - a)   1- 2* + ;
: ARRAY   INTEGER  1- 2* ALLOT   DOES>  ['] [+] (ARRAY) ;


: 2ARRAY ( y x)   DUP CONSTANT  IMMEDIATE  * 2* ALLOT
   DOES>  ['] [*+] (ARRAY) ;

: BASIC  [ ARITHMETIC ]  0 #S 2+ #S 2!  START ALSO ; IMMEDIATE
ARITHMETIC DEFINITIONS

\ Statement numbers  ( works at any address )         06Feb84map






: CHAIN ( n - a)   FIND  LENGTH 0<


   R> RESOLVE  START ;

\ Branching - high level                              13Mar84map



: SKIP   0= IF  R> 4 + >R  THEN ;
: (NEXT)

   0< IF  SWAP  THEN -

: [1]      COMPILE 1  HERE ;
: [NEXT]   COMPILE (NEXT) , ;
: (GOTO)   GET  COMPILE JUMP  CHAIN , ;
: (RET)    R> DROP ;

\ BASIC                                               19Jul84map
: LET   STATEMENT  ADDRESS ON ; IMMEDIATE
: FOR   [COMPILE] LET ;  IMMEDIATE
: TO    RPN DROP  ['] [1] 0 ;  IMMEDIATE
: STEP  RPN DROP  ['] HERE 0 ;  IMMEDIATE
: NEXT  STATEMENT 2DROP ['] [NEXT] 0   ADDRESS ON ; IMMEDIATE
: REM   STATEMENT  [COMPILE] \  ; IMMEDIATE
: DIM   [COMPILE] REM ; IMMEDIATE
: STOP  STATEMENT  COMPILE (RET) ; IMMEDIATE
: END   STATEMENT 2DROP [COMPILE] ; PREVIOUS FORTH ; IMMEDIATE
: GOTO   STATEMENT  (GOTO) ;  IMMEDIATE
: IF     STATEMENT  LOGIC ;  IMMEDIATE
: THEN   RPN 0  COMPILE SKIP  (GOTO) ; IMMEDIATE
: RETURN   STATEMENT  COMPILE (RET)  ; IMMEDIATE
: GOSUB  STATEMENT  GET  COMPILE CALL  CHAIN ,  ; IMMEDIATE

\ Input and Output                                    06Feb84map
: ASK   ." ? "  QUERY ;
: PUT   GET  SWAP ! ;
: (INPUT)   COMPILE PUT ;
: (,) ( n)   (.)  14 OVER - SPACES  TYPE SPACE ;
OUTPUTS DEFINITIONS
: , ( n)   ?IGNORE  ['] (,)  1 DEFER  ;  IMMEDIATE
: "   [COMPILE] ."  2DROP ;  IMMEDIATE
INPUTS DEFINITIONS
: ,   ?IGNORE  RPN 0  (INPUT)  ADDRESS ON ;  IMMEDIATE

ARITHMETIC DEFINITIONS
: PRINT   STATEMENT  COMPILE CR  ['] (,) 1 OUTPUTS ; IMMEDIATE
: INPUT   STATEMENT  2DROP  COMPILE ASK  ['] (INPUT) 0  INPUTS
   ADDRESS ON ;  IMMEDIATE

\ Operators                                           06Feb84map
LOGIC DEFINITIONS
2 PRECEDENCE <>   2 PRECEDENCE <=   2 PRECEDENCE >=
2 PRECEDENCE =    2 PRECEDENCE <    2 PRECEDENCE >

ARITHMETIC DEFINITIONS
: = ( a n)   SWAP ! ;   1 PRECEDENCE =
: ** ( n n - n)   1  SWAP 1 DO  OVER * LOOP  * ;
6 PRECEDENCE ABS
5 PRECEDENCE **
4 PRECEDENCE *   4 PRECEDENCE /   4 PRECEDENCE */
3 PRECEDENCE +   3 PRECEDENCE -

: (   10 #( +! ;  IMMEDIATE
: ;   [ n]   . ;   1 PRECEDENCE ;

FORTH DEFINITIONS



Wed, 19 Nov 2003 23:01:20 GMT  
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth

Quote:
> Hi everyone !

> I am trying to get
> ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
> running on win32forth
> I modified it to work without blocks ( without +thru)
> but i am missing the following words

That's an appreciably ugly bit of code to try to port.  I did a Tiny BASIC
in Forth for Quartus Forth -- available in the File Area at
<http://www.quartus.net> -- it's BNF based, and hopefully clearer than the
antique code you're looking at.

--
Neal Bridges
<http://www.quartus.net> Quartus Handheld Software!



Thu, 20 Nov 2003 04:39:40 GMT  
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth



Quote:


> > Hi everyone !

> > I am trying to get
> > ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
> > running on win32forth
> > I modified it to work without blocks ( without +thru)
> > but i am missing the following words

> That's an appreciably ugly bit of code to try to port.  I did a Tiny BASIC
> in Forth for Quartus Forth -- available in the File Area at
> <http://www.quartus.net> -- it's BNF based, and hopefully clearer than the
> antique code you're looking at.

> --
> Neal Bridges
> <http://www.quartus.net> Quartus Handheld Software!

Does your Basic handle constructs like:
integer x
: mybasicproc BASIC
10 print x
20 print " hello"
30 let x = x + 1
40 goto 10
50 end

wich creates a word called mybasicproc
like the antique source ?

cu
l8r



Thu, 20 Nov 2003 05:51:19 GMT  
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth

Quote:




> > > Hi everyone !

> > > I am trying to get
> > > ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
> > > running on win32forth
> > > I modified it to work without blocks ( without +thru)
> > > but i am missing the following words

> > That's an appreciably ugly bit of code to try to port.  I did a Tiny
BASIC
> > in Forth for Quartus Forth -- available in the File Area at
> > <http://www.quartus.net> -- it's BNF based, and hopefully clearer than
the
> > antique code you're looking at.

> Does your Basic handle constructs like:
> integer x
> : mybasicproc BASIC
> 10 print x
> 20 print " hello"
> 30 let x = x + 1
> 40 goto 10
> 50 end

> wich creates a word called mybasicproc
> like the antique source ?

It's got LET, PRINT, and INPUT.  No line numbers.  Here's the equivalent to
your example:

needs basic
variable x

: mybasicproc
  begin
    print x
    print "hello"
    let x=x+1
  again
;

The BASIC commands also work at the console, and there's a debug mode that
shows exactly what the commands translate to in Forth.

--
Neal Bridges
<http://www.quartus.net> Quartus Handheld Software!



Thu, 20 Nov 2003 06:51:35 GMT  
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth

Quote:

>Hi everyone !

>I am trying to get
>ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
>running on win32forth
>I modified it to work without blocks ( without +thru)
>but i am missing the following words
>2+        i defined it : 2+ 2 + ; is this right ?
>2-        i defined it : 2- 2 - ; is this right ?

Not as simple as that I'm sorry to say. The code has been written for a
16-bit Forth and most, but not necessarily all, occurrences of  2+  and  2-
are operating on addresses to increase or decrease them by one cell (which
is 4 bytes rather than 2 on Win32Forth). To get this to work on Win32Forth
you'll need to change these occurrences to  CELL+  and  CELL-  respectively.
Similarly you'll need to change most, but not necessarily all, occurrences
of  2*  to  CELLS  and  4  to  2 CELLS  and so on. You'll have to read and
understand what is going on in each definition to discover which bits need
changing. Check everything that involves an even number.
CREATE #S  130 ALLOT
should probably be changed to:
CREATE #S  65 CELLS ALLOT

Quote:
>LENGTH    I dont know how to define it

Those look like Michael Perry's initials on the date stamps so I would guess
this was written for F83 where  LENGTH  is defined as a cell-wide version of
COUNT . The equivalent word in Win32Forth is  LCOUNT .

Regards,
Philip.

Quote:

>How is LENGTH defined ???? (am i to stupid ???)

>__
>my modified source: (of basic.txt)

>: 2+ 2 + ;
>: 2- 2 - ;

>ONLY FORTH ALSO DEFINITIONS

>VOCABULARY ARITHMETIC   ARITHMETIC ALSO DEFINITIONS
>VOCABULARY LOGIC   VOCABULARY INPUTS   VOCABULARY OUTPUTS
>: [   ASCII ] WORD DROP ;  IMMEDIATE
>: GET   BL WORD NUMBER DROP  ;
>CREATE #S  130 ALLOT
>FORTH DEFINITIONS

>\ Precedence                                          06Feb84map
>VARIABLE ADDRESS   VARIABLE #(


>   BEGIN  2OVER NIP OVER  >= WHILE   2SWAP DROP  ,  REPEAT ;




>: NOTHING  ;
>: START ( - n)   0 #( !  0 ADDRESS !  ['] NOTHING 0
>   ARITHMETIC  ;

>\ Variables                                           06Feb84map
>: INTEGER   VARIABLE  IMMEDIATE  DOES>  [COMPILE] LITERAL

>: (ARRAY) ( a a)  SWAP >R   7 DEFER  R> [COMPILE] LITERAL

>: [+] ( a i - a)   1- 2* + ;
>: ARRAY   INTEGER  1- 2* ALLOT   DOES>  ['] [+] (ARRAY) ;


>: 2ARRAY ( y x)   DUP CONSTANT  IMMEDIATE  * 2* ALLOT
>   DOES>  ['] [*+] (ARRAY) ;

>: BASIC  [ ARITHMETIC ]  0 #S 2+ #S 2!  START ALSO ; IMMEDIATE
>ARITHMETIC DEFINITIONS

>\ Statement numbers  ( works at any address )         06Feb84map






>: CHAIN ( n - a)   FIND  LENGTH 0<


>   R> RESOLVE  START ;

>\ Branching - high level                              13Mar84map



>: SKIP   0= IF  R> 4 + >R  THEN ;
>: (NEXT)

>   0< IF  SWAP  THEN -

>: [1]      COMPILE 1  HERE ;
>: [NEXT]   COMPILE (NEXT) , ;
>: (GOTO)   GET  COMPILE JUMP  CHAIN , ;
>: (RET)    R> DROP ;

>\ BASIC                                               19Jul84map
>: LET   STATEMENT  ADDRESS ON ; IMMEDIATE
>: FOR   [COMPILE] LET ;  IMMEDIATE
>: TO    RPN DROP  ['] [1] 0 ;  IMMEDIATE
>: STEP  RPN DROP  ['] HERE 0 ;  IMMEDIATE
>: NEXT  STATEMENT 2DROP ['] [NEXT] 0   ADDRESS ON ; IMMEDIATE
>: REM   STATEMENT  [COMPILE] \  ; IMMEDIATE
>: DIM   [COMPILE] REM ; IMMEDIATE
>: STOP  STATEMENT  COMPILE (RET) ; IMMEDIATE
>: END   STATEMENT 2DROP [COMPILE] ; PREVIOUS FORTH ; IMMEDIATE
>: GOTO   STATEMENT  (GOTO) ;  IMMEDIATE
>: IF     STATEMENT  LOGIC ;  IMMEDIATE
>: THEN   RPN 0  COMPILE SKIP  (GOTO) ; IMMEDIATE
>: RETURN   STATEMENT  COMPILE (RET)  ; IMMEDIATE
>: GOSUB  STATEMENT  GET  COMPILE CALL  CHAIN ,  ; IMMEDIATE

>\ Input and Output                                    06Feb84map
>: ASK   ." ? "  QUERY ;
>: PUT   GET  SWAP ! ;
>: (INPUT)   COMPILE PUT ;
>: (,) ( n)   (.)  14 OVER - SPACES  TYPE SPACE ;
>OUTPUTS DEFINITIONS
>: , ( n)   ?IGNORE  ['] (,)  1 DEFER  ;  IMMEDIATE
>: "   [COMPILE] ."  2DROP ;  IMMEDIATE
>INPUTS DEFINITIONS
>: ,   ?IGNORE  RPN 0  (INPUT)  ADDRESS ON ;  IMMEDIATE

>ARITHMETIC DEFINITIONS
>: PRINT   STATEMENT  COMPILE CR  ['] (,) 1 OUTPUTS ; IMMEDIATE
>: INPUT   STATEMENT  2DROP  COMPILE ASK  ['] (INPUT) 0  INPUTS
>   ADDRESS ON ;  IMMEDIATE

>\ Operators                                           06Feb84map
>LOGIC DEFINITIONS
>2 PRECEDENCE <>   2 PRECEDENCE <=   2 PRECEDENCE >=
>2 PRECEDENCE =    2 PRECEDENCE <    2 PRECEDENCE >

>ARITHMETIC DEFINITIONS
>: = ( a n)   SWAP ! ;   1 PRECEDENCE =
>: ** ( n n - n)   1  SWAP 1 DO  OVER * LOOP  * ;
>6 PRECEDENCE ABS
>5 PRECEDENCE **
>4 PRECEDENCE *   4 PRECEDENCE /   4 PRECEDENCE */
>3 PRECEDENCE +   3 PRECEDENCE -

>: (   10 #( +! ;  IMMEDIATE
>: ;   [ n]   . ;   1 PRECEDENCE ;

>FORTH DEFINITIONS



Thu, 20 Nov 2003 07:36:43 GMT  
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth

Quote:






>> > > Hi everyone !

>> > > I am trying to get
>> > > ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
>> > > running on win32forth
>> > > I modified it to work without blocks ( without +thru)
>> > > but i am missing the following words

>> > That's an appreciably ugly bit of code to try to port.  I did a Tiny
>BASIC
>> > in Forth for Quartus Forth -- available in the File Area at
>> > <http://www.quartus.net> -- it's BNF based, and hopefully clearer than
>the
>> > antique code you're looking at.

>> Does your Basic handle constructs like:
>> integer x
>> : mybasicproc BASIC
>> 10 print x
>> 20 print " hello"
>> 30 let x = x + 1
>> 40 goto 10
>> 50 end

>> wich creates a word called mybasicproc
>> like the antique source ?

>It's got LET, PRINT, and INPUT.  No line numbers.  Here's the equivalent to
>your example:

>needs basic
>variable x

>: mybasicproc
>  begin
>    print x
>    print "hello"
>    let x=x+1
>  again
>;

>The BASIC commands also work at the console, and there's a debug mode that
>shows exactly what the commands translate to in Forth.

You ought to call it "Forthscript" ;o)

Rick Hohensee

- Show quoted text -

Quote:
>--
>Neal Bridges
><http://www.quartus.net> Quartus Handheld Software!



Thu, 20 Nov 2003 09:14:34 GMT  
 compiling ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt with win32forth



Quote:

> >Hi everyone !

> >I am trying to get
> >ftp.dei.isep.ipp.pt/pub/forth/various/basic.txt
> >running on win32forth
> Not as simple as that I'm sorry to say. The code has been written for a
> 16-bit Forth and most, but not necessarily all, occurrences of  2+  and
2-
> are operating on addresses to increase or decrease them by one cell (which
> is 4 bytes rather than 2 on Win32Forth). To get this to work on Win32Forth
> you'll need to change these occurrences to  CELL+  and  CELL-
respectively.
> Similarly you'll need to change most, but not necessarily all, occurrences
> of  2*  to  CELLS  and  4  to  2 CELLS  and so on. You'll have to read and
> understand what is going on in each definition to discover which bits need
> changing. Check everything that involves an even number.
> CREATE #S  130 ALLOT
> should probably be changed to:
> CREATE #S  65 CELLS ALLOT

> >LENGTH    I dont know how to define it

> Those look like Michael Perry's initials on the date stamps so I would
guess
> this was written for F83 where  LENGTH  is defined as a cell-wide version
of
> COUNT . The equivalent word in Win32Forth is  LCOUNT .

> Regards,
> Philip.

Thanks ! Managed to port it !!!!
only had to add the stuff you told me and rel>abs and abs>rel in jump and
gosub

cu



Fri, 21 Nov 2003 00:48:19 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Squeak FTP site established: ftp://ftp.create.ucsb.edu/pub/Smalltalk/Squeak

2. My ftp site (ftp://ftp.iag.net/pub/clipper)

3. ftp.demon.co.uk/pub/ibmpc/win3/apps/vo

4. ftp.iag.net/pub/clipper/patch/ca_clipper_mirror directory

5. VO - Latest uploads to VO ftp site at ftp.demon.co.uk/pub/ibmpc/win3/apps/vo

6. /pub/ETHOberon/Macintosh/beta010806/

7. asterix.inescn.pt FTP site useable?

8. asterix.inescn.pt FTP site useable?

9. compiling BASIC to forth

10. New stuff in /pub/Oberon/Tools on ftp.inf.ethz.ch

11. Pt 3/6: FAQ: Lisp FTP Resources 6/7 [Monthly posting]

12. Help please: various positioninterpolator-type-things

 

 
Powered by phpBB® Forum Software