---
title: "8086 assembly language operators"
subject: "Microprocessor"
chapter: 3
key: "semester_4/microprocessor:8086-operators"
source: https://www.bctengineer.com/q/semester_4/microprocessor/8086-operators
site: BCT Engineering
---

# 8086 assembly language operators

Microprocessor · Chapter 3: Programming with 8086 Microprocessor

- Asked in: 2073 Magh, 4 marks; 2069 Poush, 4 marks; 2068 Magh, 4 marks (asked 3 times)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/8086-operators
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-3

## Question

List out and explain the operators used in 8086 assembly language programming.

## Short answer

Assembly-time operators include arithmetic (+ – * / MOD), logical (AND OR XOR NOT), relational (EQ NE LT LE GT GE), PTR to force operand size, OFFSET/SEG to extract address components, HIGH/LOW to split bytes, and DUP for repeated data. $ returns current location counter.

## Answer

**Operators** are used in assembler statements to build expressions that are evaluated by the assembler at assembly time (not run time). The main types in 8086 (MASM) are:

| Type | Operators | Example |
|---|---|---|
| Arithmetic | `+  -  *  /  MOD` | `MOV AL,(5*4)+2` |
| Logical (bitwise) | `AND  OR  XOR  NOT` | `MOV AL,0F0H AND 3CH` |
| Shift | `SHL  SHR` | `MOV AX,1 SHL 4` (=10H) |
| Relational | `EQ  NE  LT  LE  GT  GE` | `5 GT 3` gives 0FFFFH (true), else 0 |
| Segment override | `:` | `MOV AX,ES:[BX]` |
| Index | `[ ]` | `MOV AL,ARR[SI]` |
| Type / attribute | `PTR  SHORT  THIS` | `MOV WORD PTR [BX],5` |
| Value returning | `OFFSET  SEG  TYPE  LENGTH  SIZE` | `MOV BX,OFFSET ARR` |
| Byte extractors | `HIGH  LOW` | `MOV AL,HIGH 1234H` (=12H) |
| Location counter | `$` | `LEN EQU $-MSG` |
| Data repeat | `DUP` | `BUF DB 10 DUP(0)` |

**Notes**
- `OFFSET var` gives the offset address of a variable; `SEG var` gives its segment address.
- `PTR` forces the size of an operand when it is not clear from the other operand, e.g. `INC BYTE PTR [SI]`.
- `TYPE` returns 1 for byte, 2 for word, 4 for double word; `LENGTH` returns the number of DUP elements; `SIZE` = LENGTH × TYPE.
- `$` is the current location counter, so `$ - MSG` after a string definition gives its length in bytes.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. When are operators in an 8086 assembler statement evaluated?
   A. At run time by the CPU
   B. At assembly time by the assembler
   C. At load time only
   D. At link time only
   Answer: B. Operators build expressions the assembler evaluates during assembly. (Key point: Assembly-time evaluation)

2. What is PTR used for?
   A. Giving the offset of a variable
   B. Forcing the operand size, e.g. INC BYTE PTR [SI]
   C. Repeating data
   D. Getting segment address
   Answer: B. PTR overrides/specifies size when it is unclear from the other operand. (Key point: PTR)

3. What does LEN EQU $-MSG give?
   A. Segment of MSG
   B. Length of the string in bytes
   C. Offset of MSG
   D. Number of DUP elements
   Answer: B. $ is the current location counter, so $-MSG after the definition is its length in bytes. (Key point: Location counter)

## Related in Microprocessor

- [8086 ALP: sum of 100 even numbers](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-sum-even-numbers) — Microprocessor, chapter 3
- [8086 ALP: largest and smallest, display](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-largest-smallest-display) — Microprocessor, chapter 3
- [8086 ALP: words on lines and word count](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-words-lines-count) — Microprocessor, chapter 3
- [8086 ALP: count vowels and display string](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-count-vowels-display) — Microprocessor, chapter 3
- [8086 ALP: vowels and consonants separately](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-vowels-consonants-separately) — Microprocessor, chapter 3
- [8086 ALP: convert text to uppercase](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-uppercase-text) — Microprocessor, chapter 3

## Related in other subjects

- [Define programming language](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adefine-programming-language) — Computer Programming, chapter 1, asked 3×
- [Global vs local; & and * operators](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aglobal-local-ampersand-star) — Computer Programming, chapter 3
- [Assembly constraints and tolerance fit calculation](https://www.bctengineer.com/question.md?key=semester_4%2Fcomputer_aided_design%3Aassembly-constraints-tolerance-fit) — Computer Aided Design, chapter 5
- [Operators that cannot be overloaded](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Anon-overloadable-operators) — Object Oriented Programming, chapter 5, asked 2×
