OR
BASIC keyword | |
Keyword: | OR |
Abbreviation: | – |
Type: | Operator |
Token code: | 176/$B0 |
Handling routine in BASIC ROM: |
45030–45077 $AFE6–B015 |
List of all BASIC keywords |
Remark: This article describes the BASIC command OR in BASIC V2 at the Commodore 64.
Type: Boolean/bit-wise operator General Programming-Syntax: <Boolean/integer term> OR <Boolean/integer term>
OR performs two different functions:
- In boolean expressions (such as the condition in an IF/THEN construct), OR yields the boolean value "true" (numerical: −1) if either or both of the terms preceding and trailing the OR keyword, evaluates to "true".
- In bitwise operations, a bit in the resulting integer is set if either or both the corresponding bits in the integer terms, are set.
Use of non-numerical terms in conjunction with OR causes a ?TYPE MISMATCH ERROR IN line. In the case of bitwise AND operations, both terms are evaluated as 16-bit signed integers, and thus cannot exceed the range of −32768 thru 32767, or −$8000 thru $7FFF in hexadecimal — terms outside of this range will raise an ?ILLEGAL QUANTITY ERROR IN line. If either of the terms are absent, a ?SYNTAX ERROR IN line will occur.
Note that in BASIC on the C-64, the boolean value "true" is represented by the integer −1, which is all bits set in the 16-bit signed format, while the value "false" is represented by the value 0, or all bits clear.
Examples[edit | edit source]
PRINT 3<2 OR 5<6 -1 meaning "true" ready. PRINT 3=2 OR 3<2 0 meaning "false" ready. POKE 53265,PEEK (53265) OR 64 Bitwise operation to turn on ready. a single bit in a register
Boolean algebra
PRINT 0 OR 0 (Result: 0; false) PRINT 1 OR 0 (Result: 1; true) PRINT 0 OR 1 (Result: 1; true) PRINT 1 OR 1 (Result: 1; true)
ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT