can someone show me how to display the system time ?

Recommended Answers

All 8 Replies

In its simplest form

mov ah,0
   int  1Ah    ; TIME - Get System time
       ; CX:DX = number of clock ticks since midnight
       ;  AL = midnight flag

There are approx. 18.2 clock ticks per second.

If you mean the Real-time clock

mov ah,2
  int  1Ah    ; TIME - Get Real-Time Clock Time
     ; Carry Flag = 0 if successful    set if error
     ; ch = hour (BCD)
     ; cl = minutes (BCD)
    ; DH = seconds (BCD)
    ; dl   1=daylight savings 0=Standard

tank you but how can i print it to the screen

Convert decimal to ASCII and print character by character, or put into a buffer then print buffer!

if (num >9)
     dig = num / 10
     if (dig)
          print dig+'0'
     num = num % 10

print num+'0'

huh, very interesting, i'm going to write a program like this!

i still dont understand how to display it properly

I've already posted this. You need to make an attempt to use this logic in code or I can't help as is the policy of this board!

if (num >9)
     dig = num / 10
     if (dig)
          print dig+'0'
     num = num % 10

print num+'0'

Your time 12:59:59 Hour:Min:Sec are the biggest numbers thus 8-bit works fine.

; ax = number    Ex: minutes 0...59
  mov bl,10
  div  bl
    ; al = Quotient ah = remainder
    ; al = ax/10    ah=ax mod 10

So minutes al = {0...5} ah = {0...9}
But ASCII digits '0'...'9' are hex values 030h...039h
so by adding 030h to al, and ah
add al,'0' ; al = {'0'...'9'}
So the best way is to store in a buffer to print, then print the buffer.

huh, that's cool!
You explain very nice wildgoose!

Here is a really cool piece of code for printing out
the decimal representation of values.
The amount of digits can even be adjusted!
Value to be printed is placed on the stack.
Enjoy!

bits 16
org 100h

start:
push 1234
call putdec_w
add sp,2
ret

putdec_val dw 0
putdec_dec_conv equ 30h
putdec_cnt dw 10000
putdec_dig db 0
putdec_digits dw 5

putdec_w:
push bp
mov bp,sp
pusha
push word [putdec_cnt]
mov ax, word [bp+4]
mov word [putdec_val], ax
mov cx, word [putdec_digits]
putdec_getdigit:
xor dx, dx
mov ax, word [putdec_val]
div word [putdec_cnt]       
mov byte [putdec_dig], al   
add al, putdec_dec_conv     
mov dl, al           
mov ah, 02h          
int 21h              

xor dx,dx
xor ax,ax
mov al, byte [putdec_dig]   
mov bx, word [putdec_cnt]   
mul bx               
                     


sub word [putdec_val], ax   
          
xor dx, dx
mov ax, word [putdec_cnt]
mov bx, 10
div bx               


mov word [putdec_cnt], ax  
                     
dec cx
jz putdec_exit
jmp putdec_getdigit
putdec_exit:
pop word [putdec_cnt]
popa
pop bp
ret
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.