1,105,334 Community Members

display system time using int 21 ah = 2ch

Member Avatar
xellos
Newbie Poster
11 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

can someone show me how to display the system time ?

Member Avatar
wildgoose
Practically a Posting Shark
891 posts since Jun 2009
Reputation Points: 420 [?]
Q&As Helped to Solve: 102 [?]
Skill Endorsements: 0 [?]
 
0
 

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
Member Avatar
xellos
Newbie Poster
11 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

tank you but how can i print it to the screen

Member Avatar
wildgoose
Practically a Posting Shark
891 posts since Jun 2009
Reputation Points: 420 [?]
Q&As Helped to Solve: 102 [?]
Skill Endorsements: 0 [?]
 
0
 

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'
Member Avatar
Nathan Campos
Junior Poster
189 posts since Jul 2009
Reputation Points: 23 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
xellos
Newbie Poster
11 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i still dont understand how to display it properly

Member Avatar
wildgoose
Practically a Posting Shark
891 posts since Jun 2009
Reputation Points: 420 [?]
Q&As Helped to Solve: 102 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
Nathan Campos
Junior Poster
189 posts since Jul 2009
Reputation Points: 23 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NotNull
Posting Whiz in Training
211 posts since Oct 2008
Reputation Points: 23 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 0 [?]
 
0
 

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
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article