如何在汇编语言 8086 中设置 1 秒延迟 [英] How to set 1 second time delay at assembly language 8086

查看:393
本文介绍了如何在汇编语言 8086 中设置 1 秒延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我编写了一个代码,应该将结果输出到一组连接到并行端口的 LED 中.当我运行代码时,它几乎什么也没做.我的导师告诉我,代码运行得太快了,我的眼睛没有看到发生了什么.

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.

我发现有几种方法可以进行时间延迟,我尝试循环 NOP,但我认为我无法真正确定发生了什么.有没有更好的办法?

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 

推荐答案

我最终使用的是 nop 循环

What i finally ended up using was the nop loop

; start delay

mov bp, 43690
mov si, 43690
delay2:
dec bp
nop
jnz delay2
dec si
cmp si,0    
jnz delay2
; end delay

我使用了两个寄存器,我将它们都设置为任何高值它会继续循环,直到两个值都为零

I used two registers which I set them both to any high value and its gonna keep on looping until both values go to zero

我在这里使用的是 AAAA 用于 SI 和 BP,我最终每个延迟循环大约需要 1 秒.

What I used here was AAAA for both SI and BP, i ended up with roughly 1 second for each delay loop.

感谢你们的帮助,是的,我们仍然使用 MS DOS 来学习这个汇编语言课程 :(

Thanks for the help guys, and yes, we still use MS DOS for this assembly language course :(

这篇关于如何在汇编语言 8086 中设置 1 秒延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