Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define VALUE and TO

Tags:

forth

6502

I want to implement the Forth words VALUE and TO on a RPC/8 (an emulated computer in a Minecraft mod). My best attempts get me a set of words that work fine so long as I don't use them while compiling. More sepecificly VALUE works, but TO does not.

: VALUE CREATE , DOES> @ ;
: TO ' 3 + ! ;

I have tried everything I can think of to get it working and my best attempt gets me this:

['] NameOfAValue 3 + !

Note that the processor is not a pure 6502 but a 65EL02, a custom variant of the 65816.

EDIT #1: Somehow I forgot the call to CREATE in value. It should have been there all along. EDIT #2: I also got 3 and + switched around in TO... oops. It should have been the other way all along.

like image 608
Milo Christiansen Avatar asked Feb 16 '13 20:02

Milo Christiansen


People also ask

How will you define value to a product?

Value-added is the difference between the price of a product or service and the cost of producing it. The price is determined by what customers are willing to pay based on their perceived value. Value is added or created in different ways.

What is value definition and example?

Value is the worth in goods, services or money of an object or person. An example of value is the amount given by an appraiser after appraising a house. An example of value is how much a consultant's input is worth to a committee. noun.

How do you define value in business?

A Common Definition of Value Value in business markets is the worth in monetary terms of the technical, economic, service, and social benefits a customer company receives in exchange for the price it pays for a market offering.


1 Answers

The simplest solution is

VARIABLE TO-MESSAGE   \ 0 : FROM ,  1 : TO .           
: TO 1 TO-MESSAGE ! ;

: VALUE CREATE , DOES> TO-MESSAGE @ IF ! ELSE @ THEN 
 0 TO_MESSAGE ! ; 

It uses only CORE words and is absolutely standard. And it just works in interpret and compile mode, because there is no fishy look ahead in the input stream.

like image 188
Albert van der Horst Avatar answered Oct 29 '22 22:10

Albert van der Horst