[Coco] BASIC09 - unsigned INTEGERs?

K. Pruitt pruittk at roadrunner.com
Sun Feb 1 07:11:27 EST 2015


----- Original Message ----- 
From: "Allen Huffman" <alsplace at pobox.com>
To: "CoCoList for Color Computer Enthusiasts" <coco at maltedmedia.com>
Sent: Sunday, February 01, 2015 4:07 AM
Subject: Re: [Coco] BASIC09 - unsigned INTEGERs?


>> On Feb 1, 2015, at 5:53 AM, K. Pruitt <pruittk at roadrunner.com> wrote:
>>
>>>>
>>>> On Jan 31, 2015, at 8:42 PM, Robert Gault <robert.gault at att.net 
>>>> <mailto:robert.gault at att.net>> wrote:
>>>>
>>>> You don't need to go quite that far to just print the result. If you 
>>>> want to do 32-bit math you might need to separate the four bytes.
>>>> As suggested by others, conversion of the hex words to reals might get 
>>>> around the negative integers.
>>>
>>> Yes, I’d love to see someone who can figure this out. I tried all of 
>>> that with no luck. Even did things like this:
>>> <SNIP>
>>
>> PROCEDURE filesize
>> TYPE Registers=CC,A,B,DP:BYTE; X,Y,U:INTEGER
>> DIM regs:Registers
>> DIM path,callcode:BYTE
>> OPEN #path,"test":READ
>> callcode=$8D
>> regs.A:=path
>> regs.B=$02
>> RUN SysCall(callcode,regs)
>> CLOSE #path
>> PRINT regs.U
>>
>> It works.
>
>
> Yes, if the file is less than 32767 bytes :) If it’s larger, it prints a 
> negative number. And if it’s larger than 64K, that won’t work at all 
> because the rest of the value is in X.
>
> I am glad you are looking at this. We have THREE workarounds proposed now:
>
> 1. When creating a REAL that uses regs.X and regs.U, do a little check 
> before deciding what to add: b < 0 then b=b+65536
>
> 2. Using the address of an INT variable and PEEKing out the bytes, and 
> building it as three bytes manually.
>
> 3. Curtis thinks what they did was use BYTEs for the Registers structure:
>
> TYPE Registers=CC,A,B,DP:BYTE; X1,X2,Y1,Y2,U1,U2:BYTE
>
> I tried this tonight, and it worked fine. After the call, you put things 
> back together like you want:
>
> DIM filesize:REAL
>
> filesize = x2 * 65536 + u1 * 256 + u2
>
> …something like that.
>
> #3 solves my situation, since I was really wanting to get the SysCall 
> result back and use it. BUT, it doesn’t help with the general issue of 
> dealing with INTEGERS. I guess the easiest thing to do is just use REAL if 
> you need a value > 32767. :)
>
> — A
>
>
>
>
>
>
>
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>

Oh I can fix that... I think.   (famous last words)

By the way, in a previous code snippet you said that GetStt was $86.  It's 
$8D.  That could be causing you a lot of problems if that wasn't a typo/




More information about the Coco mailing list