Classic Computer Magazine Archive COMPUTE! ISSUE 29 / OCTOBER 1982 / PAGE 10

Ask The Readers

The Editors And Readers of COMPUTE


I've noticed many programs using "AND," such as: IF (Z AND 127)<32 THEN…. What's being compared when it says "Z AND 127"? Could you also explain to me how the WAIT statement works?

David Zacharuk

The two numbers are being compared in their binary form: if the variable Z is, say, 15 then it would look like this in binary: 00001111. AN Ding it with 127 (01111111) gives 00001111 (15) so the IF THEN in the example would be less than 32. For further explanation of AND, consult any book on machine language or see "The Beginner's Page" last month, COMPUTE!, September 1982, p. 24.

WAIT is infrequently used in BASIC programming (and is not available in some versions of BASIC). If you wrote WAIT 5000,5,1 you would cause the computer to stop operations until it PEEKed address 5000, Exclusive ORs the number it found there with the 1, ANDs with the 5, and the result is anything other than zero. If it gets a zero after these operations, it continues to wait until the result becomes something other than zero. WAIT's primary value would be for communicating with peripherals when you've added your own interface. It's hard to explain, hard to understand, and, luckily, hardly ever needed.