News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SIZEOF "A String"

Started by Citric, April 02, 2005, 08:00:34 AM

Previous topic - Next topic

Citric

A little quirk that i messed my head around for a bit.

string DB "987654321",0

if you do a 'SIZEOF string' the value is 12, not 10 as i was expecting.

is this wierd or is it just me?

Adam

donkey

Hi Citric,

It seems to work fine here, returning 10. Be sure that you have not included the quotes in your string by putting single quotes around it... '"987654321"',0.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Citric

Hi Donkey

it could be me but when declared like

DATA SECTION

ALIGN 1h

                ten DB "987654321",0
                info DB "The string is '%s'",0Ah,0Dh,0
                format DB "SIZEOF string is %d",0Ah,0Dh,0
                eleven DB "987654321",0

ALIGN 4h
                hInstance DD ?
                commandLine DD ?

CODE SECTION


for 'ten' SIZEOF ten is 10
but
for 'eleven SIZEOF eleven is 11
and the only difference is the align of the bytes in the file.

attached is the RadAsm project showing this case, but u need to add 'msvcrt.dll' to the GFL.txt file

Adam

[attachment deleted by admin]

donkey

Hi Ctric,

SIZEOF will measure to the next label, in the case of eleven the next label may actually 11 bytes away because of the ALIGN directive. However, when I copy the data section directly to a test app, eleven returns 10 from SIZEOF. I am running GoAsm version 0.52.2 beta, it could be that the problem existed and was fixed, I don't use the SIZEOF operator in my code so I would never have noticed it.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

jorgon

Citric

You're right, this is a bug!

I've corrected this in GoAsm 0.52.3 beta which is available from here.

Thanks for reporting this.

Jeremy
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

Citric

Cheers Jeremy

works like a charm now!!!

Adam