你能告诉我这个代码的错误吗? [英] can you tell what im doin wrong with this code

查看:118
本文介绍了你能告诉我这个代码的错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获得此输出



999999999

88888888

7777777

666666

55555

4444

333

22

1



使用此代码



im trying to get this output

999999999
88888888
7777777
666666
55555
4444
333
22
1

with this code

Title F3 MFS
DOSSEG
.MODEL SMALL
.STACK 0100H
.DATA

.CODE

    mov ax,@data
    mov ds,ax

    mov cl,008h
    mov bh,009h
    mov ah,02
    mov dl, '1'
    int 21h
 B: mov dh,dl
    mov dl,0ah
    int 21h
    mov dl,0dh
    int 21h
    mov bl,cl
    dec bh
    dec dh
    mov cl,bh
    mov dl,dh
 C: int 21h
    loop C
    mov cl,bl
    loop B


    mov ah, 4ch
    int 21h

end





和我得到的输出是:





and the output im getting is:

9
88888888
7777777
666666
55555
4444
333
22
1





我做错了什么?



what am i doing wrong?

推荐答案

使用调试器,你会很容易找到问题。由于将 bh 的值分配给它,看起来你第一次使用 cl 作为计数器丢失了,最初是1,所以'9'只重复一次。这样的事情。这是一个小虫子;而你几乎就在那里。只需使用调试器。



-SA
Use the debugger and you will easily find the problem. It looks like your very first assignment to cl used as a counter is lost due assigning of the value of bh to it, which is initially 1, so '9' is repeated only once. Something like that. This is a tiny bug; and you are almost there. Just use the debugger.

—SA


这篇关于你能告诉我这个代码的错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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