[Coco] BASIC09 - unsigned INTEGERs?

L. Curtis Boyle curtisboyle at sasktel.net
Sat Jan 31 20:53:39 EST 2015


I know I always did it with a TYPE declaration for the register stack; don’t know if that made a difference. Something like (boy, has it been a long time since I did this):
TYPE registers=cc,a,b,dp:BYTE;x,y,u:INTEGER
DIM regs:registers

and then ran the SYSCALL. I honestly don’t remember if we had to tweak anything to get it to assign correctly, to do SEEK’s, etc.
 
L. Curtis Boyle
curtisboyle at sasktel.net



> On Jan 31, 2015, at 7:46 PM, Allen Huffman <alsplace at pobox.com> wrote:
> 
> 
>> On Jan 31, 2015, at 11:51 AM, L. Curtis Boyle <curtisboyle at sasktel.net> wrote:
>> 
>> I am pretty sure you can assign regs.x*65536.+regs.u to a FLOAT variable and it works fine… we used to do this at work all the time.
> 
> 
> Nope.
> 
> When it does the math, regs.U is -4601 or whatever on mine, so it does the first part, then subtracts -4601. It was driving me nuts, ‘cause the HEX was printing perfectly (PRINT USING) but the REAL was wrong. I ended up printing each value and that’s when I realized what was going on.
> 
> DIM a:INTEGER
> DIM b:INTEGER
> DIM c:REAL
> 
> a = $0002
> b = $FFFF
> c = a * 65536 + b
> 
> Expected result:
> 
> $0002 * 65536 + $FFFF
> 2 * 65566 + 65535 = 327679
> 
> Actual:
> 
> 2 * 65536 + -1 = 131071
> 
> 		— A
> 
> 
> 
> 
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
> 



More information about the Coco mailing list