Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #43752

Emulating a 16-bit Forth

From Lars Brinkhoff <lars.spam@nocrew.org>
Newsgroups comp.lang.forth
Subject Emulating a 16-bit Forth
Organization nocrew
References (16 earlier) <n1p8g9$5t1$1@dont-email.me> <87a8qnu5g7.fsf@nightsong.com> <56408caf.141582139@news.eternal-september.org> <86twobwzqi.fsf@vps34351.public.cloudvps.com> <86egffwl44.fsf@vps34351.public.cloudvps.com>
Date 2015-11-25 13:18 +0100
Message-ID <86k2p6uval.fsf_-_@vps34351.public.cloudvps.com> (permalink)

Show all headers | View raw


>>>>> Immediate inspiration: I'm interested in running an app (not yet
>>>>> written) on a TI MSP430, that uses a 16 bit CPU.  I'd prefer to
>>>>> write and debug the computational part of the app on a Linux box
>>>>> for greater convenience.  Right now there doesn't seem to be any
>>>>> 16-bit Forth for Linux.
>>>>
>>>> Item 2 [a 16-bit Forth] is easy to do with a new vocabulary or word
>>>> list.
>>>
>>> How would you easily implement @ in this vocabulary?
>>
>> If we are emulating a 16 bit CPU, then declare a 64k buffer and index
>> into it. To allow for 16 bit access, assume that the 32 bit host has
>> a word W@ ( addr -- x16 ).
>>
>> 64 kb buffer: vmem
>>
>> ...
>>
>> : @  ( addr16 -- x16 )
>>   $FFFF and vmem + w@ 
>> ;
>
> The purpuse was to emulate a 16-bit Forth with a new vocabulary.  So
> if we go down this route, I guess we'd have to redefine VARIABLE etc
> too to allocate data space inside this buffer.
>
> We still want to tick colon definitions and use EXECUTE and DEFER etc.

So maybe something like this?  It's kind of like a cross compiler for a
16-bit target, except the code lives in the host.



only forth definitions

vocabulary forth16

65536 constant #data
create data  #data allot
variable dp  0 dp !

: mask   65535 and ;
: ?addr   dup -65536 and abort" Not a 16-bit address!" ;
: >host   ?addr data + ;
: mask:   >in @ >r : r> >in !  ' compile, postpone mask postpone ; ;

: h:   : ;
: h;   postpone ; ; immediate

also forth16 definitions

\ Add lots of these...
mask: +  mask: -  mask: *  mask: /

: here   dp @ ;
: allot   dp +! ;

: execute   >host @ execute ;
: does   does> @ execute ;
: :   create here dup ,  1 cells allot  does  :noname ;
h: ;   postpone ; swap >host ! ; immediate

h: create   create here ,  does> @ h;
h: variable   create 2 allot h;

h: '   ' >body @ h;
h: >body h;

h: c@   >host c@ h;
h: c!   >host c! h;

\ Little endian versions.
h: @   dup c@  swap 1+ c@ 8 lshift + h;
h: !   2dup c!  swap 8 rshift swap  1+ c! h;

h: c,   here c!  1 allot h;
h: ,   here !  2 allot ;

