Nemo
Nemo

Reputation: 85

Display system time using int 21h, 2Ch

I'm trying to display the system time using int 21h, 2Ch so I started by displaying the hour in CH but I get no output and I don't know why. Could you please help? Here's the first piece of my code:

Data_segment_name  segment  para 

H db ?
hh db ?
M db ?
mm db ?

Data_segment_name ends


Stack_segment_name segment para stack



Stack_segment_name ends


Code_segment_name segment 

Main_prog  proc far

    assume SS:Stack_segment_name,CS:Code_segment_name,DS:Data_segment_name

    mov AX,Data_segment_name         ; load the starting address of the data
    mov DS,AX                        ; segment into DS reg. 

    mov ah,2ch
    int 21h

    mov ah,ch
    mov bl,10 
    div bl

    mov H,al
    mov hh,ah
    mov dl,30h
    add dl,H
    mov ah,02h
    int 21h

    mov dl,30h
    add dl,hh
    mov ah,02h
    int 21h



    mov ax,4c00h                     ; exit program

    int 21h


Main_prog      endp

Code_segment_name   ends
end Main_prog

Upvotes: 3

Views: 4069

Answers (1)

Fifoernik
Fifoernik

Reputation: 9899

For the sake of completeness and thanks to users Ruud and Elderbug, this is the correction for this program:

mov ah, 2ch
int 21h

mov al, ch
mov ah, 0

mov bl, 10 
div bl

Here's a shorter alternative for the rest of the code:

;;; No more need to store in variables
add  ax, 3030h         ;Convert together
push ax
mov  dl, al            ;H
mov  ah, 02h
int  21h
pop  dx
mov  dl, dh            ;hh
int  21h

Upvotes: 2

Related Questions