News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

db string limit

Started by alCoPaUL, April 27, 2024, 02:58:23 AM

Previous topic - Next topic

alCoPaUL

do you know why there is a db 'limited#ofcharactershere',$ in masm, masm32, and masm64?

what's the rationale behind that?

coz in nasm, you can just make a full straight line of db characters, surpassing the limit that is present in masm, masm32 and masm64?

zedd151

#1
Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMdo you know why there is a db 'limited#ofcharactershere',$ in masm, masm32, and masm64?
Do you have an example of what you mean?

Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMcoz in nasm, you can just ...
Ah, nasm. Are you at all interested in masm32/64?
Have you done any work, in either of them?

db string maximum length == 251 plus the zero terminator. = 252...  I would have figured 256 for max length.

alCoPaUL_string db "12345678901234567890123456789012345678901278901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123452345678901", 0

no error

with one extra character:
alCoPaUL_string db "123456789012345678901234567890123456789012789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234523456789012", 0

error:
C:\Users\Administrator\Desktop\test\test.asm(22) : error A2042: statement too complex
I also tested with much longer strings, resulting in error "Line too long"

This is with ml.exe inside the masm32 SDK, similar result with ml64 version 14.xxx.xx
But what is your point?
"We are living in interesting times"   :tongue:

NoCforMe

I just checked my MASM manual (the actual Micro$oft document for MASM 6.1):
QuoteAn initialized string can be no longer than 255 characters.
I had no idea this limit existed. Guess I never tried to exceed it.

As to the OP's question of "Why?", I guess chalk it up to MASM's designers thinking nobody would ever need more than 255 characters in a DB statement.

BTW, the workaround is so easy:
Variable1 DB "<string of 255 characters>"
          DB "<another string of 255 characters>"
          DB "<yet another string of 255 characters>"
Of course, you won't be able to use the SIZEOF operator on Variable1, but that's also easily fixed:
Variable1 DB "<string of 255 characters>"
          DB "<another string of 255 characters>"
          DB "<yet another string of 255 characters>"
          . . .
$sizeofVariable1 EQU $ - Variable1
Assembly language programming should be fun. That's why I do it.

jj2007

include \Masm32\MasmBasic\Res\JBasic.inc    ; ## console demo, builds in 32- or 64-bit mode with UAsm, ML, AsmC ##
My$ db "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0
Init        ; OPT_64 1    ; put 0 for 32 bit, 1 for 64 bit assembly
  PrintLine Chr$("This program was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format.")
  Print Str$("Printing a string with %i bytes:\n", Len(offset My$))
  Inkey offset My$
EndOfCode

This program was assembled with UAsm64 in 64-bit format.
Printing a string with 990 bytes:
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

zedd151

Thx jj, I was going to ask about Uasm in this regard.
"We are living in interesting times"   :tongue:

alCoPaUL

Quote from: sudoku on April 27, 2024, 03:42:43 AM
Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMdo you know why there is a db 'limited#ofcharactershere',$ in masm, masm32, and masm64?
Do you have an example of what you mean?

Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMcoz in nasm, you can just ...
Ah, nasm. Are you at all interested in masm32/64?
Have you done any work, in either of them?

db string maximum length == 251 plus the zero terminator. = 252...  I would have figured 256 for max length.

alCoPaUL_string db "12345678901234567890123456789012345678901278901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123452345678901", 0

no error

with one extra character:
alCoPaUL_string db "123456789012345678901234567890123456789012789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234523456789012", 0

error:
C:\Users\Administrator\Desktop\test\test.asm(22) : error A2042: statement too complex
I also tested with much longer strings, resulting in error "Line too long"

This is with ml.exe inside the masm32 SDK, similar result with ml64 version 14.xxx.xx
But what is your point?


i was thinking that it's all string formatting gatekeeping but i did a workaround, which you can find in the link in my signature..

and so masmbasic and nasm exceed the masm16/32/64 db limit...

C3

Quote from: alCoPaUL on April 27, 2024, 11:50:40 PM
Quote from: sudoku on April 27, 2024, 03:42:43 AM
Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMdo you know why there is a db 'limited#ofcharactershere',$ in masm, masm32, and masm64?
Do you have an example of what you mean?

Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMcoz in nasm, you can just ...
Ah, nasm. Are you at all interested in masm32/64?
Have you done any work, in either of them?

db string maximum length == 251 plus the zero terminator. = 252...  I would have figured 256 for max length.

alCoPaUL_string db "12345678901234567890123456789012345678901278901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123452345678901", 0

no error

with one extra character:
alCoPaUL_string db "123456789012345678901234567890123456789012789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234523456789012", 0

error:
C:\Users\Administrator\Desktop\test\test.asm(22) : error A2042: statement too complex
I also tested with much longer strings, resulting in error "Line too long"

