Display integers in aligned columns in MASM Assembly
<p>I have been struggling to get this to work for days and have had no luck getting it to work.  I would really appreciate some help figuring this out.</p>

<p>(This is in MASM Assembly and the only library allowed is the Irvine Library)</p>

<p>The program is a basic Fibonacci number generator.  It takes user input from 1-46 (<em>n</em>)and then prints the Fibonacci sequence up to the <em>nth</em> term.</p>

<p>The output should be 5 terms per row with at least 5 spaces in between.  This part works.</p>

<p><em>Edit*</em>  The part I am having issues with is getting the output to line up in columns when the integer length is greater than 7 digits.</p>

<p>I attempted to implement this by passing a TAB to the console which works but only up to 7 digit long integers.  I understand why this is but I can't find a way around it.  I tried printing spaces of varying length to no avail.  My guess is that I either need to count the length of the integer and print the correct number of spaces based on the length after row 7 or use Gotoxy() from the Irvine library but I am having trouble wrapping my head around exactly how.</p>

<p>Here is the output-  </p>

<pre><code>1               1               2               3               5

8               13              21              34              55

89              144             233             377             610

987             1597            2584            4181            6765

10946           17711           28657           46368           75025

121393          196418          317811          514229          832040

1346269         2178309         3524578         5702887         9227465

14930352                24157817                39088169                  63245986                102334155
165580141               267914296               433494437               701408733               1134903170
1836311903              Press any key to continue . . .
</code></pre>

<p>Here is the relevant code...</p>

<pre><code>mov     rowPosition,1           ;assign initial row positon 
mov     currentTerm, 0          ;makes first two terms 1
mov     previousTerm, 1
mov     ecx, nthTerm            ;set counter to nth term 

printFib:       
            mov     eax,currentTerm
            mov     ebx,currentTerm     ;mov current term to ebx to hold  value
            add     eax,previousTerm    ; = currentTerm + previousTerm
            call    WriteDec            ;writes new term
            mov     currentTerm,eax     ;set newly calculated term to currentTerm
            mov     previousTerm,ebx    ;set previousTerm to equal current Term

            mov     al, 9               ; ASCII CHAR 9 =  TAB
            call    WriteChar           ;writes tab to align text
            call    WriteChar

            cmp     rowPosition, 5      ;checks postion in row
            jge     newRow              ;jump if rowPostion greater than or equal to 5
            inc     rowPosition         ;else increment rowPosition
            loop    printFib            ;If ECX!=0 Loop to printFib 
            jmp     goodbye

newRow:     call        crlf            ; move to next row
            mov         rowPosition, 1  ;reset row postion to 1
            loop        printFib        ;If ECX!=0 Loop to printFib 
</code></pre>

<p>Can anyone please point me in the right direction?</p>