3.1 UNDERSTANDING INSTRUCTION SET AND ASSEMBLY LANGUAGE
3.1.1 Define instruction set,machine and assembly language
3.1.2 Describe features and architectures of various type of microprocessor
3.1.3 Describe the Addressing Modes
3.2 APPLY ASSEMBLY LANGUAGE
3.2.1 Write simple program in assembly language
3.2.2 Tool in analyzing and debugging assembly language program
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
INSTRUCTION SET AND ASSEMBLY
CLO 3: construct a simple program in assembly language
to perform a given task
Summary : This topic introduces the instruction set, data format,
addressing modes, status flag and assembly language programming.
RTA: (06 : 06)
INSTRUCTION SET AND
3.1.1 Define instruction set,machine
and assembly language
• An instruction set is a list of commands ready to be executed directly by CPU.
• We can simply say that the functions of instruction set is to instruct all CPU's with
a set of instruction that can
– tells the CPU where to find data
– when to read the data
– what to do with the data
Now we will see some of the type of instruction set.
• Data transfer instruction
• Arithmetic instruction
• Logical instruction and bit manipulation
• Program control instruction
• Processing control instruction
• Shift and rotate instruction
• A machine language sometimes referred to
as machine code or object code.
• Machine language is a collection
of binary digits or bits that the computer
reads and interprets.
• Machine language is the only language a
computer is capable of understanding.
• Machine language consists of 0s and 1s.
• Is a low-level programming
language for computers,microprocessors,
microcontrollers and other programmable devices.
• Assembly language is just one level higher than
– Assembly language consists of simple codes.
– Each statement in an assembly language corresponds
directly to a machine code understood by the
• The software used to convert an assembly program
into machines codes is called an assembler.
3.1.2 Describe features and architectures
of various type of microprocessor
• The Motorola 68000 is a 32-bit CISC microprocessor.
• 24 bit address bus
• 16 bit data bus.
• 8086 has 16-bit ALU; this means 16-bit
numbers are directly processed by 8086.
• It has 16-bit data bus, so it can read data or
write data to memory or I/O ports either 16
bits or 8 bits at a time.
• It has 20 address lines, so it can address up to
i.e. 1048576 = 1Mbytes of memory (words
i.e. 16 bit numbers are stored in consecutive
3.1.3 Describe the Addressing
• Many instructions, such as MOV, operates on
– MOV dest, source
• Addressing mode indicates where the operands
• There are various addressing modes in x86.
– Register, immediate, direct, register indirect, base-
plus-index, register relative, base relative-plus-
Register is a storage element inside a
1. Register Addressing
• Instruction gets its source data from a register.
• Data resulting from the operation is stored in
• Data length depends on register being used.
– 8-bit registers: AH, AL, BH, BL, CH, CL, DH, DL.
– 16-bit registers: AX, BX, CX, DX, SP, BP, SI, DI.
– 32-bit registers: EAX, EBX, ECX, EDX, ESP, EBP, EDI,
– 64-bit registers: RAX, RBX, RCX, RDX, RSP, RBP, RDI,
RSI, and R8 through R15.
– MOV AX, BX ;Copy the 16-bit content of BX to
– MOV AL, BL ;Copy the 8-bit content of BL to AL
– MOV SI, DI ;Copy DI into SI
– MOV DS, AX ;Copy AX into DS
• Note that the instruction must use registers of
the same size.
– Cannot mix between 8-bit and 16-bit registers.
– Will result in an error when assembled.
2. Immediate Addressing
• The source data is coded directly into the
– The term immediate means that the data
immediately follows the hexadecimal opcode in the
• Immediate data are constant data such as
a number, a character, or an arithmetic
– MOV AX, 100
– MOV BX, 189CH
– MOV AH, 10110110B
– MOV AL, (2 + 3)/5
3. Direct Addressing
• The operand is stored in a memory location, usually in
• The instruction takes the offset address.
– This offset address must be put in a bracket [ ].
– MOV [1234H], AL
– The actual memory location is obtained by combining
the offset address with the segment address in the
segment register DS (unless specified otherwise)
– If we want to use another segment register such as ES,
you can use the syntax ES:[1234H]
– Assuming DS = 1000H, then this instruction will move
the content of AL into the memory location 1234H.
4. Register Indirect Addressing
• Similar to direct data addressing, except
that the offset address is specified using
an index or base register.
– Base registers = BP, BX. Index registers = DI, SI.
– In 80386 and above, any register (EAX, EBX, ECX, EDX, EBP,
EDI, ESI) can store the offset address.
– The registers must be specified using a bracket [ ].
– DS is used as the default segment register for BX, DI and SI.
– MOV AX, [BX]
– Assuming DS = 1000H and BX = 1234H, this instruction will
move the content memory location 11234H and 11235H into
5. Base-plus-index Addressing
• Similar to register indirect addressing, except
that the offset address is obtained by adding a
base register (BP, BX) and an index register (DI,
– MOV [BX+SI], BP
– Assuming DS = 1000H, BX = 0300H and SI = 0200H,
this instruction will move the content of register BP
to memory location 10500H.
6. Register Relative Addressing
• Similar to register indirect addressing,
except that the offset address is obtained
by adding an index or base register with a
• Example 1:
– MOV AX, [DI+100H]
– Assuming DS = 1000H and DI = 0300H, this instruction will
move the content from memory location 10400H into AX.
• Example 2:
– MOV ARRAY[SI], BL
– Assuming DS = 1000H, ARRAY = 5000H and SI = 500H, this
instruction will move the content in register BL to memory
7. Base Relative-plus-index
• Combines the base-plus-index addressing
and relative addressing.
– MOV AH, [BX+DI+20H]
– MOV FILE[BX+DI], AX
– MOV LIST[BP+SI+4], AL
3.2.1 Write simple program in
Example of assembly languange:
MOV CL, 55H ; move 55H into register CL
MOV DL, CL ; copy the contents of CL into DL (now DL=CL=55H)
MOV AH, DL ; copy the contents of DL into AH (now AH=CL=55H)
MOV AL, AH ; copy the contents of AH into AL (now AL=AH=55H)
MOV BH, CL ; copy the contents of CL into BH (now BH=CL=55H)
MOV CH, BH ; copy the contents of BH into CH (now CH=BH=55H)
3.2.2 Tool in analyzing and debugging
assembly language program
• Emulator 8086k –analyze for INTEL 8086
• Easy68k- analyze for MOTOROLA 6800