?
Solved

2digit number printing in assembler

Posted on 2005-05-13
7
Medium Priority
?
442 Views
Last Modified: 2008-03-03
Hello,

I want to display the clock on the screen
i'm using
mov ah,0
int 1ah

CX get the hours and dx get the minutes.

Now , How can I display 2-digit number which in cx and dx on the screen?

Regards,
Eyal Keren

BTW - without dividing by 10
0
Comment
Question by:eylkrn
7 Comments
 
LVL 14

Assisted Solution

by:StillUnAware
StillUnAware earned 400 total points
ID: 13998252
Here is the working code:


.Model Small
CommonSeg    segment
             assume CS:CommonSeg,DS:CommonSeg
             org  100h
start:

;                              INT 21,2C - Get Time
;        AH = 2C;
;
;        on return:
;        CH = hour (0-23)
;        CL = minutes (0-59)
;        DH = seconds (0-59)
;        DL = hundredths (0-99)
;        - retrieves DOS maintained clock time

mov ah, 2Ch
int 21h
push dx
xor ax, ax
mov al, ch
mov bl, 0Ah
div bl
mov bx, ax
mov dl, bl
add dl, 30h
mov ah, 02h
int 21h
mov dl, bh
add dl, 30h
int 21h
mov dl, 3Ah
int 21h
xor ax, ax
mov al, cl
mov bl, 0Ah
div bl
mov bx, ax
mov dl, bl
add dl, 30h
mov ah, 02h
int 21h
mov dl, bh
add dl, 30h
int 21h
mov dl, 3Ah
int 21h
pop dx
xor ax, ax
mov al, dh
mov bl, 0Ah
div bl
mov bx, ax
mov dl, bl
add dl, 30h
mov ah, 02h
int 21h
mov dl, bh
add dl, 30h
int 21h
mov ax, 4C00h
int 21h
CommonSeg ends
end start
0
 
LVL 22

Accepted Solution

by:
grg99 earned 1200 total points
ID: 13998692
To get the bottom digit you have to do a mod 10, to get the high minute digit you have to do a divive by ten.

Or just keep subtracting tens and keep track of the number of times.  A poor person's division.  

      mov    cx,0       ;  no tens yet

 lp:    sub    ax,10
         jlt      Done   ;; got all tens

        add   cx,1      ;;   one more ten
        jmp   lp

Done:
       sub    cx,1     ;; back up one
       add    ax,10  ;; restore remainder

0
 

Author Comment

by:eylkrn
ID: 13999080
Hi  grg99 '

My masm 6.15 doesnt recognize the "jlt Done".
is there any replacement for the jlt?

Regards,
Eyal
0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 

Author Comment

by:eylkrn
ID: 13999114
Hi  grg99 !

how stupid I am, jlt - Jump Less Than --> is-- >  jng - Jump Not Greater
 Hi  grg99 '
Eyal

0
 
LVL 3

Assisted Solution

by:Dawaffleman
Dawaffleman earned 400 total points
ID: 14002553
jlt = jl

you dont need to t
0
 

Author Comment

by:eylkrn
ID: 14055170
oK,
thanks Dawaffleman and grg99.
0
 

Author Comment

by:eylkrn
ID: 14055171
ah,
and thanks for StillUnAware  too..
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Applications for our next round of the Experts Exchange Scholarship Contest are starting to roll in. It made us wonder what our past winners are up to these days. Here's a look at what four winners experienced with the contest and what they're doing…
In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question