Re: Confused
- From: MarkWills <markrobertwills@xxxxxxxxxxx>
- Date: Wed, 28 Jan 2009 06:52:53 -0800 (PST)
On Jan 28, 2:33 pm, Mikael Nordman <oh2aun....@xxxxxxxxxxxxxx> wrote:
If HEX were not immediate, then NUMBER (who either pushes values to
the stack (immediate mode) or calls LIT (compile mode)) would break
while trying to parse FF (or, more specifically, it would pass it to
WORD who would try to find it in the dictionary).
The normal solution to this problem is to extend the number conversion
with prefix that determines the conversion base.
From FlashForth.
% means binary
# means decimal
$ means hex
cold COLD!
FlashForth V3.3 on PIC18F2520
ok<16,2>
decimal ok<10,2>
$dead ok<10,2>57005
$beef ok<10,2>57005 48879
hex ok<16,2>dead beef
bin ok<2,2>1101111010101101 1011111011101111
hex ok<16,2>dead beef
+ ok<16,2>9d9c
drop ok<16,2>
Ah. Ok. That makes sense. That differs from how I did it, and i'll
stick my neck out and say that it also differs from how polyFORTH did
it in Brodie's original book (although I don't have the book in front
of me so I could be wrong).
I guess a more appropriate name for the as I have implemented it would
be [HEX]
Thanks everyone for the help. Good stuff.
Actually, something just occurred to me. They way I have written it
you could have this situation:
: FACE S" HELLO" ;
: TEST 1 2 HEX FF FACE ;
The last word in TEST(FACE) was (in my mind) a call to the word FACE,
however, it's also a legal HEX word, so it would have been compiled as
a LIT by NUMBER.
Oh dear!
(although, of course you could get around it with : TEST 1 2 HEX FF
DECIMAL FACE ;
Horses for courses. Different strokes etc!
Mark
Mark.
Mark
.
- Follow-Ups:
- Re: Confused
- From: Elizabeth D Rather
- Re: Confused
- From: Mikael Nordman
- Re: Confused
- References:
- Confused
- From: MarkWills
- Re: Confused
- From: Helmar
- Re: Confused
- From: MarkWills
- Re: Confused
- From: Helmar
- Re: Confused
- From: MarkWills
- Re: Confused
- From: Mikael Nordman
- Confused
- Prev by Date: Re: Confused
- Next by Date: Re: CLI gforth loosing CR's
- Previous by thread: Re: Confused
- Next by thread: Re: Confused
- Index(es):
Relevant Pages
|