[Coco] BASIC09 - unsigned INTEGERs?

Allen Huffman alsplace at pobox.com
Sat Jan 31 02:33:41 EST 2015


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.

But, since regs.X and regsY are both INTEGER types, values with the high bit set are seen as negative numbers, and any such math is treated that way.

I am basically doing this (which is an example of how to use SYSCALL I found on Cocopedia, from a BASIC09 manual).

TYPE Registers=CC,A,B,DP:BYTE; X,Y,U:INTEGER
DIM regs:Registers
DIM callcode:BYTE
…
DIM path:BYTE

…file gets opened...

callcode = $86   <- GetStt
regs.A = path
regs.B = $02   <- SS.SIZ
RUN SysCall(callcode, regs)

…on return, regs.X and regs.U is the size:

PRINT USING “‘filesize = $’,H2,H4”, regs.X; regs.U)

but if I print regs.X and regs.U, it may be showing a negative number and thus my math isn’t working.

I don’t see any way to cast — but surely there’s a solution. Anyone know?

		— A


More information about the Coco mailing list