Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

Bit Shifting in Basic (https://subethasoftware.com)

30 points by efren6 4 days ago | 2 comments | View on ycombinator

JdeBP 32 minutes ago |

The interesting thing is that there were BASICs where one could do this more directly. The early Microsoft BASICs for OEM home computers, as Commodore and Tandy BASICs here, are not the only games in town at 50 years's remove. Picking the 1970s BASICs misses out on what one could actually do a handful of years later, as vendors improved BASIC with these new ideas like 16-bit processors and whatnot. (-:

TrueBASIC was done by the Darthmouth people themselves in the middle 1980s, and had BIN$() and CONVERT() to convert a number to and from its binary representation as a string of one and zero characters.

TurboBASIC had binary numbers as first class numeric literals, &Bxxxxxx, and BIN$().

Sinclair SuperBASIC for the QL had PEEK_W and PEEK_L, so one didn't have to do the tedious byte multiplication. BBC and ARM BASIC had the pling ('!') operator likewise for word instead of byte accesses.

When it comes to Unix: Thompson's bas(1) from 1972 did not have any of this, and neither did the DEC PDP basic(6) that was left out of Unix 2nd Edition. But again, that was the 1960s and 1970s. All of these years later we have yabasic that has (alas!) C-style rather than the conventional BASIC-style constants for hexadecimal and binary and bin$() and dec() functions for the string to number conversions in binary, in C style.

pcwalton about 1 hour ago |

You can shift an integer 1 bit to the left by adding it to itself. This should be faster than multiplying by 2 on ancient CPUs.

martinamaldonad 11 minutes ago |

[flagged]