Hi,
my problem is that the print-macro or StdOut seems to have some strange behaviour with long sz-Strings.
f.ex. a bytearray of NUMSIZE = 20000 bytes stores a packed BCD-number, initialized to a value of 1:
F1 db NUMSIZE - 1 dup(0),1
szNum holds the ASCII-representation of this number and it's length is NUMSIZE * 2
With NUMSIZE=20000 I get console output for print ADDR szNum of Fibonaci-number 191387 which has 39998 decimal digits.
With NUMSIZE > 20000 programm still works correct, shows correct number of dec-digits, but does not display szNum in the console window.
However, if I redirect console output to a file everything works fine!
f.ex. with 80000 dec-digits
c:\>fibgen
fails to print szNum (which len is 80000)
but
c:\> fibgen >fib.txt
works
why that?
rgds cobold
Did you try SetConsoleScreenBufferSize (http://msdn.microsoft.com/en-us/library/ms686044(VS.85).aspx)?
cobold,
Its a limitation of the Windows API, when data is written to a file it streams the data out so if you need the same charracteristic for display, read it at about 1k at a time and tile the output. This is streaming to the screen.
thanks to both of you for replying!
@jj2007:
thanks for the hint, but my console window buffer is 125 cols x 3000 lines = 375000 bytes, which should be more than enough to print a string with 80000 bytes, doesn't it?
@hutch:
Hope I understand correctly what you mean:
example: I have a zero-terminated string (lets call it szString) with a length of 53000 bytes. print ADDR szString,13,10 works.
However, if strlen > approx. 53000: is over operating-system limit, so if I want to print that string in console window need to "stream" it, right?
like:
szString db 100000 dup(32),0
szStream db 1000 dup(32),0
and then
.while cnt < len(szString)
mov blocks of 1000 bytes from szSting to szStream
print ADDR szStream
.end
Did I you mean that with streaming?
Thanks and regards
cobold
cobold,
basically yes, just look for a convenient way to break up the string into smaller units then display one after another. If your text is in column / row format, just pick how many rows at a time you can display.
hutch,
your hint helped me - but I still don't understand why the OS allows you to define a string of length let's say 100000 bytes but is not able to print it in console. What is the exact limit and why?
cobold
I imagine it had some to do with what they though would exceed all expectations when they wrote the function, a truly lousy design but there have been many like it. I vaguely remember the limit being about 10k on my win2000 box but this may change on earlier and later OS versions.
I have noticed the same problem myself. In the description of WriteFile api in win32 API help file there is some stuff about PIPED operations being limited to 64k (or 32k, I can't remember which). I think it's the property of the stdout console that it can be piped and so one is only allowed to output a fixed number of bytes at a time to allow the output to be piped to some other program.