only forth definitions

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 09:04 -0700
  Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 09:18 -0700
    Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-28 12:35 -0400
      Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 09:54 -0700
        Re: Stoked lehs <skydda.barnen@gmail.com> - 2015-10-28 10:35 -0700
        Re: Stoked Jason Damisch <jasondamisch@yahoo.com> - 2015-10-28 11:21 -0700
        Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-28 14:24 -0400
          Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 13:12 -0700
            Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-28 16:31 -0400
          Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 14:55 -0700
            Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-29 01:36 -0400
          Re: Stoked Alfred Singlestone <vitonis@gmail.com> - 2015-10-30 06:01 -0700
            Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-30 13:22 -0400
          Re: Stoked Marcos Cruz <use_the_contact_page@programandala.net> - 2015-11-07 17:50 +0000
            Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-07 13:04 -0500
              Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-07 10:19 -0800
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 08:29 -1000
                Re: Stoked hughaguilar96@gmail.com - 2015-11-07 13:28 -0800
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-07 13:33 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-07 16:40 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-07 14:25 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-07 18:03 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-07 15:22 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 01:13 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-07 22:35 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 01:58 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-07 23:17 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 02:49 -0500
                Re: Stoked Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-08 00:06 -0800
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 01:40 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 15:18 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 13:31 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 17:19 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-11 20:49 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-12 00:57 -0500
                Re: Stoked hughaguilar96@gmail.com - 2015-11-11 22:24 -0800
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-11 23:34 -0800
                Re: Stoked Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-12 00:03 -0800
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-12 19:37 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-12 15:24 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-12 13:18 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-12 16:40 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-12 20:59 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-13 01:50 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-12 23:11 -0800
                Re: Stoked forthisit@gmail.com - 2015-11-12 13:47 -0800
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-12 16:27 -0800
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-12 12:18 -1000
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-13 00:28 -0800
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-11 22:37 -1000
                Re: Stoked hughaguilar96@gmail.com - 2015-11-12 23:37 -0800
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-09 14:19 +0000
                Re: Stoked Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-23 07:47 +0100
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-23 11:27 +0000
                Re: Stoked Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-23 13:43 +0100
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-08 12:49 -1000
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 19:20 -0500
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 23:44 -1000
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-08 18:23 +0000
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 10:32 -0800
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-08 18:45 +0000
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 10:53 -0800
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-08 21:25 +0000
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 14:09 -0800
                Re: Stoked "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-11-09 05:32 -0500
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-09 14:58 +0000
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 23:42 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 21:11 -0800
                Re: Stoked Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-15 12:50 +0100
                Re: Stoked Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-07 23:56 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 03:24 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 01:31 -0800
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 23:57 -1000
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 02:18 -0800
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-08 08:33 -1000
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-09 00:07 -0500
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-08 23:49 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 21:06 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-09 00:20 -0500
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-08 22:51 -0800
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-09 02:22 -0500
                Re: Stoked Alfred Singlestone <vitonis@gmail.com> - 2015-11-10 04:32 -0800
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-10 13:48 +0000
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-10 16:17 -0500
                Re: Stoked "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-11-10 17:26 -0500
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-08 21:50 -1000
                Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-11-09 12:15 +0000
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-09 15:09 +0000
                Re: Stoked Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-24 09:47 +0100
                Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-11-24 12:54 +0000
                Re: Stoked Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-24 15:03 +0100
                Emulating a 16-bit Forth Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-25 13:18 +0100
                Re: Emulating a 16-bit Forth Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-25 14:08 +0100
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-09 14:30 +0000
                Re: Stoked Bernd Linsel <bl1@gmx.com> - 2015-11-09 18:27 +0100
                Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-10 00:50 -0800
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 23:52 -1000
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 23:16 -1000
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 23:07 -1000
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-08 17:58 +0000
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-11-07 12:00 -1000
                Re: Stoked Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-08 17:49 +0000
        Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-10-28 23:24 +0000
          Re: Stoked Jason Damisch <jasondamisch@yahoo.com> - 2015-10-28 17:30 -0700
          Re: Stoked Waldek Hebisch <hebisch@antispam.uni.wroc.pl> - 2015-10-29 02:40 +0000
            Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-10-29 10:11 +0000
          Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 21:07 -0700
            Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-10-28 21:16 -0700
            Re: Stoked franck.bensusan@gmail.com - 2015-10-29 01:35 -0700
            Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-10-29 10:16 +0000
              Re: Stoked lehs <skydda.barnen@gmail.com> - 2015-10-29 03:35 -0700
                Re: Stoked lehs <skydda.barnen@gmail.com> - 2015-10-29 03:48 -0700
          Re: Stoked mhx@iae.nl - 2015-10-29 11:31 -0700
            Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-29 12:01 -0700
              Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-10-29 12:26 -0700
            Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-29 15:29 -0400
              Re: Stoked mhx@iae.nl - 2015-10-29 13:27 -0700
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-29 16:48 -0400
                Re: Stoked josv@planet.nl - 2015-10-29 14:58 -0700
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-30 01:36 -0400
                Re: Stoked josv@planet.nl - 2015-10-30 04:34 -0700
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-30 13:28 -0400
                Re: Stoked josv@planet.nl - 2015-10-30 12:05 -0700
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-30 15:32 -0400
                Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-10-30 18:53 -1000
                Re: Stoked josv@planet.nl - 2015-11-01 04:28 -0800
                Re: Stoked hughaguilar96@gmail.com - 2015-11-03 22:27 -0800
                Re: Stoked mhx@iae.nl - 2015-10-29 16:47 -0700
                Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-30 01:33 -0400
                Re: Stoked mhx@iae.nl - 2015-10-31 00:55 -0700
                Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-10-30 11:52 +0000
              Re: Stoked josv@planet.nl - 2015-10-29 14:49 -0700
              Re: Stoked stephen@mpeforth.com (Stephen Pelc) - 2015-10-30 11:50 +0000
    Re: Stoked Hans Bezemer <the.beez.speaks@gmail.com> - 2015-10-28 18:39 +0100
      Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 11:11 -0700
        Re: Stoked Hans Bezemer <the.beez.speaks@gmail.com> - 2015-10-28 20:01 +0100
        Re: Stoked hughaguilar96@gmail.com - 2015-10-28 12:34 -0700
          Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 13:09 -0700
    Re: Stoked François <francois.ganza@wanadoo.fr> - 2015-10-28 15:25 -0700
      Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 21:01 -0700
        Re: Stoked "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-10-29 01:58 -0400
          Re: Stoked Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-10-28 23:34 -0700
        Re: Stoked Lars Brinkhoff <lars.spam@nocrew.org> - 2015-10-29 08:56 +0100
    Re: Stoked "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-10-28 18:41 -0400
      Re: Stoked josv@planet.nl - 2015-10-29 05:28 -0700
      Re: Stoked "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-12-12 11:25 -0500
        Re: Stoked "Elizabeth D. Rather" <erather@forth.com> - 2015-12-12 08:43 -1000
          Re: Stoked hughaguilar96@gmail.com - 2015-12-16 13:45 -0800
            Re: Stoked hughaguilar96@gmail.com - 2015-12-17 10:26 -0800
        Re: Stoked Rob Sciuk <rob@controlq.com> - 2015-12-13 23:29 -0500
          Re: Stoked Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-12-13 22:31 -0800
    Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-10-28 15:52 -0700
      Re: Stoked anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-29 16:57 +0000
        Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-10-29 12:36 -0700
          Re: Stoked anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-31 14:57 +0000
            Re: Stoked Bernd Paysan <bernd.paysan@gmx.de> - 2015-10-31 20:25 +0100
        Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-11-03 20:39 -0800
    Re: Stoked Pablo Hugo Reda <pabloreda@gmail.com> - 2015-10-28 16:27 -0700
    Re: Stoked Alfred Singlestone <vitonis@gmail.com> - 2015-10-30 05:57 -0700
    Re: Stoked "HAA" <someone@microsoft.com> - 2015-11-02 13:15 +1100
      Re: Stoked François <francois.ganza@wanadoo.fr> - 2015-11-02 02:08 -0800
  Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-10-28 09:28 -0700
    Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 09:37 -0700
      Re: Stoked Paul Rubin <no.email@nospam.invalid> - 2015-10-28 10:28 -0700
  Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 10:52 -0700
    Re: Stoked anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-28 18:14 +0000
  Re: Stoked François <francois.ganza@wanadoo.fr> - 2015-10-28 15:20 -0700
    Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-28 21:16 -0700
  Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-10-30 12:13 -0700
    Re: Stoked rickman <gnuarm@gmail.com> - 2015-10-30 15:34 -0400
  Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-11-07 13:57 -0800
    Re: Stoked rickman <gnuarm@gmail.com> - 2015-11-07 17:19 -0500
  Re: Stoked François <francois.ganza@wanadoo.fr> - 2015-11-09 00:10 -0800
  Re: Stoked Chris Curl <ccurl609@gmail.com> - 2015-12-12 18:52 -0800

csiph-web