[Coco] DEF USR and strings?

Allen Huffman alsplace at pobox.com
Thu Oct 30 10:52:37 EDT 2025


> On Oct 29, 2025, at 10:49 PM, Sean Conner via Coco <coco at maltedmedia.com> wrote:
> 
>  Not only that, but the registers upon calling USRn (ECB) are (from my
> notes):
> 
> 	       USRn    Entry point to user-callable machine language subroutine
> 	Entry: A - 0   if paramater in FP0 is a number
> 	         - 255 if parameter in FP0 is a string descriptor
> 	       B - length if string descriptor
> 	       X - FP0EXP if A=0
> 	         - string descriptor if A=255
> 	       Zf - 1 if A = 0
>                  - 0 if A = 255
> 	       Zn - 1 if A = 255
>                  - 0 if A = 0
> 	       FP0 + _STRPTR - string descriptor if A=$FF
> 	       VALTYP - same as A
> 	
> 	Note:  ECB/DECB allow returning a string value.
> 	
> 	       Changing the characters of the string pointer is undefined; changing
> 	       the contents of the string descriptor is allowed.
> 
>  Because the flags reflect the value in A, there's no need to CMPA or TSTA
> before jumping if supporting both a string or numeric input.  Also, INTCVT
> does a type check, so calls to CHKNUM (a name I came up with) isn't required
> if calling INTCVT.
> 
>  USR (from Color BASIC) doesn't set the registers with any meaningful
> values, just FYI.
> 
>  -spc

Thank you for your service!

May I quote some of your messages here in an upcoming blog post?

I want to scan through Rainbow archives and see if this “return a string” was ever addressed in Rainbow. With the references in the Getting Started with Extended BASIC saying you could do it, but no examples of how to make it work, I wonder if someone saw that back then and figured this out.

	— Allen


More information about the Coco mailing list