[Coco] BASIC09 - unsigned INTEGERs?

Aaron Wolfe aawolfe at gmail.com
Sat Jan 31 12:56:37 EST 2015


You can use ADDR and PEEK to directly access the individual bytes of reg.x
and reg.u, I.e. XH=PEEK(ADDR(reg.x)) and XL=PEEK(ADDR(reg.x)+1).  This
should let you display them as bytes, without invoking BASIC09's signing
logic.
 On Jan 31, 2015 2:33 AM, "Allen Huffman" <alsplace at pobox.com> 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.
>
> 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
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list