Could someone please look at this code and tell me why it is not working. I am trying to retrieve the number that is stored in the "Hundredths" section of the system time and output it to the screen.


.MODEL  SMALL                           
.STACK  100h                            

   Typed     DB  LF,LF,CR,' My answer is "$'
   CharTyped DB ?

        call Clock
        mov CharTyped,dl              
        call PutChar
        mov ax,@data
        mov ds,ax
        lea dx,Typed
        call PrintString
        call PutChar


        mov  ax,4c00h                 
        int  21h                      

;********************* Near procedure to print a char 

PutChar PROC                         
        mov ah,02h                     
        int 21h                       
PutChar ENDP                           

;******************* Near procedure to print a string 

PrintString PROC                        ;Define procedure
        mov  ah,9h                      ;DOS print string function #9
        int  21h                        ;display the string
        ret                             ;Return to calling procedure
PrintString ENDP                        ;End of procedure

;********************* Procedure to Read System Clock 

Clock PROC
        mov ah,2ch                    
        int 21h                  
Clock ENDP

END Main

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

7 Years
Discussion Span
Last Post by NotNull

You may want to start with the fact that you are trying to display a binary value in dl. You will need to convert it to ASCII before printing it.
Be advised that the value will probably be in 1/18th of a second increments for standard system clocks.


Here's a quick way to print out the value of DL.

mov al, dl ; value must be in range of 0-99
add ah, 30h
add al, 30h
push ax
mov dl, ah
mov ah, 2
int 21h
pop ax
mov dl, al
mov ah, 2
int 21h

Here is a routine for printing decimal values in ASCII.
Value is pushed onto stack, routine handles adjusting
stack for parameters.
Value is limited to 65,535

mov ax, 666
push ax
call printdec
mov ax, 123
push ax
call printdec

printdec_val dw 10000 ; divisor
push bp
mov bp, sp
push word [printdec_val]
mov ax, [bp+4]

push ax
xor dx, dx
div word [printdec_val] ; Number / PlaceValue
; Digit in AL

push ax
add al, 30h  ; Turn into ASCI digit
mov dl, al
mov ah, 2
int 21h   ; print character

cmp word [printdec_val], 1 ; check if at end
jz printdec_e

pop ax
xor ah, ah
mul word [printdec_val] ; digit * PlaceValue
pop bx
sub bx, ax ; subtract from number

push bx
mov bx, 10
mov ax, [printdec_val]
div bx  ; PlaceValue / 10 = new divisor
mov [printdec_val], ax

pop ax
jmp printdec_l
pop ax
pop ax
pop word [printdec_val]
pop bp
ret 2
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.