1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
; Template for console application .586 .MODEL flat, stdcall OPTION CASEMAP:NONE Include kernel32.inc Include masm32.inc IncludeLib kernel32.lib IncludeLib masm32.lib .CONST MsgExit DB 13,10,"Press Enter to Exit" ,0AH,0DH,0 .DATA B SWORD 6 D SWORD 0 X SWORD ? fX SWORD 0 ;Starshee slovo rezultata Zapros DB 13,10,'Input A',13,10,0 Result DB 'Result=' ResStr DB 16 DUP (' '),0 .DATA? A SWORD ? fA SWORD ? ;Starshee slovo peremennoy A Buffer DB 10 DUP (?) inbuf DB 100 DUP (?) .CODE Start: Invoke StdOut,ADDR Zapros Invoke StdIn,ADDR Buffer,LengthOf Buffer Invoke StripLF,ADDR Buffer ;Preobrazovanie v SDWORD Invoke atol,ADDR Buffer ;rezultat v EAX mov DWORD PTR A,EAX ;VbI4isleniya mov CX,D add CX,8; CX:=D+8 mov BX,B dec BX ; BX:=B-1 mov AX,A add AX,D; AX:=A+D imul BX ; DX:AX:=(A+D)*(B-1) idiv CX ; AX:=(DX:AX):CX mov X,AX ;Preobrazovanie Invoke dwtoa,X,ADDR ResStr ;VbIVod Invoke StdOut,ADDR Result XOR EAX,EAX Invoke StdOut,ADDR MSgExit Invoke StdIn,ADDR inbuf,Lengthof inbuf Invoke ExitProcess,0 End Start |
KnowledgeBase Archive
An Archive of Early Microsoft KnowledgeBase Articles
View on GitHub
Article: Q94912
Product(s): Microsoft Macro Assembler
Version(s): MS-DOS:6.0,6.0a,6.0b
Operating System(s):
Keyword(s):
Last Modified: 06-MAY-2001
-------------------------------------------------------------------------------
The information in this article applies to:
- Microsoft Macro Assembler (MASM), versions 6.0, 6.0a, 6.0b
-------------------------------------------------------------------------------
SYMPTOMS
========
An attempt to assemble code that initializes an array of nested structures fails
and the computer hangs and stops responding or the assembler produces the
following messages:
error A2138: invalid data initializer
error A2036: too many initial values for structure
RESOLUTION
==========
To work around this problem, perform one of the following two steps:
- Remove the initialization from the structure declaration
-or-
- Remove the DUP operator and declare multiple nested structure fields
STATUS
======
Microsoft has confirmed this to be a problem in MASM versions 6.0, 6.0a, and
6.0b for MS-DOS and OS/2. This problem was corrected in MASM version 6.1 for
MS-DOS.
MORE INFORMATION
================
In code developed for Microsoft Macro Assembler (MASM) version 6.0 or later, an
application can create nested structures or use the DUP operator to create
arrays of structures. An application can initialize a nested structure or an
array of structures. However, an attempt to initialize a structure that contains
an array of nested structures fails with the errors listed above.
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
The following code example demonstrates this error.
Sample Code
-----------
; Assemble options needed: none
.MODEL small, c
inner_struct STRUCT
w1 DW ?
inner_struct ENDS
outer_struct STRUCT
s1 inner_struct 2 DUP ({})
outer_struct ENDS
.DATA
tst1 outer_struct {{{1},{2}}} ; This line generates an error message
; tst2 outer_struct {{}} ; This line is allowed
END
Additional query words: 6.00 6.00a 6.00b buglist6.00 buglist6.00a buglist6.00b fixlist6.10
======================================================================
Keywords :
Technology : kbMASMsearch kbAudDeveloper kbMASM600 kbMASM600a kbMASM600b
Version : MS-DOS:6.0,6.0a,6.0b
Solution Type : kbfix
=============================================================================
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED «AS IS» WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.
align(16)
__xmm@200020000a4f0a4f6621662170707070 xmmword 200020000a4f0a4f6621662170707070h
and
__xmm@200020000a4f0a4f6621662170707070 xmmword 0x200020000a4f0a4f6621662170707070
Both fail, the compiler saying error A2138: invalid data initializer
Cody Gray♦
236k50 gold badges486 silver badges567 bronze badges
asked Nov 27, 2018 at 16:59
4
The best workaround I found is to use two 8 byte initializers with a separate LABEL
definition, such as:
__xmm@200020000a4f0a4f6621662170707070 LABEL xmmword
dq 0x6621662170707070, 0x200020000a4f0a4f
answered Nov 27, 2018 at 17:36
JesterJester
55.4k4 gold badges77 silver badges121 bronze badges
From BetaArchive Wiki
Jump to:navigation, search
Article ID: 94912
Article Last Modified on 10/16/2003
- Microsoft Macro Assembler 6.0 Standard Edition
- Microsoft Macro Assembler 6.0a
- Microsoft Macro Assembler 6.0b
This article was previously published under Q94912
SYMPTOMS
An attempt to assemble code that initializes an array of nested structures fails and the computer hangs and stops responding or the assembler produces the following messages:
error A2138: invalid data initializer
error A2036: too many initial values for structure
RESOLUTION
To work around this problem, perform one of the following two steps:
- Remove the initialization from the structure declaration -or-
- Remove the DUP operator and declare multiple nested structure fields
STATUS
Microsoft has confirmed this to be a problem in MASM versions 6.0, 6.0a, and 6.0b for MS-DOS and OS/2. This problem was corrected in MASM version 6.1 for MS-DOS.
MORE INFORMATION
In code developed for Microsoft Macro Assembler (MASM) version 6.0 or later, an application can create nested structures or use the DUP operator to create arrays of structures. An application can initialize a nested structure or an array of structures. However, an attempt to initialize a structure that contains an array of nested structures fails with the errors listed above.
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
The following code example demonstrates this error.
Sample Code
; Assemble options needed: none .MODEL small, c inner_struct STRUCT w1 DW ? inner_struct ENDS outer_struct STRUCT s1 inner_struct 2 DUP ({}) outer_struct ENDS .DATA tst1 outer_struct {{{1},{2}}} ; This line generates an error message ; tst2 outer_struct {{}} ; This line is allowed END
Additional query words: 6.00 6.00a 6.00b buglist6.00 buglist6.00a buglist6.00b fixlist6.10
Keywords: kbfix KB94912
-
wsd
New Member
- Публикаций:
-
0
- Регистрация:
- 8 авг 2007
- Сообщения:
- 2.824
Стоял masm32 Version 6.14.8444 .
Взял из VS2005 ml Version 8.00.50727.42
и перекинул в родную папку масма.
Перестали компилироваться старые проектыПошла ругань на конструкцию в windows.inc
C:Masm32Includewindows.inc(14142) : error A2138: invalid data initializerтам находится
-
IMPORT_OBJECT_HEADER STRUCT
-
[b]rImport ImportRec <>[/b]
-
IMPORT_OBJECT_HEADER ENDS
если закомментировать спорную строчку — полностью всё пашет.
И в моих поделках эта структыра не используется.С чем это может быть связано?
Ещё кто-то на что-то в этом роде нарывался? -
S_Alex
Alex
- Публикаций:
-
0
- Регистрация:
- 27 авг 2004
- Сообщения:
- 561
- Адрес:
- Ukraine
-
wsd
New Member
- Публикаций:
-
0
- Регистрация:
- 8 авг 2007
- Сообщения:
- 2.824
S_Alex
Спасибо!
Я восьмёрку хотел поставить, чтобы с SSE2 поиграть.
А версия ML(шестая) в MASM32 их не поддерживает и приходится их
опкодами по мануалу кодировать
Просто действительно глюк какой-то получается!
Должна же поздняя версия обратно совместимой с предыдущей быть.
Может аргумент какой компилятору передать?
Поиск молчит… -
Jupiter
Jupiter
- Публикаций:
-
0
- Регистрация:
- 12 авг 2004
- Сообщения:
- 530
- Адрес:
- Russia
Я уже отвечал по теме на аналогичный вопрос S_Alex (он привёл ссылку той темы):
MASM error A2138: invalid data initializer -
wsd
New Member
- Публикаций:
-
0
- Регистрация:
- 8 авг 2007
- Сообщения:
- 2.824
Jupiter
Спасибо
Т.е. получается по существу двойной ванндам:
1. Попутан порядок полей в старой
ImportRec RECORD Reserved : 11,NameType : 3,Type2 : 2
на
IMPORT_REC RECORD Type2:2,NameType:3,Reserved:11
и косяк в FPO_DATA
2. НО ОСНОВНОЕ Теперь инициализация рекорда в старом стиле невозможна
ImportRec <>
на
ImportRec <>,<>,<>Я правильно понял?
Просто копипаст неинтересно -
Jupiter
Jupiter
- Публикаций:
-
0
- Регистрация:
- 12 авг 2004
- Сообщения:
- 530
- Адрес:
- Russia
wsd
если коротко: эт всё баги ml.exe, подправишь одно — вылезет где-то ещё. я когда тестил 9-й линкер и асм из студии, то сталкивался с тем, что при создании дебаг версии кто-то из них напрочь подвисал. некоторые структуры хаваются компилятором после совершенно идиотских преобразований. никакой логики я в этом не вижу. баги в чистом виде. -
wsd
New Member
- Публикаций:
-
0
- Регистрация:
- 8 авг 2007
- Сообщения:
- 2.824
Jupiter
Понял.
За короткий ответ — короткое Спасибо!А первый раз, когда на твой ответ давал ссылку S_Alex,
сразу не вкурил , что это к моей проблеме так-же относится.
Там в нём намбр еррор лайне сильно другой был, по сравнению с
моим.Вот и подумал ,что это другой косяк, вообще не вникая
в дальнейший текст ответа.
А получается — что правда тот-же косяк, просто еррор лайны
наши разные из-за разных версий инклюда.
Спасибо что сильно не ругали за то что дважды на одно и
тоже направляли -
Asterix
New Member
- Публикаций:
-
0
- Регистрация:
- 25 фев 2003
- Сообщения:
- 3.576
на форуме Хатча тема обсуждалась, вроде выкладывался другой Windows.inc для фикса
thanks @jj2007
the code is:
.data?
str1 dd ?
Hits dd ?
.code
start:
;#########################################################################
invoke crt_printf,chr$ ("Collatz Theorem",CR,LF,CR,LF)
@Start:
and Hits,0
mov str1,input("enter a number between 4 and 2000 : ")
mov esi,sval(str1)
push esi
invoke crt_printf,chr$ (CR,LF,CR,LF,"%d -> { "),esi
pop esi
mov ebx,3
.repeat
; test esi,1
.if !(esi & 1) ;ZERO?
mov eax,esi
shr eax,1
mov esi,eax
.if (eax != 1)
invoke crt_printf,chr$("%d, "),eax
.else
invoke crt_printf,chr$("%d }"),eax
.endif
.else
mov eax,esi
; mov ecx,3
mul ebx
add eax,1
mov esi,eax
invoke crt_printf,chr$("%d, "),eax
.endif
inc Hits
.until esi==1
@End:
lea ebx, @End
lea edx, @Start
sub edx,ebx
invoke crt_printf,chr$("used Bytes : %d ",CR,LF,CR,LF),edx
; invoke crt_printf,chr$ (CR,LF,CR,LF)
invoke crt_printf,chr$ (CR,LF,"%d -> Nodes",CR,LF),Hits
;#########################################################################
invoke wait_key
invoke ExitProcess, 0
end start
PS: found it (sub edx,ebx) registers inverted
again thanky you @jj2007 have nice weekend
Amadeus