How to set 1 second time delay at assembly language 8086

Jer Yango picture Jer Yango · Mar 4, 2013 · Viewed 80.2k times · Source

My problem is that I have written a code that is supposed to output a result into a set of LEDs connected to the parallel port. When I ran the code it pretty much did nothing. My instructor told me that the code ran too fast that my eyes did not see what happened.

I have found that there are a couple of ways to do a time delay, I have tried to loop the NOP but I think I cannot really determine what is going on. Is there any better way?

I have here a part of the code where I have to add a time delay into:

org 100h

mov ax, 0
mov dx, 378
out dx, ax
mov ax, 1  

; 1st

mov cx, 1ah
start1st:
mov ax, 1
left:
out dx, ax 
; --------------------------------> how to loop?
mov bx, 2
mul bx
cmp ax, 80h
jl left
dec cx
cmp cx,0
jg start1st
; end 1st 

Answer

john picture john · Mar 4, 2014

Set 1 million microseconds interval (1 second) By using below instruction .

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

You can set multiple second delay by using 86H and INT 15H

check these links for more details

Waits a specified number of microseconds before returning control to the caller

INT 15H 86H: Wait