Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
im trying to get this output

999999999
88888888
7777777
666666
55555
4444
333
22
1

with this code

ASM
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:

VB
9
88888888
7777777
666666
55555
4444
333
22
1


what am i doing wrong?
Posted
Updated 28-Feb-14 6:07am
v2
Comments
Sergey Alexandrovich Kryukov 28-Feb-14 12:04pm    
How about using the debugger?
—SA
Member 10548351 28-Feb-14 12:11pm    
my mistake on the '1' and inc
i already changed the code
anyway it seems the loop starts on 8, how do i make it start on 9?
if i adjust the cl counter to 9 it goes on a sort of crazy loop of zeros
Richard MacCutchan 28-Feb-14 12:34pm    
You only print the first digit once, followed by new line. You should put it as part of the main loop and add the newline characters after printing all the digits, not before.

1 solution

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
 
Share this answer
 
Comments
Member 10548351 28-Feb-14 12:14pm    
how do i use the debugger too, im sort of a beginner...sorry
and im using a dosbox since my laptop is in 64-bit
Sergey Alexandrovich Kryukov 28-Feb-14 13:36pm    
I never used DOSBox, and this is unrelated to the problem. If you develop under DOS (mind you, this is extremely rare these days, I bet most younger developers never saw it), you should have some code debugger.

Please see: http://stackoverflow.com/questions/1645479/need-a-debugger-for-dos-assembly.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900