Skip to main content

8086 assembly language operators

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.

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

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:

TypeOperatorsExample
Arithmetic+ - * / MODMOV AL,(5*4)+2
Logical (bitwise)AND OR XOR NOTMOV AL,0F0H AND 3CH
ShiftSHL SHRMOV AX,1 SHL 4 (=10H)
RelationalEQ NE LT LE GT GE5 GT 3 gives 0FFFFH (true), else 0
Segment override:MOV AX,ES:[BX]
Index[ ]MOV AL,ARR[SI]
Type / attributePTR SHORT THISMOV WORD PTR [BX],5
Value returningOFFSET SEG TYPE LENGTH SIZEMOV BX,OFFSET ARR
Byte extractorsHIGH LOWMOV AL,HIGH 1234H (=12H)
Location counter$LEN EQU $-MSG
Data repeatDUPBUF 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.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Microprocessor chapter 3 questions →