真的没人会吗?在百度贴吧发贴都没人回答

bakerycn00001 2008-12-01 07:45:11
5.5 试编写一程序,要求能从键盘接收一个个位数N,然后响铃N次(响铃的ASCII码为07)。

答:程序段如下:

BEGIN: MOV AH, 1 ;从键盘输入一个字符的DOS调用

INT 21H

SUB AL, ‘0’

JB STOP ;输入字符<‘0’吗?

CMP AL, 9 ;输入字符>‘9’吗?

JA STOP

CBW

MOV CX, AX ;响铃次数N

JCXZ STOP

BELL: MOV DL, 07H ;准备响铃

MOV AH, 2 ;显示一个字符的DOS调用,实际为响铃

INT 21H

CALL DELAY100ms ;延时100ms

LOOP BELL

STOP: RET
答案书上给的答案,只给代码段,没编译通过呀,有高手帮忙吗,让他编译通过
...全文
133 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xtdumpling 2008-12-02
  • 打赏
  • 举报
回复
stack_seg segment 'stack'
dw 10h dup(0)
stack_seg ends
code_seg segment 'code'
assume ss:stack_seg
BEGIN: MOV AH, 1 ;从键盘输入一个字符的DOS调用

INT 21H

SUB AL, '0'

JB STOP ;输入字符 <‘0’吗?

CMP AL, 9 ;输入字符>‘9’吗?

JA STOP

CBW

MOV CX, AX ;响铃次数N

JCXZ STOP

BELL: MOV DL, 07H ;准备响铃

MOV AH, 2 ;显示一个字符的DOS调用,实际为响铃

INT 21H

CALL DELAY100ms ;延时100ms

LOOP BELL

STOP:; RET
mov ah,4ch
int 21h

delay100ms proc uses cx
mov cx, 100;;;;;
call delay_1ms
ret
delay100ms endp

delay_1ms proc near public uses ax cx
mov cx,60 ;63*15.8us=995.4us
@@:
in al,61h
and al,10h
cmp al,ah
je @b
mov ah,al
loop @b
ret
delay_1ms endp

code_seg ends
end BEGIN
xtdumpling 2008-12-02
  • 打赏
  • 举报
回复
stack_seg segment 'stack'
dw 10h dup(0)
stack_seg ends
code_seg segment 'code'
assume ss:stack_seg
BEGIN: MOV AH, 1 ;从键盘输入一个字符的DOS调用

INT 21H

SUB AL, '0'

JB STOP ;输入字符 <‘0’吗?

CMP AL, 9 ;输入字符>‘9’吗?

JA STOP

CBW

MOV CX, AX ;响铃次数N

JCXZ STOP

BELL: MOV DL, 07H ;准备响铃

MOV AH, 2 ;显示一个字符的DOS调用,实际为响铃

INT 21H

CALL DELAY100ms ;延时100ms

LOOP BELL

STOP:; RET
mov ah,4ch
int 21h

delay100ms proc uses cx
mov cx, 120
call delay_1ms
ret
delay100ms endp

delay_1ms proc near public uses ax cx
mov cx,60 ;63*15.8us=995.4us
@@:
in al,61h
and al,10h
cmp al,ah
je @b
mov ah,al
loop @b
ret
delay_1ms endp

code_seg ends
end BEGIN
juzinaiyou 2008-12-01
  • 打赏
  • 举报
回复
CALL DELAY100ms
那个delay100ms
子程序?也给补上。
authenticationf 2008-12-01
  • 打赏
  • 举报
回复
ding
filec75 2008-12-01
  • 打赏
  • 举报
回复
ding

21,458

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