[OpenBIOS] Concatenating strings

Tarl Neustaedter tarl-b2 at tarl.net
Wed Sep 1 02:11:30 CEST 2010

  On 2010-8-31 8:06 PM, Programmingkid wrote:
> Could someone provide me with a code example on how to combine two strings 
> together in forth please. Here is my attempt. For some reason it doesn't 
> work. Any help would be great.

The below takes two strings of the form (addr len), allocates a chunk of 
memory for them, and concatenates them into that allocated memory, returning 
addr len.

: $cat2  ( $1 $2 -- $3 )
    2 pick over +  dup >r alloc-mem >r
    2swap tuck  r@ swap move           ( $2 $1-len )
    r@ + swap move                     ( )
    r> r>

More information about the OpenBIOS mailing list