[Coco] BASIC09 - unsigned INTEGERs?

Allen Huffman alsplace at pobox.com
Sat Jan 31 20:39:12 EST 2015


> On Jan 31, 2015, at 11:42 AM, Robert Gault <robert.gault at att.net> wrote:
> 
> Robert Gault wrote:
>> Allen Huffman wrote:
>>> In BASIC09, I am trying to use SYSCALL to get the size of a file. It returns
>>> with values in regs.X and regs.Y, which I would like to put together to make
>>> the actual file size.
>>> 
> 
> Here is an example that will at least print the answer. Doing comparisons with the result would be more complex.
> 
> 
> TYPE registers=cc,a,b,dp:BYTE; x,y,u:INTEGER
> DIM regs:registers
> DIM hx,lx,hu,lu:BYTE
> regs.x=$FE47
> regs.u=$CF39
> hx=LAND(regs.x,65280)/256
> lx=LAND(regs.x,255)
> hu=LAND(regs.u,65280)/256
> lu=LAND(regs.u,255)
> PRINT"$";
> PRINT USING "h2",hx;lx;hu;lu
> 
> RUN
> $FE47CF39
> 
> Cumbersome but the value printed is correct.

Neat! I tried LAND() early on to un-do the negative, but that didn’t work for getting it in to a REAL.

Actually, I didn’t think it needed to be that complex. When I was Googling on how to use SYSCALL, I came across a page on my CoCopedia site someone put there. It was the SYSCALL source code from OS-9 L1 and embedded in the comments was an example of how to use it (missing one crucial line!) specifically on getting the size. In it, the just

PRINT USING “‘filesize =‘,H2,H4”, regs.X, regs.Y

….or something very similar to that. Printing as HEX will show $FF00 as $FF00, though decimal shows it as a negative value.

		—A






More information about the Coco mailing list