j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
On Sep 1, 2010, at 6:00 AM, openbios-request@openbios.org wrote:
Message: 5 Date: Tue, 31 Aug 2010 20:11:30 -0400 From: Tarl Neustaedter tarl-b2@tarl.net To: The OpenBIOS Mailinglist openbios@openbios.org Subject: Re: [OpenBIOS] Concatenating strings Message-ID: 4C7D9A32.2070300@tarl.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed
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> ;
Thank you very much Tarl. This word should be added to OpenBIOS.
Attachments:
On 9/1/10 4:57 PM, Programmingkid wrote:
On Sep 1, 2010, at 6:00 AM, openbios-request@openbios.org mailto:openbios-request@openbios.org wrote:
Message: 5 Date: Tue, 31 Aug 2010 20:11:30 -0400 From: Tarl Neustaedter <tarl-b2@tarl.net mailto:tarl-b2@tarl.net> To: The OpenBIOS Mailinglist <openbios@openbios.org mailto:openbios@openbios.org> Subject: Re: [OpenBIOS] Concatenating strings Message-ID: <4C7D9A32.2070300@tarl.net mailto:4C7D9A32.2070300@tarl.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
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> ;
Thank you very much Tarl. This word should be added to OpenBIOS.
Please make sure whether the already existing functions (ie. in openbios/forth/lib/string.fs) work for you before adding new stuff.
Stefan