I was following an example, trying to explain to myself what it does:
: place \ ptr len ptr2
2dup \ ptr len ptr2 len ptr2
>r >r \ ptr len ptr2
char+ \ ptr len (ptr2 + 1)
swap \ ptr (ptr2 + 1) len
chars \ ptr (ptr2 + 1) (len * char)
cmove \ --
\ from to how-many
r> r> \ ptr2 len
c! ; \ len = ptr2 ???
\ s" Hello! " name place
It all made sense, until the last instruction... where did I go wrong?
EDIT:
I've added some tracing:
: place \ ptr len ptr2 |
2dup cr .s \ ptr len ptr2 len ptr2 | <5> 16490736 5 2126333248 5 2126333248
>r >r cr .s \ ptr len ptr2 | <3> 16490736 5 2126333248
char+ cr .s \ ptr len (ptr2 + 1) | <3> 16490736 5 2126333249
swap cr .s \ ptr (ptr2 + 1) len | <3> 16490736 2126333249 5
chars cr .s \ ptr (ptr2 + 1) (len * char) | <3> 16490736 2126333249 5
cmove cr .s \ -- | <0>
\ from to how-many |
r> r> cr .s \ ptr2 len | <2> 5 2126333248 ok
c! ; \ ptr2 = len ??? |
\ s" Hello! " name place