Room Struct
descrip BYTE 100 DUP(?)
east DWORD ?
;etc
Room ENDS
.data
testRoom Room<"A simple room.">
And this is giving me the error: error A2177: nested structure improperly initialized. Any help you can give me with this would be REALLY appreciated.
[Assembly] String and Struct issues
First, I would like to know if it possible to do something like: mov foo, "Bar" at all. Been wanting to do that for a while but it always gives me an error and I haven't been able to find any examples.
Second, a problem with some code that should be working (basically copied it from a book).
FIX: A2138, A2036 or Hang, Init Nested Structure Array
MASM version 6.1 generates the following error message when an application attempts to initialize an array of nested structures:
error A2177: nested structure improperly initialized
mov foo, "Bar"
Have you considered going with old fashioned C instead of MASM?
char *foo = "Bar";
You can find a free ide and compiler here. There are others available on the www too.
MASM version 6.1 generates the following error message when an application attempts to initialize an array of nested structures:
error A2177: nested structure improperly initialized
mov foo, "Bar"
Have you considered going with old fashioned C instead of MASM?
char *foo = "Bar";
You can find a free ide and compiler here. There are others available on the www too.
Unfortunately, I can't use C or anything like that, this is for a project for an Assembly course, which is using MASM.
Also, I just checked my version of MASM, and it says I have version 8.0.50720, it says it got fixed in version 6.1, so I would assume it wouldn't apply anymore.
Also, I should have done this from the beginning, but here's a code paste including the nested structures if it'll help at all: http://codepad.org/fngNxQ30
Also also, just trying something like mov foo, "bar" doesn't like to work. The code:
mov testRoom.descrip, "A simple room."
coughs the error "error A2084: constant value too large" back into my face.
Also, I just checked my version of MASM, and it says I have version 8.0.50720, it says it got fixed in version 6.1, so I would assume it wouldn't apply anymore.
Also, I should have done this from the beginning, but here's a code paste including the nested structures if it'll help at all: http://codepad.org/fngNxQ30
Also also, just trying something like mov foo, "bar" doesn't like to work. The code:
mov testRoom.descrip, "A simple room."
coughs the error "error A2084: constant value too large" back into my face.
well,if you want to copy string "Bar" to the element descrip then you can do something like this...
and btw you cant do direct mem to mem copy in asm...
btw check this forum
and btw you cant do direct mem to mem copy in asm...
.686.model flat,stdcalloption casemap:noneinclude kernel32.incincludelib kernel32.libRoom Struct descrip BYTE 100 DUP (?) east DWORD ?Room ENDS.datatestroom Room <"A Simple Room",10>bar byte "Bar",0.data?.codestart: mov ecx,lengthof bar mov esi,offset bar mov edi,offset testroom.descrip rep movsb invoke ExitProcess,0end start
btw check this forum
You can't use 'mov' to copy strings around, because they aren't single elements of memory. You need to have some kind of loop to copy a byte (or word, if you're sufficiently clever) at a time. It's analogous to how assigning a pointer in C doesn't actually copy the string, which is why the C standard library provides strcpy().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement