# Operator

An **operator** is a type of mathematical function. It represents an action upon an input, in order to deliver an output. The input consists of operands, and the relationship between the operator and operand is known as an operation. In computer programming, there are many operators that allow the manipulation of data in terms of quantity, structure, space and change.

## Common C64 Operators[edit | edit source]

In its default state, the C64 allows a programmer access to the high-level language BASIC through the BASIC ROM interpreter. Similarly by use of a machine language monitor, the programmer can access a low-level assembly language. Although there are other languages available to the C64 programmer, the following operators will be referred to only in terms of BASIC and assembly language. The notation (position in the operation) of the operator is critical: in the following tables, *prefix* means the operator is placed before the operand and *infix* means the operator is placed between operands. Naturally all opcodes in assembly language are placed *prefix*, however they are included for completeness and comparison.

### Arithmetic Operators[edit | edit source]

Arithmetic operations return a numerical output.

Name | BASIC | Assembly Language | ||
---|---|---|---|---|

Symbol/Mnemonic | Notation | Symbol/Mnemonic | Notation | |

Add | + | Infix | ADC | Prefix |

Subtract | - | Infix | SBC | Prefix |

Decrement | DEC, DEX, DEY | Prefix | ||

Increment | INC, INX, INY | Prefix | ||

Multiply | * | Infix | ||

Divide | / | Infix | ||

Exponent | ^ | Infix | ||

Logarithm | LOG | Prefix | ||

Square Root | SQR | Prefix |

### Boolean Operators[edit | edit source]

Boolean operations return a logical output.

Name | BASIC | Assembly Language | ||
---|---|---|---|---|

Symbol/Mnemonic | Notation | Symbol/Mnemonic | Notation | |

And | AND | Infix | ||

Or | OR | Infix | ||

Not | NOT | Infix | ||

Exclusive Or | EOR | Prefix |

### Assignment Operators[edit | edit source]

Assignment operations return a replicated output.

Name | BASIC | Assembly Language | ||
---|---|---|---|---|

Symbol/Mnemonic | Notation | Symbol/Mnemonic | Notation | |

Load | LDA, LDY, LDX | Prefix | ||

Store | STA, STY, STX | Prefix | ||

Transfer | TAX, TAY, TXS, TXA, TYA, TSX | Prefix | ||

Push | PHA, PHP | Prefix | ||

Pull | PLA, PLP | Prefix | ||

Equal | = | Infix |

### Relational Operators[edit | edit source]

Relational operations return an associative output.

Name | BASIC | Assembly Language | ||
---|---|---|---|---|

Symbol/Mnemonic | Notation | Symbol/Mnemonic | Notation | |

Lesser Than | < | Infix | ||

Greater Than | > | Infix | ||

Not Equal To | <> | Infix | ||

Lesser Than Or Equal To | <=, =< | Infix | ||

Greater Than Or Equal To | >=, => | Infix | ||

Compare | CMP, CPX, CPY | Prefix |

### Trigonometric Operators[edit | edit source]

Trigonometric operations return a numerical output.

Name | BASIC | Assembly Language | ||
---|---|---|---|---|

Symbol/Mnemonic | Notation | Symbol/Mnemonic | Notation | |

Sine | SIN | Prefix | ||

Cosine | COS | Prefix | ||

Tangent | TAN | Prefix |

## Code Examples[edit | edit source]

** BASIC **

10 A=2 : B=0 20 IF ( A>0 OR B=1 ) AND A=1 THEN C=1 30 PRINT A, B, C RUN 2 0 0

*C is 0, although A > 0, but A isn't 1.*
*If no bracket is in line 20, the logic change and also the result: C is 1, cause A > 0, but if hasn't A=1, it is equal which value has B.*