Composition of XTs in Retro

7 views
Skip to first unread message

Alexander Shendi

unread,
Nov 3, 2009, 2:24:37 PM11/3/09
to retr...@googlegroups.com
Dear list,

I am looking for a way to write a word to "compose" 2 XTs, i.e. a word
that takes 2 XTs of the stack
and returns the XT of a word that calls them in sequence.
The best I could come up with is depositing Ngaro opcodes with "," at
HERE and then return the old value
of HERE. As in:

: compose ( xt1 xt2 -- xt3 ) swap here -rot 7 , , 7 , , 9 , ;

"7" is the opcode for calling an address, "9" exits a word. This seems
to work, at least for simple cases.
Now I have 2 questions:

- Is there a better way of doing this?
- Do I need to pad the opcodes with NOPs to align them?

Thank you in advance for your help.

Best Regards,

Alexander Shendi

Charles Childers

unread,
Nov 3, 2009, 2:52:52 PM11/3/09
to Retro List
Hi Alex,

You can use "compile" to lay down the calls, and ";;" (with a backtick; sort of like postpone in ANS Forth):

: compose ( xt1 xt2 -- xt3 )
here push swap compile compile ` ;; pop ;

On the second question, alignment is not necessary.

-- crc
Reply all
Reply to author
Forward
0 new messages