This is with ml.exe inside the masm32 SDK, similar result with ml64 version 14.xxx.xx
But what is your point?


i was thinking that it's all string formatting gatekeeping but i did a workaround, which you can find in the link in my signature..

and so masmbasic and nasm exceed the masm16/32/64 db limit...

.data
    longstring db "1234567890123456789012345678901234567890"
               db "1234567890123456789012345678901234567890"
               db "1234567890123456789012345678901234567890"
               db "1234567890123456789012345678901234567890",0

I dont know if I missed the point?, but you can do like this.

zedd151

@Alcopaul: Most of us here all have our own work-arounds for situations like that. But thanks for offering yours.
Pardon the non exact spelling of your username, difficult for me, as the autocorrect interferes (posting from an old iPad)
Quote... but you can do like this...
Yes C3, exactly.  :thumbsup:
"We are living in interesting times"   :tongue:

jj2007

Quote from: johnsa on February 11, 2019, 08:24:40 PMThe default setting in the source at present is 1024
Quote from: HSE on September 25, 2022, 09:14:58 AMYou can rebuild UASM with longer lines, no restriction. Usually I set maximum line size to 2048 bytes, but my longer mesured line only was 1680 bytes.

NoCforMe

All in all, this seems like a pretty weak reason to prefer Uasm over, say, MASM, even though there may be other things in its favor.

It's like, "Hey, assembler (x) lets me have variable names up to 1,024 bytes! Woo-hoo!" Yeah, right; who's ever going to need to use a name that long?



Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on April 28, 2024, 05:20:51 AMthis seems like a pretty weak reason to prefer Uasm

Correct - there are many other reasons to throw MASM into the dustbin :thumbsup:

NoCforMe

Well, so far it works fine for me, so no change contemplated here.
Assembly language programming should be fun. That's why I do it.

alCoPaUL

Quote from: C3 on April 27, 2024, 11:55:44 PM
Quote from: alCoPaUL on April 27, 2024, 11:50:40 PM
Quote from: sudoku on April 27, 2024, 03:42:43 AM
Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMdo you know why there is a db 'limited#ofcharactershere',$ in masm, masm32, and masm64?
Do you have an example of what you mean?

Quote from: alCoPaUL on April 27, 2024, 02:58:23 AMcoz in nasm, you can just ...
Ah, nasm. Are you at all interested in masm32/64?
Have you done any work, in either of them?

db string maximum length == 251 plus the zero terminator. = 252...  I would have figured 256 for max length.

alCoPaUL_string db "12345678901234567890123456789012345678901278901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123452345678901", 0

no error

with one extra character:
alCoPaUL_string db "123456789012345678901234567890123456789012789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234523456789012", 0

error:
C:\Users\Administrator\Desktop\test\test.asm(22) : error A2042: statement too complex
I also tested with much longer strings, resulting in error "Line too long"

This is with ml.exe inside the masm32 SDK, similar result with ml64 version 14.xxx.xx
But what is your point?


i was thinking that it's all string formatting gatekeeping but i did a workaround, which you can find in the link in my signature..

and so masmbasic and nasm exceed the masm16/32/64 db limit...

.data
    longstring db "1234567890123456789012345678901234567890"
               db "1234567890123456789012345678901234567890"
               db "1234567890123456789012345678901234567890"
               db "1234567890123456789012345678901234567890",0

I dont know if I missed the point?, but you can do like this.

yeah.

but along the process of making assembly language quines, i found out that you can just enclose a full string buffer as the data part of a nasm quine in db 'quineyeayeayo1234',27h,0

i encountered the limit when i was making the masm AND tasm quines..

i have to make the quines' format their db string as

db 'ttkpdotporppotpeo7t'
db 'whatever1234232332',27h,0

AND i have to have a working buffer that won't go past the limit of string operations within the quines themselves just for that string reformatting...

so it will display a valid masm/tasm source code that can be reassembled..

like

c:\>quinemasm64.asm.exe >> quinemasm64.txt

and quinemasm64.txt can be assembled, executed to output contents that are also the same contents that quinemasm64.asm.exe outputs..

coz quinemasm64.asm is == quinemasm64.txt in content..

alCoPaUL

good thing that from windows 2000 to current, you can adjust the width of the console window to 214 characters or more to display the 32/64 bit masm32, tasm32 and masm64 quines properly and elegantly. but for the 16-bit, you have to have the edit.com as the "output console" coz real mode DOS console can just display 80 characters (or a little more) but the redirected output to >> file16bit.asm.txt can be reassembled and linked with no problems..

zedd151

Me: "What the hell is a 'quine'"? ...

Wikipedia via Google search:
https://en.m.wikipedia.org/wiki/Quine_(computing)

I had to look it up, as I did not know.  :smiley:
So, now that I know...
What is it good for, alCoPaUL?
"We are living in interesting times"   :tongue: