[Coco] Pointer to sting array

Darren A mechacoco at gmail.com
Wed Apr 5 12:52:11 EDT 2017


On Wed, Apr 5, 2017 at 9:47 AM, Phill Harvey-Smith wrote:

> Hi all,
>
> Does anyone know how to get in assembler a pointer to a string array, I
> want to write an array sorting routine as it's too slow in basic, that
> takes an array and sorts it I should be able to do this by swapping the
> order of the 5 byte string descriptors for the array, but I need to work
> out either how to get the array name so I can search the array variables
> area for it's data, or a pointer to the array descriptor.
>
>

You could use VARPTR(A$(0)) to get the pointer to the first element in the
array.  Subtracting 7 from that will give the pointer to the array
descriptor.  If your sort routine is interfaced to Basic as a USR() call
then pass the descriptor pointer as the argument:

X=USR0(VARPTR(A$(0)) - 7)


- Darren


More information about the Coco mailing list