Hi I was wondering how you can write a super long string in
ASM, I want it for CGI's

Does the function StdOut only take up to so many characters

Anyway I find I have to do this

string1 db "yyyyyyyyyyyy" <----strings much longer
string2 db "xxxxxxxxxxx"
string3 db "zzzzzzzzzzzz"

invoke StdOut , addr string1
invoke StdOut , addr string2
invoke StdOut , addr string3

when I wish I coud just do this

string db "yyyyyyyyyyyyxxxxxxxxxxxxxxzzzzzzzzzzzz"
invoke StdOut, addr string

Is there away to do this?

Thanks

Andy981
Posted on 2002-06-01 12:38:56 by andy981
I haven't tried it, but I guess this might work?
	lea eax,string

@B: invoke StdOut, eax ; returns bytes written
lea eax, string[eax] ; end of string written
cmp BYTE PTR [eax],0
jne @B
Posted on 2002-06-01 13:12:35 by bitRAKE
Thanks BitRake, I haven't tried it but that looks like it will work,
I did try something other than StdOut, and I still had the same problem.


Andy981
Posted on 2002-06-01 15:52:11 by andy981
invoke WriteFile, hStdOut, addr httpHeaders, len_httpHeaders, addr BytesWritten, NULL

This is a line from what Thomas showed me in November, beasically what I'm sure you already know, there are other ways to print to a screen besides StdOut, but I believe as I remember having the same problem of limited output


Thanks Andy981
Posted on 2002-06-01 15:57:36 by andy981
That is what StdOut does - it is just a wrapper around the API you posted. ;) Look on MSDN for the console functions for many other ways to write to the console.
Posted on 2002-06-01 16:34:36 by bitRAKE
lea eax,string
@B: invoke StdOut, eax ; returns bytes written
lea eax, string ; end of string written
cmp BYTE PTR ,0
jne @B


It works, but I have not fully bench tested it, I'll have to make a giant string.
Posted on 2002-06-01 22:17:24 by andy981
That was excellent code, but now I remember why I asked this question.

It seems that you just can't declare a string in ASM
like string db "God awfully long String............." goes many lines

And not get this compile error

fatal error A1009: line too long

See I made a program in C that can take a html page and automatically
create a printf ("God awfully long String..............",
".....................................................");
printf statement, and it's cool because it saves you lots of time making cool CGI's in C , takes care of all the "" and other little perks.
Now I remember why I did not write another program in C to make giant ASM string declarations for the same purpose

It can be found somewhere here
http://busybeesolutions.com

I guess were victims of error A1009: line too long


Andy981
Posted on 2002-06-01 22:34:35 by andy981
It's a long standing assembly language practice to create long strings (or any large block of data) by splitting it over several data lines:
CR equ 13

LF equ 10

LongString db 'First part of string, '
db 'Second part of data, '
db 'End of line 1.', CR, LF
db 'Start of second line, '
db '..., '
db 'End of data'
ActualLength equ $-LongString
db 0 ; add this if creating an ASCIIZ string
I and other firmware programmers are still using this style. You can use this style to show logical breaks in the long data.
Posted on 2002-06-02 00:22:46 by tenkey
String Length is only limited by your imagination. StdOut is based upon WriteFile (theoritically). Therefore you can print a string up to 4GB in size. And you can print 2 strings for a total of 8GB. If you put a null at the end of String3, call StrLen, you can use Write File to print all three at once if they are contiguous.

BTW, FAsm has the file directive, which allows you to place the file contents right into the output.
Posted on 2002-06-02 02:21:47 by eet_1024

ActualLength equ $-LongString
db 0 ; add this if creating an ASCIIZ string



What does this part mean and how would I use it for ?


By the way Thank You TenKey , I tested what you gave me and it worked great, I believe I created a long enough string that before would have gave me an error

Thanks Andy:alright:
Posted on 2002-06-06 21:37:40 by andy981
ASCIIZ is another name for a zero (NUL) terminated byte (ASCII/ANSI/ISO) string.

$ is the current value of the location counter, and ($-BeginningOfData) gives the number of bytes from BeginningOfData to the byte before the EQU.

Some functions, like WriteFile, do not use zero-terminated data. They use a size value instead of relying on a terminating character. This allows the function to handle either binary or text data.
Posted on 2002-06-06 23:32:55 by tenkey
How do add single quotes to a string like this



LongString db 'First part of string, '


LongString2 db 'First part of of many part's , '

that single quote will give you an error
Posted on 2002-06-08 23:23:42 by andy981
JUst add another single quote

:stupid:
Posted on 2002-06-08 23:24:49 by andy981
Just rename the html file or part needed to infile.htm
and have it in the same directory as this program and it'll create a text file
like this

LongString db 'First part of string, '
db 'Second part of data, '
db 'End of line 1.', CR, LF
db 'Start of second line, '
db '..., '

Saves time if you like doing asm cgi's
#include <stdio.h>


#include <stdlib.h>
/*
LongString db 'First part of string, '
db 'Second part of data, '
db 'End of line 1.', CR, LF
db 'Start of second line, '
db '..., '
*/
void main( void)
{
FILE *htmr,*writo;
int i=0;
char c;



if( (htmr = fopen( "infile.htm", "r" )) == NULL )
{ printf("There is no file named infile.htm\n");
getchar();
exit( 0 );}
writo = fopen("html.txt","w");
fprintf(writo,"LongString db '");
//fprintf(writo,"HTML = HTML & \"");


while( c != EOF)
{
i++;
c = fgetc( htmr );
if (c == '\n')
c = ' ';

if(i%50 != 0 && c != EOF)
{if(c == 34)
fprintf(writo,"\"");
else if(c == 39)
fprintf(writo,"'");

fprintf(writo,"%c", c);}
else if (c == EOF)
fprintf(writo,", ' ");
else
fprintf(writo,", ' \n db '");
}


fclose(htmr);
fclose(writo);
printf("Your file has been properly converted into an ASM long String\n");
getchar();
}
Posted on 2002-06-08 23:41:47 by andy981