[Coco] Superboard discussion: Serial EEPROM

Robert Gault robert.gault at worldnet.att.net
Sat Apr 24 09:58:45 EDT 2004


Boisy G. Pitre wrote:
> 
><snip>
> I'm proposing an assembly language routine that will be in unused 
> portions of the BASIC ROM.  One call will write a byte to a location, 
> another call will read a byte from a location.  I wanted to use the 
> DEFUSR/USRX calls, but in the case of writing, two parameters need to be 
> passed (the location and the byte) and I don't believe the USRX calls 
> take more than one parameter.  Anybody know?
> 
 ><snip>

USR takes a single argument but don't confuse this with DEF FN. 
USR/DEFUSR is able to take a variable or string as an argument as well 
as a number. That means one could execute USR1("$FE20,$A0") and the 
routine could then store $A0 at $FE20 or USR2("$FE20,$A0B0") and store 
$A0B0 at $FE20.

"Going Ahead with Extended Basic" indicates that, "For a string 
argument, the X register points to a five-byte descriptor. The first 
byte of the descriptor is the length of the string. The third and fourth 
bytes of the descriptor contain the address of the first byte of the 
string. The second and fifth bytes are reserved...." The reference gives 
an example of returning a string to Basic so you could read as well as 
write.

You could say A$="$FE20"+"" and USR3(A$) could return A$="$A0" or 
perhaps A$="$FE20:$A0". The length of the string can be changed by the 
USR call. Using the +"" prevents the Basic program from being changed.




More information about the Coco mailing list