64 bit integers in BASIC
Dave Higton (1515) 3526 posts |
I would like to use 64 bit integers in BASIC. I don’t think all integers should be 64 bit – that would be wasteful. I would like to see them as an additional data type. What would the syntax be? When a 32 bit integer is assigned to a 64 bit, I assume it would be sign extended, so if we wanted to take an inherently unsigned one (such as a file position or extent), we would have to explicitly AND with FFFFFFFF. I assume we could indirect them with two pling operations, one shifted. |
Jeffrey Lee (213) 6048 posts |
BB4W supports (signed) 64bit integers, using %% as the name suffix. So it would probably make sense if we followed their lead. Using 64bit integers with SYS could be fiddly. Maybe it can borrow a leaf from VDU’s book and use ‘|’ instead of ‘,’ whenever we want a 64bit value? E.g. SYS "OS_Something",A%%,A%%>>32,C% TO B%,B2% : B%%=B%+(B2%<<32) Could be written as SYS "OS_Something",A%%|C% TO B%%| I.e. whether for input or output, | will cause the preceeding variable to be treated as a 64bit value split across two consecutive registers. (In reference to VDU, ‘;’ would have been a more obvious choice for a double-width value, but of course that’s already been made use of for capturing the NZCV flags on return) |
Rick Murray (539) 13840 posts |
Two things to consider: Firstly, I have seen Secondly, is there any OS level API that is capable of displaying and manipulating 64 bit values? I’m thinking here of the likes of OS_ConvertXXX and the like. Of course, we also hit the problem that a 64 bit value can’t be represented in a single register… |
Jeffrey Lee (213) 6048 posts |
|
GavinWraith (26) 1563 posts |
The most recent RiscLua (6.xx) has 64 bit integers. They are cut down to 32-bit for sys calls. |
Steve Drain (222) 1620 posts |
I wrote a library to support some of this this, as have others. It is a candidate for Basalt, someday. ;-) |