mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
add d:lookup-xt to standard image
FossilOrigin-Name: 93028838c88b5a721c03520ed51d80e795ec5006c6dce4bf204f081e0aa1e321
This commit is contained in:
parent
215ae073af
commit
acc3ca0bb2
6 changed files with 22 additions and 17 deletions
|
@ -222,6 +222,7 @@ compile:
|
|||
d:last<xt>
|
||||
d:link
|
||||
d:lookup
|
||||
d:lookup-xt
|
||||
d:name
|
||||
d:xt
|
||||
|
||||
|
|
|
@ -1049,6 +1049,16 @@ This returns zero if the word is not found.
|
|||
|
||||
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||
|
||||
d:lookup-xt
|
||||
|
||||
a-d
|
||||
|
||||
Lookup the specified address in the dictionary
|
||||
and return a pointer to its dictionary header.
|
||||
This returns zero if the word is not found.
|
||||
|
||||
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||
|
||||
d:name
|
||||
|
||||
d-s
|
||||
|
|
|
@ -80,21 +80,6 @@ long as instruction bundle strings (8 characters).
|
|||
s:length #30 swap - #0 n:max [ sp ] times ;
|
||||
~~~
|
||||
|
||||
As I was working I decided I wanted a way to see the names that went
|
||||
along with calls, jumps, etc. So I wrote a quick word to find the DT
|
||||
that goes along with an XT. If none is found, it returns zero.
|
||||
|
||||
~~~
|
||||
{{
|
||||
'Matching var
|
||||
---reveal---
|
||||
:d:lookup-xt (a-d)
|
||||
#0 !Matching
|
||||
[ [ d:xt fetch over eq? ] sip swap [ !Matching ] [ drop ] choose ] d:for-each drop
|
||||
@Matching ;
|
||||
}}
|
||||
~~~
|
||||
|
||||
I split out each type (instruction, reference/raw, and data) into a
|
||||
separate handler.
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -948,6 +948,15 @@ dictionary in a very clean manner.
|
|||
dup-pair [ [ swap call ] dip ] dip again ] call drop ;
|
||||
~~~
|
||||
|
||||
Using `d:for-each`, I implement a means of looking up a dictionary
|
||||
header by the `d:xt` field.
|
||||
|
||||
~~~
|
||||
:d:lookup-xt (a-d)
|
||||
#0 swap [ dup-pair d:xt fetch eq?
|
||||
[ swap [ nip ] dip ] [ drop ] choose ] d:for-each drop ;
|
||||
~~~
|
||||
|
||||
Use `s:with-format` to construct a string from multiple items. This
|
||||
can be illustrated with:
|
||||
|
||||
|
|
BIN
ngaImage
BIN
ngaImage
Binary file not shown.
Loading…
Reference in a new issue