Using ASM To Show DateTime

This is a comprehensive program , It well demonstrates CPU 8086 of the commonly used registers and commonly used instructions. it is beautiful similar as c !

When this program running it will show characters like ‘18/09/02 17:33:22’ ! But it isn`t easy !

IDE: MASMPlus
OS : Virtual Machine Windows XP
Lang: ASM x86 EXE

//Using C/CPP to describe this program, just like:
int getDate(int al,int ah){
    ...
}
int Display(int BCD, char ch, int step){
    int al = BCD;
    int ah = null;
    char det = ch;
    getDate(&al,&ah);
    for(int i=3;i>0;i--){
        ....
        if(i == 1){
            det=' ';
        }else{
            det = ch;
        }
        ....
    }
 
}
int main(){
    Read From CMOS...
    .....
    Display(9,'/',1);
    Display(4,':',2);
    getch();
    return 0;
}

This is the source code of the program :

;#Mode=DOS
 
.model small
.CODE
 
main: ;Write to the port 70h cell address to be accessed.
      mov bx, 0b800h ;GUI RAM
      mov es, bx
      mov si, 0
       
      mov cx, 3
      mov DS:[2], '/'
      mov DS:[3], 1
      mov al, 9; 0sec 2min 4hou 7day 8mon 9yer
      call Display
       
      mov cx, 3
      mov DS:[2], ':'
      mov DS:[3], 2
      mov al, 4; 0sec 2min 4hou 7day 8mon 9yer
      call Display
       
      mov ah, 1
      int 21h
      mov ax,4c00h
      int 21h
       
getDate: 
      out 70h,al
      in al,71h
      mov ah,al ;al reads data from port 8 of CMOS RAM.
      mov cl,4
      shr ah,cl
      and al,00001111b
      add ah,30h
      add al,30h
      ret
 
Display: 
      mov DS:[4], al
      mov DS:[5], cx
      call getDate
      mov byte ptr es:[si+2],ah
      mov byte ptr es:[si+2+2],al
      add si,4
      cmp DS:[5],1
      je flagelse
flagif:
      mov al, DS:[2]
      jmp flagCOM
flagelse:
      mov al, ' '
      jmp flagCOM
flagCOM:
      mov byte ptr es:[si+2], al
      add si,2
      mov cx, DS:[5]
      mov al, DS:[4]
      sub al, DS:[3]
      loop Display
      ret
       
END main