-5

I am writing a program to print 00 to 60 in 60 seconds delay! But somehow it is not working! Can you guys help?

org 100h

.model small
.stack 100h
.data 
  a db 0
  b db 0
.code 
  main PROC
    mov cx,100 
  secnd:
    mov bl,a
    add bl,48
    mov bh,b
    add bh,48
    mov ah,2
    mov dl,bl
    int 21h

    mov ah,2
    mov dh,bh
    int 21h

    mov ah,2
    mov dl,0dh
    int 21h

    mov dl,0ah
    int 21h 

    MOV  CX, 0FH
    MOV  DX, 4240H
    MOV  AH, 86H
    INT  15H

    inc a
  loop secnd
    ret
Ross Ridge
  • 38,414
  • 7
  • 81
  • 112

1 Answers1

2

Your program has a few problems:

  • Since the BIOS call used CX as one of its parameters, you effectively have destroyed your loop-control variable! push/pop it:

     mov  cx,100 
    secnd:
     PUSH CX
     ...
     POP  CX
     loop secnd
     ret
    
  • You're treating the a variable as tenths and the b variable as units, but you only change the former one with a single inc a.
    You could choose this approach:

     ...
     inc b
     cmp b,10
     jb  done
     mov b,0
     inc a
    done:
     POP  CX
     loop secnd
     ret
    
Sep Roland
  • 33,889
  • 7
  • 43
  • 76