Hi..
This is my fist time, I need your help guys to figure out what is the problem with my code. My program is to show time in this format " TIME:Hours : minute : seconds : Hunderthseconds" , but , the problem is that it didn't show correct numbers, it shows me just charachers I don't understand. As far as I know function AH = 2CH INT 21H, returns ASCII code for time " CH=hour, CL = minutes, DH = seconds, DL = 5/100 seconds"
... So, could you please figure out what is wrong with this code,
Thank you very much.

TITLE " Project "
.MODEL SMALL
.STACK 200
.DATA
         MSG1 DB 'TIME:$'
         MSG2 DB  ?,'$'
.CODE
MAIN PROC
        MOV AX, @DATA    ; get the address of the data segment
        MOV DS, AX       ; and store it n register DS
        MOV AH, 9        ; display string function
        LEA SI, MSG1     ; get memory location of first message
        MOV DX, SI       ; and store it in the DX register
        INT 21H
        MOV AH, 2CH      ; Get time function 2CH interrupt 21H
        INT 21H   
        LEA DI, MSG2  ; Get MSG2 address
        MOV BH, 3AH  ; Copy the ASCII code for :
        MOV [DI], CH     ; Copy hours into MSG2
        CALL WRITING  ; call function Writing to write it on the standard output "screen"
        MOV [DI], BH     ; Copy minutes
        CALL WRITING  ; call function writing
        MOV [DI], CL
        CALL WRITING
        MOV [DI], BH
        CALL WRITING
        MOV [DI], DH
        CALL WRITING
        MOV [DI], BH
        CALL WRITING
        MOV [DI], DL
        CALL WRITING
 MOV AH, 07
 INT 21H
        MOV AX,4C00H    ; Exit to DOS function
        INT 21H
MAIN ENDP
WRITING PROC
        PUSH DX  ; Save value of DX
        MOV AH, 02 ; Function 02 of interrput 21H to write character to stander output
        MOV DL, MSG2 ; Copy content of MSG2 into DL
        INT 21H 
        POP DX  ; get the original value of DX again.
        RET
WRITING ENDP
END MAIN

interrupt 2c returns binary numbers, not ascii. You have to convert them to ascii before displaying them.

Thanks a lot man ... I really appreciate it :)
Best regards

I'm sorry, what should I do to change these to ASCII representation ^^.. Thanks again.

Here are some examples

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.