[Coco] BASIC09 problem

embsys dev embsysdev at gmail.com
Tue Feb 24 22:14:53 EST 2015


8-bit math overflow :  sector(1)*256 = more than 8 bits

On Tue, Feb 24, 2015 at 7:56 PM, Bob Devries <devries.bob at gmail.com> wrote:

> I'm trying to write a small procedure in Basic09 to write to the last
> sector on a disk(image). It's not working the way I thought it should.
> Maybe someone can see my error?
>
> DIM sector(256):BYTE
> DIM path:INTEGER
> DIM lof:INTEGER
> BASE 0
> OPEN #path,"/x0@":UPDATE
> GET #path,sector
> lof = sector(1)*256+sector(2) (* returns 2880 on the image I'm using *)
> SEEK #path, (lof-1)*256 (* should go to the start of the last sector *)
> (* 2880 - 1 = 2879. 2879 * 256 = 737024 *)
> GET #path, sector
> PUT #path, sector
> CLOSE #path
> END
>
> The line with SEEK #path is where it is going wrong. (lof-1)*256 returns
> 16128.
>
> I'm sure it should be a simple error in my code, but I can't see it.
>
> Regards, Bob Devries
> Dalby, QLD, Australia
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list