The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: alCoPaUL on April 27, 2024, 02:58:23 AM

Title: db string limit
Post by: alCoPaUL on April 27, 2024, 02:58:23 AM
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?
Title: Re: db string limit
Post by: 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?
Title: Re: db string limit
Post by: NoCforMe on April 27, 2024, 05:50:12 AM
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
Title: Re: db string limit
Post by: jj2007 on April 27, 2024, 05:59:46 AM
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
Title: Re: db string limit
Post by: sudoku on April 27, 2024, 06:28:48 AM
Thx jj, I was going to ask about Uasm in this regard.
Title: Re: db string limit
Post by: 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...
Title: Re: db string limit
Post by: 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.
Title: Re: db string limit
Post by: sudoku on April 27, 2024, 11:57:49 PM
@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:
Title: Re: db string limit
Post by: jj2007 on April 28, 2024, 04:59:24 AM
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.
Title: Re: db string limit
Post by: NoCforMe on April 28, 2024, 05:20:51 AM
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?



Title: Re: db string limit
Post by: jj2007 on April 28, 2024, 07:02:54 AM
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:
Title: Re: db string limit
Post by: NoCforMe on April 28, 2024, 08:10:24 AM
Well, so far it works fine for me, so no change contemplated here.
Title: Re: db string limit
Post by: alCoPaUL on May 07, 2024, 03:28:36 AM
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..
Title: Re: db string limit
Post by: alCoPaUL on May 07, 2024, 10:57:05 AM
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..
Title: Re: db string limit
Post by: sudoku on May 07, 2024, 11:02:29 AM
Me: "What the hell is a 'quine'"? ...

Wikipedia via Google search:
https://en.m.wikipedia.org/wiki/Quine_(computing) (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?
Title: Re: db string limit
Post by: sinsi on May 07, 2024, 12:40:37 PM
Quote from: alCoPaUL on May 07, 2024, 10:57:05 AMgood 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..
Some video cards have a 132-column VESA text mode (132x60 if you're lucky). Real DOS only, of course.
Quote from: WikipediaModes 264–268 are text modes. 264 (0108h) is 80 columns × 60 rows (80×60), 265 (0109h) is 132×25, 266 (010Ah) is 132×43, 267 (010Bh) is 132×50 and 268 (010Ch) is 132×60
Title: Re: db string limit
Post by: daydreamer on May 07, 2024, 03:38:14 PM
You have richedit control is big exception to 260 chars in edit control
Can hold whole novel
Title: Re: db string limit
Post by: NoCforMe on May 07, 2024, 04:28:16 PM
Quote from: sudoku on May 07, 2024, 11:02:29 AMMe: "What the hell is a 'quine'"? ...
I had no idea either.
QuoteI had to look it up, as I did not know.  :smiley:
So, now that I know...
What is it good for, alCoPaUL?
I'm not the OP, but I'll answer anyhow:
It's what my dear old dad would have called "mental masturbation". IOW, one of those things that makes you feel good but is useless.
A programming game.
Title: Re: db string limit
Post by: TimoVJL on May 07, 2024, 05:39:29 PM
Repeat:
https://en.wikipedia.org/wiki/Quine_(computing) (https://en.wikipedia.org/wiki/Quine_(computing))

https://www.cprogramming.com/challenges/solutions/self_print.html (https://www.cprogramming.com/challenges/solutions/self_print.html)
Title: Re: db string limit
Post by: alCoPaUL on May 08, 2024, 12:51:28 AM
Quote from: NoCforMe on May 07, 2024, 04:28:16 PM
Quote from: sudoku on May 07, 2024, 11:02:29 AMMe: "What the hell is a 'quine'"? ...
I had no idea either.
QuoteI had to look it up, as I did not know.  :smiley:
So, now that I know...
What is it good for, alCoPaUL?
I'm not the OP, but I'll answer anyhow:
It's what my dear old dad would have called "mental masturbation". IOW, one of those things that makes you feel good but is useless.
A programming game.

if no one did it before since x86 chips were invented and improved, it's called "stroking your e-peenus"..

but yo, https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf

ken thompson and the bell lab guises wrote C quines in their past times..

and yes, that's ken thompson and the old school bell lab guises..

and you can scour the assembly language quines written before..

only 16 bit....

but what is it good for?

say your program can output its own source code and reassemble itself coz your program can custom translate the source into opcode or is piggybacking the whole assembler/linker after your program modified itself at the source code level by string formatting..

and i see people here posting their own versions of notepad.exe written in assembly language..
Title: Re: db string limit
Post by: NoCforMe on May 08, 2024, 03:02:51 AM
Welll, I do hope you have fun with it. Nothin' wrong with that.

Notepad written in assembly languge? My editor (EdAsm, described somewhere on this site) is a damn sight better than Notepad and written in asm. JJ's MasmBasic, which goes far beyond Notepad (it's actually a whole IDE) similarly written.
Title: Re: db string limit
Post by: sudoku on May 08, 2024, 06:17:19 AM
Since we're on the subject of editors, my editors are modeled after the functionality of qeditor. Period.  :cool:
Just plain ole ascii text.