0

Hi ,I am trying to print this ,so far unsuccessful,I am printing only the first row
Thanks

1  2  3  4  5  6  7  8  9 10 
             1  2  3  4  5  6  7  8  9 10 11 
             2  3  4  5  6  7  8  9 10 11 12 
             3  4  5  6  7  8  9 10 11 12 13 
             4  5  6  7  8  9 10 11 12 13 14 
             5  6  7  8  9 10 11 12 13 14 15 
             6  7  8  9 10 11 12 13 14 15 16 
             7  8  9 10 11 12 13 14 15 16 17 
             8  9 10 11 12 13 14 15 16 17 18 
             9 10 11 12 13 14 15 16 17 18 19 
            10 11 12 13 14 15 16 17 18 19 20
.386
.model Flat
include Cs266.inc
.data
start DD 0
finish DD 12
.code
first:
mov EDX,finish
mov EBX,start
inc EDX
inc EBX
putch 10

main:
cmp EBX,0
JE zero
putch ' '
putint EBX
inc EBX
cmp EBX,EDX
JB main
JE first
zero:      ;zero
putch ' '
inc EBX
jmp main
exit:
Ret
end

Edited by kukuruku: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by GunnerInc
0

Well, your logic is a bit off... print is a MASM macro that prints text to the console, just change print to what you use... putch and putint

mov     esi, 10                 ; only want 10 numbers printed
    xor     ebx, ebx
FirstRow:
    inc     ebx
    print str$(ebx), 32             ; print num + space
    dec     esi
    test    esi, esi                ; is our counter at zero?
    jnz     FirstRow                ; nope, print next number
    print  " ", 13, 10, 13, 10      ; done with first line

TheRest:    
    xor     edi, edi
    inc     edi
NextRow:
    mov     esi, 11                 ; we only want 11 columns and rows
    mov     ebx, edi                
NextCol:
    print str$(ebx), 32 
    dec     esi
    inc     ebx
    test    esi, esi                ; are we at end of column?
    jnz     NextCol                 ; nope, print next column
    print  " ", 13, 10 
    inc     edi
    mov     ebx, edi
    cmp     edi, 11                 ; are we at our last row?
    jl      NextRow                 ; nope, print next row
    
    print  " ", 13, 10              ; we made it here, we are done!
    ret
Attachments console.jpg 26.3 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.