szVersion db "1.0.0.0-2", 0
szClassName2 db "Updater v", szVersion
error A2071: initializer magnitude too large for specified size
Why would it not work?
It should just make:
szVersion db "1.0.0.0-2", 0
szClassName2 db "Updater v1.0.0.0-2",0
szVersion db "1.0.0.0-2", 0
szClassName2 db "Updater v", szVersion <------- tries to put the 32-bit address of szVersion into a byte array
try this...
szClassName2 db "Updater v"
szVersion db "1.0.0.0-2", 0
This might be a better option for organization:
CurrentVersion EQU "1.0.0.0-2", 0
......blah blah blah....
szVersion db CurrentVersion
szClassName2 db "Updater v", CurrentVersion
Remember that a variable always references an address, whereas an EQU is essentially a 'plug and chug'. In your version, you are trying to append the address of szVersion to the end of the string, which is neither support nor intended
-r
Or alternatively use masm's @catstr (strcat?) or some such built in macro.
Mirno
I forgot all about how it represents an address. I really thought it would append it on during assembling. :red
I like the method using the constants. For Dave, that method just looks messy (I hope you know what I mean), and I aim for readability, easy to go through and understand.
Thank you you all! :dance:
lol - that's ok - no offense taken
i bet that, at some point, you will make a structure just like that - lol
it seems inevitable
i do it quite often - especially for buffers
AsciiBuffer db 32 dup(?)
AscBuffTerm db 4 dup(?)
;end of AsciiBuffer
notice the remark at the end - that way, a reader (or myself) knows they belong together
the advantage in this case is that "sizeof AsciiBuffer" returns the correct value, without the terminator
i have assigned 4 bytes to the terminator in this case to keep the addresses 4-aligned
here' another example...
Banner db 'DednDave Times Ten Table Generator'
BanTerm db 0,10
BanCrLf db 13,10,0
;end of Banner
this time, i use the banner (zero terminated) to set the console title
then, i set the 0 byte at BanTerm to a 13, and use the string again as the console banner (with 2 cr/lf pairs)
this way, i don't have to count bytes and say "mov byte ptr Banner+35,13"
i just say "mov byte ptr BanTerm,13"
i also use the last cr/lf pair for other text
i like RedSkull's approach - if you need to create 2 copies of the string
mine takes 10 bytes less :U