---
title: "8086 ALP: multiplication table of a number"
subject: "Microprocessor"
chapter: 3
key: "semester_4/microprocessor:alp-8086-multiplication-table"
source: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8086-multiplication-table
site: BCT Engineering
---

# 8086 ALP: multiplication table of a number

Microprocessor · Chapter 3: Programming with 8086 Microprocessor

- Asked in: 2068 Magh, 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8086-multiplication-table
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-3

## Question

Write a program in 8086 to read a number and display the multiplication table of that number.

## Short answer

The program reads a decimal number using READ_NUM (accumulates digits until Enter), then loops i=1 to 10, printing "N x i = N*i" using MUL and PRINT_DEC. Output example: for 7, it displays 7 x 1 = 7 through 7 x 10 = 70.

## Answer

**Method:** `READ_NUM` reads a multi-digit decimal number (digits are accumulated as value = value × 10 + digit until Enter is pressed). The program then prints `N x i = N*i` for i = 1 to 10. `MUL CX` gives N × i in DX:AX, and `PRINT_DEC` prints any value in AX in decimal.

```asm
.MODEL SMALL
.STACK 100H

DISPSTR MACRO MSG            ; display a '$'-terminated string
        LEA  DX,MSG
        MOV  AH,09H
        INT  21H
        ENDM

CLRSCR  MACRO                ; clear screen and home the cursor
        MOV  AX,0600H        ; scroll whole window (AL=0 -> blank it)
        MOV  BH,07H          ; normal attribute
        MOV  CX,0000H        ; upper-left corner (row 0, col 0)
        MOV  DX,184FH        ; lower-right corner (row 24, col 79)
        INT  10H
        MOV  AH,02H          ; set cursor position
        MOV  BH,00H          ; page 0
        MOV  DX,0000H        ; row 0, col 0
        INT  10H
        ENDM

.DATA
    MSG1  DB 'Enter a number: $'
    TMS   DB ' x $'
    EQS   DB ' = $'
    CRLF  DB 13,10,'$'
    NUM   DW ?

.CODE
MAIN PROC
    MOV  AX,@DATA
    MOV  DS,AX

    DISPSTR MSG1
    CALL READ_NUM          ; AX = number
    MOV  NUM,AX
    DISPSTR CRLF
    MOV  CX,1              ; multiplier i = 1
TBL:
    MOV  AX,NUM
    CALL PRINT_DEC         ; N
    DISPSTR TMS          ; " x "
    MOV  AX,CX
    CALL PRINT_DEC         ; i
    DISPSTR EQS            ; " = "
    MOV  AX,NUM
    MUL  CX                ; DX:AX = N * i
    CALL PRINT_DEC         ; product
    DISPSTR CRLF
    INC  CX
    CMP  CX,10
    JBE  TBL               ; repeat for i = 1..10
    MOV  AH,4CH            ; return to DOS
    INT  21H
MAIN ENDP

; ---- read a decimal number from the keyboard, result in AX
READ_NUM PROC
    PUSH BX
    PUSH CX
    PUSH DX
    XOR  BX,BX             ; BX = value accumulated so far
RN1:MOV  AH,01H            ; read a character with echo
    INT  21H
    CMP  AL,0DH            ; Enter ends the number
    JE   RN2
    SUB  AL,'0'            ; ASCII -> digit
    XOR  AH,AH
    MOV  CX,AX             ; CX = digit
    MOV  AX,10
    MUL  BX                ; AX = value * 10
    ADD  AX,CX             ; add the new digit
    MOV  BX,AX
    JMP  RN1
RN2:MOV  AX,BX             ; return value in AX
    POP  DX
    POP  CX
    POP  BX
    RET
READ_NUM ENDP

; ---- print the unsigned number in AX in decimal (registers preserved)
PRINT_DEC PROC
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    MOV  BX,10
    XOR  CX,CX             ; digit counter
PD1:XOR  DX,DX
    DIV  BX                ; AX = quotient, DX = remainder (digit)
    PUSH DX
    INC  CX
    OR   AX,AX
    JNZ  PD1
PD2:POP  DX                ; digits come out in correct order
    ADD  DL,30H            ; to ASCII
    MOV  AH,02H
    INT  21H
    LOOP PD2
    POP  DX
    POP  CX
    POP  BX
    POP  AX
    RET
PRINT_DEC ENDP

END MAIN
```

**Output for 7:** `7 x 1 = 7` ... `7 x 10 = 70`.

## Check yourself

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

1. How does READ_NUM build a multi-digit number?
   A. value = value + digit
   B. value = value x 10 + digit until Enter
   C. value = digit x 10
   D. value = value / 10
   Answer: B. Each new digit shifts the earlier digits left decimally, which is done by multiplying by 10 and adding. (Key point: Reading number)

2. What does MUL CX give when AX holds N?
   A. N + CX in AX
   B. N x CX in DX:AX
   C. N / CX in AX
   D. N x CX in BX
   Answer: B. A 16-bit MUL multiplies AX by the operand and places the 32-bit result in DX:AX. (Key point: Multiplication)

3. How is the table limited to 10 lines?
   A. CX starts at 1 and the loop repeats while CX <= 10 (CMP CX,10 / JBE)
   B. CX starts at 0 and loops until zero
   C. The user enters the limit
   D. The loop stops when AX overflows
   Answer: A. CX is the multiplier i, incremented each time, and JBE continues while i is 10 or below. (Key point: Loop range)

4. What is subtracted from the typed key code to get a digit?
   A. 'A'
   B. 30
   C. 0DH
   D. '0'
   Answer: D. Subtracting ASCII '0' (30H) turns the key code into its value 0 to 9. (Key point: Number conversion)

## Related in Microprocessor

- [8085 ALP: multiplication table of a number](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-multiplication-table) — Microprocessor, chapter 2
- [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: alternate case display](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-alternate-case) — 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: display only alphabetic characters](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-alphabetic-only) — Microprocessor, chapter 3
- [8086 ALP: count vowels, consonants, numerals](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8086-count-vowels-consonants-numerals) — Microprocessor, chapter 3

## Related in other subjects

- [Complex number multiplication using structure](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astruct-complex-multiply) — Computer Programming, chapter 8
- [Prime number program: procedural and OOP](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aprime-procedural-oop) — Object Oriented Programming, chapter 1
- [Read records until end; show nth record](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-worker-nth-record) — Computer Programming, chapter 10, asked 2×
