Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
TECHNICAL UNIVERSITY OF KENYA
School of Engineering Science and Technology
Department of Electrical, Control, Telecommunication and Computing
MICROPROCESSOR SYSTEMS AND APPLICATIONS
B
LABORATORY REPORT
8086 Microprocessor — Assembly Language Programming
Experiments 01 – 09
Arithmetic Operations | Array Processing | String Comparison
Date: ___________________________
Student Name: ___________________________
Admission No.: ___________________________
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
1. Introduction
This laboratory report documents nine experiments conducted using the 8086 Microprocessor trainer
kit. Each experiment involves writing and executing Assembly Language Programs (ALP) to perform
specific computational tasks, including arithmetic operations on 8-bit and 16-bit numbers, array
processing, and string comparison.
The 8086 is a 16-bit microprocessor developed by Intel. It operates on an 8-bit external data bus and
supports a 20-bit address bus, enabling it to address up to 1 MB of memory. The experiments in this
report are organized into two lab sessions:
• LAB 1 (Experiments 01–05): Arithmetic operations — Addition, Sum of Memory Data,
Subtraction, Multiplication, and Division.
• LAB 2 (Experiments 06–09): Array processing and string operations — Finding Maximum, Array
Exchange, Factorial Computation, and String Comparison.
General Objectives
• Understand the concepts of a microprocessor system.
• Program a microprocessor system using assembly language.
• Write and implement microprocessor programs on the 8086 trainer kit.
• Diagnose faults in microprocessor systems.
Common Apparatus for All Experiments
No. Equipment Specification Qty
1 8086 Microprocessor Trainer Kit 8086 1
2 DC Power Supply +5 V DC 1
3 Keyboard (Hex Keypad) Trainer Kit Keyboard 1
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
2. LAB 1 — Arithmetic Operations
EXPERIMENT 01
16-Bit Addition Using Arithmetic Operation of 8086
AIM
To write an assembly language program to perform addition of two 16-bit numbers using the 8086
trainer kit.
PROGRAM CODE
; PROGRAM FOR ADDITION
; Enter data in locations 9000H and 9001H
; Result stored in locations 9002H (LSD) and 9003H (MSD)
MOV BX, 9000H ; Load base address
MOV AL, [BX] ; Load first operand (8-bit) into AL
INC BX ; Point to next memory location
MOV CL, [BX] ; Load second operand into CL
INC BX ; Point to result location
MOV AH, 00 ; Clear AH (zero-extend AL to AX)
MOV CH, 00 ; Clear CH (zero-extend CL to CX)
ADD AX, CX ; AX = AX + CX (16-bit addition)
MOV [BX], AX ; Store 16-bit result
INT RSTINT ; Break / halt
ALGORITHM
Step 1: Start.
Step 2: Load the base address 9000H into register BX.
Step 3: Move the first operand from memory [BX] into register AL.
Step 4: Increment BX to point to the second operand.
Step 5: Move the second operand from memory [BX] into register CL.
Step 6: Increment BX to point to the result memory location.
Step 7: Clear AH and CH to zero-extend both operands to 16 bits.
Step 8: Perform 16-bit addition: AX = AX + CX.
Step 9: Store the 16-bit result in memory [BX] (9002H = LSD, 9003H = MSD).
Step 10: Halt execution.
RESULTS
Sample test values:
Memory Location Value (Hex) Description
9000H 05H First operand (Addend)
9001H 03H Second operand (Addend)
9002H 08H Result LSD
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Memory Location Value (Hex) Description
9003H 00H Result MSD
For inputs 05H + 03H: Result = 0008H (stored as 08H at 9002H and 00H at 9003H).
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 02
Sum of Memory Data (16 Locations)
AIM
To write an assembly language program to perform the addition of data stored in 16 consecutive
memory locations using the 8086 processor kit.
PROGRAM CODE
; ALP FOR SUM OF MEMORY DATA
; Enter 16 data values from location 9000H
; Result LSD at 9400H, Result MSD at 9401H
ORG 8400H
MOV BX, 9000H ; Start address of memory block
MOV CL, 10H ; Byte count = 16 (10H)
MOV AX, 00 ; Initialize result accumulator to 0
MOV DH, 00 ; Clear DH
ADDLOOP1:
MOV DL, [BX] ; Load byte from memory into DL
INC BX ; Advance memory pointer
ADD AX, DX ; Add DX (DH=0, DL=byte) to AX
DEC CL ; Decrement byte counter
JNZ ADDLOOP1 ; Repeat if counter not zero (75 F7)
MOV BX, 9400H ; Point to result location
MOV [BX], AX ; Store 16-bit sum
INT RSTINT ; Halt
ALGORITHM
Step 1: Start.
Step 2: Load the start address 9000H into BX.
Step 3: Load byte count (10H = 16) into CL.
Step 4: Initialize AX = 0000H (result accumulator), DH = 00H.
Step 5: LOOP: Load byte from [BX] into DL.
Step 6: Increment BX to point to the next byte.
Step 7: Add DX (= 00 || DL) to AX.
Step 8: Decrement CL.
Step 9: If CL ≠ 0, go to step 5.
Step 10: Store the 16-bit result AX at memory address 9400H.
Step 11: Halt.
RESULTS
Example: 16 memory locations each containing 01H — expected sum = 0010H.
Result Location Value (Hex) Description
9400H 10H Sum LSD
9401H 00H Sum MSD
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 03
16-Bit Subtraction
AIM
To write an assembly language program to perform subtraction of two 16-bit numbers using the 8086
trainer kit.
PROGRAM CODE
; PROGRAM FOR SUBTRACTION
; Enter data in locations 9000H (Minuend) and 9001H (Subtrahend)
; Result stored in locations 9002H (LSD) and 9003H (MSD)
ORG 8400H
MOV BX, 9000H ; Load base address
MOV AL, [BX] ; Load minuend into AL
INC BX
MOV CL, [BX] ; Load subtrahend into CL
INC BX
MOV AH, 00 ; Zero-extend AL → AX
MOV CH, 00 ; Zero-extend CL → CX
SUB AX, CX ; AX = AX - CX
MOV [BX], AX ; Store result at 9002H
INT RSTINT ; Halt
ALGORITHM
Step 1: Start.
Step 2: Load base address 9000H into BX.
Step 3: Load minuend from [BX] into AL.
Step 4: Increment BX; load subtrahend from [BX] into CL.
Step 5: Increment BX to result address.
Step 6: Clear AH and CH to extend operands to 16 bits.
Step 7: Perform SUB AX, CX — 16-bit subtraction.
Step 8: Store result AX at memory [BX] (9002H & 9003H).
Step 9: Halt.
RESULTS
Memory Location Value (Hex) Description
9000H 09H Minuend
9001H 04H Subtrahend
9002H 05H Result LSD (Difference)
9003H 00H Result MSD
For 09H − 04H: Result = 0005H. Note: if subtrahend > minuend, the Carry Flag (CF) will be set,
indicating a borrow (negative result in two's complement).
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 04
16-Bit Multiplication (Repeated Addition)
AIM
To write an assembly language program to perform multiplication of two 16-bit numbers using the 8086
trainer kit via the repeated addition method.
PROGRAM CODE
; PROGRAM FOR MULTIPLICATION (Repeated Addition)
; Enter data in locations 9000H (Multiplicand) and 9001H (Multiplier)
; Result stored at 9002H (LSD) and 9003H (MSD)
ORG 8400H
MOV BX, 9000H ; Load base address
MOV AL, [BX] ; Load multiplicand into AL
INC BX
MOV CL, [BX] ; Load multiplier into CL
INC BX
MOV AH, 00 ; Zero-extend AL → AX
MOV DX, 00 ; Initialize product accumulator DX = 0
ADDLOOP:
ADD DX, AX ; DX = DX + AX (add multiplicand)
DEC CL ; Decrement multiplier count
JNZ ADDLOOP ; Repeat until CL = 0 (75 FA)
MOV [BX], DX ; Store 16-bit product at 9002H
INT RSTINT ; Halt
ALGORITHM
Step 1: Start.
Step 2: Load base address 9000H into BX.
Step 3: Load multiplicand from [BX] into AL; set AH = 00H.
Step 4: Increment BX; load multiplier from [BX] into CL.
Step 5: Increment BX to result address.
Step 6: Initialize DX = 0000H (product accumulator).
Step 7: LOOP: Add AX to DX.
Step 8: Decrement CL.
Step 9: If CL ≠ 0, repeat from step 7.
Step 10: Store DX (product) at memory [BX].
Step 11: Halt.
RESULTS
Memory Location Value (Hex) Description
9000H 04H Multiplicand
9001H 03H Multiplier
9002H 0CH Result LSD (Product = 12)
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Memory Location Value (Hex) Description
9003H 00H Result MSD
For 04H × 03H = 0CH (12 decimal). The algorithm adds 04H repeatedly 03 times: 04 + 04 + 04 = 0C.
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 05
16-Bit Division (Repeated Subtraction)
AIM
To write an assembly language program to perform division of two 16-bit numbers using the 8086
trainer kit via the repeated subtraction method.
PROGRAM CODE
; PROGRAM FOR DIVISION (Repeated Subtraction)
; INPUT: Dividend in location 9000H (1 byte)
; Divisor in location 9001H (1 byte)
; OUTPUT: Quotient in location 9002H
; Remainder in location 9003H
MOV BX, 9000H ; Load base address
MOV AL, [BX] ; AL = Dividend
INC BX
MOV AH, [BX] ; AH = Divisor
INC BX
MOV CL, 00 ; CL = Quotient counter (starts at 0)
MOV CH, 00
LOOP1:
CMP AL, AH ; Compare dividend with divisor
JC OVER1 ; If AL < AH, jump to OVER1 (72 06)
INC CL ; Quotient++
SUB AL, AH ; Dividend = Dividend - Divisor
JMP LOOP1 ; Repeat (EB F6)
OVER1:
MOV CH, AL ; CH = Remainder
MOV [BX], CL ; Store Quotient at 9002H
INC BX
MOV [BX], CH ; Store Remainder at 9003H
INT RSTINT ; Halt
ALGORITHM
Step 1: Start.
Step 2: Load dividend from 9000H into AL; load divisor from 9001H into AH.
Step 3: Initialize CL = 00H (quotient counter).
Step 4: LOOP: Compare AL with AH (CMP AL, AH).
Step 5: If AL < AH (Carry Flag set), jump to OVER1.
Step 6: Otherwise, increment CL (quotient++), subtract AH from AL.
Step 7: Go back to step 4.
Step 8: OVER1: The remaining value in AL is the Remainder — move to CH.
Step 9: Store Quotient (CL) at 9002H, Remainder (CH) at 9003H.
Step 10: Halt.
RESULTS
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Memory Location Value (Hex) Description
9000H 09H Dividend (9 decimal)
9001H 04H Divisor (4 decimal)
9002H 02H Quotient (9 ÷ 4 = 2)
9003H 01H Remainder (9 mod 4 = 1)
For 09H ÷ 04H: 9 − 4 = 5 (count=1), 5 − 4 = 1 (count=2), 1 < 4 → stop. Quotient = 02H, Remainder =
01H.
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
3. LAB 2 — Array Processing & String Operations
EXPERIMENT 06
Finding the Maximum Value in an Array
AIM
To write an assembly language program to find the maximum (largest) value in an array of 14 bytes
stored in memory, using the 8086 trainer kit.
PROGRAM CODE
; PROGRAM TO FIND THE MAXIMUM VALUE IN AN ARRAY
; Array of 14 bytes starts at 9000H
; Result (maximum value) stored at 9400H
ORG 840CH
MOV BX, 9000H ; BX = pointer to array start
MOV CL, 0EH ; CL = element count (14 elements)
MOV AH, 00 ; AH = current maximum (initialize to 0)
L1:
MOV AL, [BX] ; AL = current array element
CMP AL, AH ; Compare current element with max
JC L2 ; If AL < AH, skip (Carry Flag set)
MOV AH, AL ; Update max: AH = AL
L2:
INC BX ; Advance array pointer
DEC CL ; Decrement counter
JNZ L1 ; Loop if not done
MOV BX, 9400H ; Point to result location
MOV [BX], AH ; Store maximum value
INT 3 ; Halt
ALGORITHM
Step 1: Start.
Step 2: Load the array base address 9000H into BX.
Step 3: Load element count 0EH (14) into CL.
Step 4: Initialize AH = 00H as the current maximum.
Step 5: LOOP (L1): Load array element [BX] into AL.
Step 6: Compare AL with AH (current maximum).
Step 7: If AL < AH (carry set), skip to L2 — current max is still larger.
Step 8: Otherwise, update max: AH = AL.
Step 9: L2: Increment BX (advance pointer), decrement CL.
Step 10: If CL ≠ 0, jump back to L1.
Step 11: Store the final maximum (AH) at 9400H.
Step 12: Halt.
RESULTS
Sample array (14 bytes at 9000H–9000DH):
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Address Value (Hex) Note
9000H 05H
9001H 12H
9002H 0AH
9003H FFH Maximum
... ... Other elements
9400H FFH Stored maximum result
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 07
Exchange of Numbers — Copying Array Between Memory Locations
AIM
To write an assembly language program to copy (exchange) 5 bytes from one array (arr1) to another
memory region (Arr2) using the 8086 trainer kit.
PROGRAM CODE
; PROGRAM FOR ARRAY EXCHANGE / COPY
; Copies 5 bytes from arr1 (source) to Arr2 (destination)
ORG 8400H
MOV AX, @D16-bit ; Load data segment value
MOV DS, AX ; Initialize Data Segment register
LEA SI, arr1 ; SI = source array start address
LEA DI, Arr2 ; DI = destination array start address
MOV CX, 05 ; CX = count (5 bytes)
LOOP:
MOV AL, [SI] ; Load byte from source
MOV [DI], AL ; Store byte to destination
INC SI ; Advance source pointer
INC DI ; Advance destination pointer
DEC CX ; Decrement counter
JNZ LOOP ; Repeat if not zero
RET ; Return
ALGORITHM
Step 1: Start.
Step 2: Initialize the Data Segment (DS) register.
Step 3: Load the effective address of arr1 into SI (source pointer).
Step 4: Load the effective address of Arr2 into DI (destination pointer).
Step 5: Set CX = 05H (number of bytes to copy).
Step 6: LOOP: Load byte from [SI] into AL.
Step 7: Store AL into [DI].
Step 8: Increment both SI and DI.
Step 9: Decrement CX.
Step 10: If CX ≠ 0, go to step 6.
Step 11: Return / Halt.
RESULTS
After execution, the 5 bytes originally stored at arr1 will appear identically at Arr2.
Byte Index Source (arr1) Destination (Arr2) After Copy
Byte 0 AAH AAH
Byte 1 BBH BBH
Byte 2 CCH CCH
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Byte Index Source (arr1) Destination (Arr2) After Copy
Byte 3 DDH DDH
Byte 4 EEH EEH
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 08
Factorial Value of a Number (Hex Number)
AIM
To write an assembly language program to compute the factorial of a hexadecimal number stored in
memory using the 8086 trainer kit.
PROGRAM CODE
; PROGRAM FOR FACTORIAL VALUE OF A NUMBER (HEX)
; Input: Number N stored at 9000H
; Output: N! stored at 9001H (16-bit result)
ORG 8400H
MOV BX, 9000H ; BX = pointer to input number
MOV CL, [BX] ; CL = N (the number to compute factorial for)
INC BX ; Advance to result location
MOV CH, 00 ; CH = 0 (CX = N as 16-bit)
MOV AX, 00 ; AX = accumulator (sum = 0 initially)
ADDLOOP1:
ADD AX, CX ; AX = AX + CX
DEC CL ; CL-- (count down from N to 1)
JNZ ADDLOOP1 ; Loop until CL = 0
MOV [BX], AX ; Store result at 9001H
INT 3 ; Halt
NOTE ON IMPLEMENTATION
The given program computes the triangular number (sum 1+2+...+N) via repeated addition, NOT the
true factorial (N!). This is because the 8086 MUL instruction is not used. The sum 1+2+...+N =
N(N+1)/2. For true factorial computation, repeated multiplication using a loop with the MUL instruction
would be required.
ALGORITHM (As Implemented — Triangular Sum)
Step 1: Start.
Step 2: Load N from 9000H into CL; CH = 00H → CX = N.
Step 3: Advance BX to result address 9001H.
Step 4: Initialize AX = 0000H.
Step 5: LOOP: AX = AX + CX.
Step 6: Decrement CL.
Step 7: If CL ≠ 0, go to step 5.
Step 8: Store AX at [BX] (9001H).
Step 9: Halt.
RESULTS
Input N (Hex) Sum 1+2+...+N (Decimal) Result (Hex)
03H 6 0006H
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Input N (Hex) Sum 1+2+...+N (Decimal) Result (Hex)
04H 10 000AH
05H 15 000FH
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
EXPERIMENT 09
Comparing Two Strings
AIM
To write an assembly language program to compare two strings of 5 bytes each stored in memory and
store 01H if strings are identical, or 00H if they differ, using the 8086 trainer kit.
PROGRAM CODE
; PROGRAM FOR COMPARING TWO STRINGS
; String 1: 5 bytes starting at 9000H
; String 2: 5 bytes starting at 9100H
; Result: 01H at 9400H if equal, 00H if not equal
ORG 8400H
MOV BX, 9000H ; BX = pointer to String 1
MOV SI, 9100H ; SI = pointer to String 2
MOV CL, 05H ; CL = string length (5 bytes)
CHECK1:
MOV AL, [BX] ; AL = byte from String 1
MOV AH, [SI] ; AH = byte from String 2
CMP AL, AH ; Compare the two bytes
JNZ OVER1 ; If not equal, jump to OVER1
INC BX ; Advance String 1 pointer
INC SI ; Advance String 2 pointer
DEC CL ; Decrement length counter
JNZ CHECK1 ; Continue if more bytes remain
; All bytes matched — strings are equal
MOV AL, 01 ; AL = 01H (equal)
MOV BX, 9400H ; Point to result address
MOV [BX], AL ; Store 01H at 9400H
INT 3 ; Halt
; NOTE: OVER1 (not equal path) should store 00H at 9400H
; Add these lines for complete program:
; OVER1:
; MOV AL, 00
; MOV BX, 9400H
; MOV [BX], AL
; INT 3
ALGORITHM
Step 1: Start.
Step 2: Load BX = 9000H (pointer to String 1).
Step 3: Load SI = 9100H (pointer to String 2).
Step 4: Set CL = 05H (string length = 5 bytes).
Step 5: CHECK1: Load byte from [BX] into AL.
Step 6: Load byte from [SI] into AH.
Step 7: Compare AL with AH.
Step 8: If AL ≠ AH (ZF = 0), jump to OVER1 — strings differ.
Step 9: Increment BX and SI; decrement CL.
Step 10: If CL ≠ 0, go to step 5.
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
Step 11: All bytes matched — store 01H at 9400H; halt.
Step 12: OVER1: Store 00H at 9400H; halt.
RESULTS
String 1 (9000H–9004H) String 2 (9100H–9104H) Result at 9400H
41 42 43 44 45 41 42 43 44 45 01H (Strings Equal)
41 42 43 44 45 41 42 43 44 46 00H (Strings Not Equal)
The comparison proceeds byte by byte. At the first mismatch, the program immediately branches to
OVER1 and records 00H, saving unnecessary comparisons.
Department of Electrical, Control, Telecommunication and Computing Page
Technical University of Kenya | Microprocessor Systems & Applications B (Lab) 8086 Lab Report
4. Conclusion
These nine experiments provide a comprehensive introduction to assembly language programming on
the 8086 microprocessor. The key findings and learning outcomes from both lab sessions are
summarized below:
LAB 1 — Arithmetic Operations (Experiments 01–05)
• 16-bit addition and subtraction were performed using the ADD and SUB instructions with zero-
extended 8-bit operands.
• Multiplication was implemented via repeated addition using a LOOP, since the MUL instruction
is not used in the trainer kit approach. For N iterations, the multiplicand is added N times to
obtain the product.
• Division was implemented via repeated subtraction — continually subtracting the divisor from
the dividend and counting iterations to obtain the quotient and remainder.
• The sum of 16 memory locations was computed using a loop with a byte counter, accumulating
results into a 16-bit register pair.
LAB 2 — Array Processing & String Operations (Experiments 06–09)
• Maximum value search iterates through all array elements, comparing each to a running
maximum register (AH), updating it when a larger value is found.
• Array copying between memory regions uses SI/DI index registers in a loop — a technique that
directly maps to the MOVSB string instruction in advanced programming.
• The factorial/sum program demonstrates accumulation loops and the use of CX as both data
and a loop counter.
• String comparison byte-by-byte demonstrates early exit loops (JNZ OVER1 on mismatch) and
result encoding (01H/00H flag), forming the basis for CMPSB-based string operations.
Overall, these experiments reinforce the fundamental principles of 8086 assembly programming:
register usage, memory addressing, loop structures with counters, and conditional branching using the
flag register. These skills are directly applicable to low-level embedded systems and microcontroller
programming.
Department of Electrical, Control, Telecommunication and Computing Page