Digital Clock in assembly language is developed as an educational project to learn assembly language in more detail and have practical experience.


  1. The clock shows the time of the computer system.
  2. It shows hours, minutes and seconds.
  3. It uses 12 hour format.
  4. It is developed in VGA graphics with 320x200 resolution.
  5. It is displayed in a classy, stylish and attractive font.
  6. The interface is simplistic with white text on black background.


Digital Clock in assembly home screen

How to use

  1. Download TASM for windows and install.
  2. Build the program and run it.

How it works

  1. First we define two macros for later uses. One for drawing rows and another for drawing columns. We send the row, column and color values as parameters for the macros.
  2. We then set the video mode for our display operation.
  3. Since we are going to use 1CH in order to continuously refresh the screen, we set the interrupt vector for 1CH.
  4. The routine which will be executed each time the 1CH interrupt is generated, is defined.
  5. In the routine, we first generate interrupt to get the current time from the system.
  6. As the time is returned into the registers, we use those values to convert that time to a string for ease in later tasks.
  7. We define ten functions each for displaying each digit from 0 to 9.
  8. Each digit is created using the macros defined earlier. We draw rows and columns for the digits accordingly.
  9. Before a digit is printed on the screen, we first clear the screen since it will have the previously displayed digit on the screen.
  10. As the screen keeps getting refreshed continuously, the program waits for a key to be pressed in order to terminate the program.
  11. As a key is pressed the display is set back to text mode and the program terminates and returns control to DOS.

Interrupts used in the program

INT 10H:

This interrupt is used to execute graphics based routines.
AH = 00H; set graphics mode
AL = 13H; graphics mode VGA 320 x 200 256 color

AH = 0CH; draw pixel
AL = color
BH = page
CX = column
DX = row

INT 16H:

The bios interrupt 16H routine is the key-board driver. In order to take an input from the keyboard we have used this interrupt where the function value 00H was stored in AH.
AH = 00H; wait for a key press

INT 21H:

This is a DOS interrupt. It is used to request different DOS function. The function value is stored in AH. In our program we have used three functions.
AL = interrupt number
AH = 35H; gets interrupt vector stored in AL
INT 21H; returns the address to ES:BX

AL = interrupt number
AH = 25H; sets interrupt vector stored in AL
INT 21H; sets the vector to DS:DX

AH = 2CH; gets the current time, CH = hour, CL = minute, DH = second
INT 21H;

AH = 4CH; returns program to DOS
INT 21H;


The 1CH interrupt is automatically generated by an internal clock circuit. It is generated about 18.2 times per second on an average. We can define a routine for this interrupt which will be executed every time the interrupt is generated. Since we need to continuously refresh the display, we simply define a routine to refresh the display.