Hi guys I wanted to ask how to make the numbers 0 to 9 show up diagonally, vertically, and horizontally all at the same time.

My code must show something like this: (NOTE: Daniweb won't allow me to fill up those spaces with blanks so just imagine the "x" as blank spaces)

0 1 2 3 4 5 6 7 8 9
1 1
2 x 2
3 xxx 3
4 xxxxxx4
5 xxxxxxxx5
6 xxxxxxxxxx6
7 xxxxxxxxxxxx7
8 xxxxxxxxxxxxxx8
9 xxxxxxxxxxxxxxxx9

I was only able to do the horizontal and vertical directions and below is my code, anyone who can help me put up all the horizontal, vertical, diagonal at the same time?Thank you!

a100
mov Bl,30
mov CL,0A
mov AH,02
mov Dl,BL
int 21
mov AH,02
mov DL,20
int 21
inc BL
LOOP 106
mov Bl,31
mov CL,09
mov AH,02
MOV DL,0A
INT 21
MOV AH,02
MOV DL,0D
INT 21
MOV AH,02
MOV DL,20
INT 21
MOV AH,02
MOV DL,0D
INT 21
MOV AH,02
mov Dl,BL
int 21
mov AH,02
mov DL,0A
int 21
inc BL
LOOP 126
INT 20

You're not really doing it at the same time. Think of the output as a sequence of rows, and each row as a sequence of characters where the blank space between items is literally whitespace. So for each 'x' in your example, print a space character.

The pseudocode for the algorithm is this:

# Print the header row
for i = 0 to 9
    print i
    print space
end

print newline

# Print subsequent rows
for i = 0 to 9
    # Print the first number at column 0
    print i

    # Match the column of the second number
    for j = 0 to 9
        print space
    end

    # Print the second number at the matching column
    print i
    print newline
end

To be more efficient, you could move the cursor to the right position without wasting CPU ticks printing the spaces.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.