Masm32 assembly error

Ошибка при компиляции программы "fatal error A1000: cannot open file : /masm32/include/windows.inc" Assembler Решение и ответ на вопрос 2320206

0 / 0 / 0

Регистрация: 05.04.2018

Сообщений: 10

1

12.09.2018, 12:44. Показов 12678. Ответов 2


Assembler
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
.486
.model flat, stdcall
include /masm32/include/windows.inc
include /masm32/include/user32.inc
include /masm32/include/kernel32.inc
includelib /masm32/lib/user32.lib
includelib /masm32/lib/kernel32.lib
include /masm32/macros/macros.asm
uselib masm32, comctl32, ws2_32
.data
msg_title db "title",0
x dd 0,1,2,3,4,5,6,7,8,9,10,11
n dd 12
bufer db 128 dup(?)
format db "%d",0
.code
start:
mov eax,0
mov ecx, n
mov ebx, 0
L: add eax, x[ebx]
add ex, type x
dec ecx
cmp ecx, 0
jne L
invoke wsprintf, addr buffer, addr format, eax
invoke MessageBox, 0, addr buffer, addr msg_title, MB_OK
invoke ExitProcess, 0
end start.
Assembler
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
.486
.model flat, stdcall
include /masm32/include/windows.inc
include /masm32/include/user32.inc
include /masm32/include/kernel32.inc
includelib /masm32/lib/user32.lib
includelib /masm32/lib/kernel32.lib
include /masm32/macros/macros.asm
uselib masm32, comctl32, ws2_32
.data
msg_title db "title",0
x dd 0,1,2,3,4,5,6,7,8,9,10,11
n dd 12
bufer db 128 dup(?)
format db "%d",0
.code
start:
mov eax,0
mov ecx, n
mov ebx, 0
L: add eax, x[ebx]
add ex, type x
dec ecx
cmp ecx, 0
jne L
invoke wsprintf, addr buffer, addr format, eax
invoke MessageBox, 0, addr buffer, addr msg_title, MB_OK
invoke ExitProcess, 0
end start.

Внимание! В ходе построения обнаружены ошибки:
Assembling: C:UsersbogdanAppDataLocalTempSASMprogram.as m
C:UsersbogdanAppDataLocalTempSASMprogram.as m(3) : fatal error A1000: cannot open file : /masm32/include/windows.inc
LINK : fatal error LNK1181: cannot open input file «C:UsersbogdanAppDataLocalTempSASMprogram.o »

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Topic: Back to Basics: Error Assembling a MASM32 Tutorial File!  (Read 2802 times)

So I decided to go through the Tutorials after installing MASM32…

Console Demos 1 — 4 (and 6-7 too), worked just fine using «Project» —> «Console Assemble & Link» in the Quick Editor.
But when I tried Demo5 (numbers.asm), even if I use a simple build.bat file instead of the Quick Editor, it keeps giving me this Assembly error either way:

error A2006: undefined symbol : crt_atol
 sval(2): Macro Called From … numbers.asm

The numbers.exe file that came with it works fine, and I checked where «crt_atol» is defined and don’t see any problems there! So what’s wrong??!  PLEASE TRY running this yourself using the latest MASM32 install from the website. The line of code involved in the file is:

    mov var1, sval(input("Enter a number : "))
UPDATE: Since the file itself notes that the code above was a combination of macros, I went ahead and split them, in that case the error message is still about this line of code:

    mov var1, sval(str1)

error A2006: undefined symbol : crt_atol
 sval(2): Macro Called From
  C:masm32tutorialconsoledemo5numbers.asm(74): Main Line Code

Dan.


Logged


Hi Dan,

atol

is a function exported by msvcrt.dll  To avoid naming conflicts with some reserved Masm keywords, the msvcrt functions are prepended with the symbol

crt_

You need to add the two lines below to the source code :

include masm32includemsvcrt.inc
includelib masm32libmsvcrt.lib

Part of masm32includemsvcrt.inc :

externdef _imp__atol:PTR c_msvcrt
crt_atol equ <_imp__atol>

« Last Edit: December 08, 2020, 05:33:29 AM by Vortex »


Logged


Or, a bit simpler, after line 22:

    include masm32macrosmacros.asm       ; MASM support macros
    uselib msvcrt


Logged


First, Thank you for your replies!  Tested the code all different ways as suggested, works fine now!

atol is a function exported by msvcrt.dll  To avoid naming conflicts with some reserved Masm keywords, the msvcrt functions are prepended with the symbol vc_

Part of masm32includemsvcrt.inc :

externdef _imp__atol:PTR c_msvcrt
crt_atol equ <_imp__atol>

I just found a number of replies from Hutch about this on 16 NOV 2020 (in «Re: scanf macro and printf macro»), so I guess that’s why Demo5‘s

numbers.asm

file hasn’t been changed yet?  Or was this change requiring «msvcrt» much earlier?

Regarding the comment: «… the msvcrt functions are prepended with the symbol

vc_

,» I still don’t quite understand what that «

vc_

» has to do with the definition of

sval()

(and the «

crt_atol

» in macros.asm) and a number of capitalized «VC_»s I see in various examples. However, now that I’ve looked thoroughly, I see the only definition of «

crt_atol

» in all of the MASM32 files is in: msvcrt.inc. So it’s rather obvious it must be included in the

numbers.asm

file.

As I wrote in my first post’s later comments, most of the work I did with assembly was reversing raw hex into straight-forward assembly instructions, so many ‘masm macros’ are still just a bunch of crazy meaningless symbols to me. :dazzled:


Logged


Hi Dan,

My apologies, the 32-bit version of msvcrt.inc is using the suffix

crt_

  The 64-bit version of the same file :

vc_

I corrected this in my previous message.

masm32include64msvcrt.inc :

externdef __imp_atol:PPROC
vc_atol equ <__imp_atol>

There are some Masm specific keywords like div and FABS which could collide with the sane named msvcrt functions. To avoid those confusions, Hutch prepended the functions names with

crt_

and

vc_


Logged


Dan,

The general drift is while you are getting up to speed, use the system as its designed. The masm32rt.inc file has all the the correct include files, the main macro file and the matching libraries. Also don’t be afraid to use the help files, they document the library procedures and the available macros you can use. Once you are up to pace you can be creative, write your own libraries, macros and architecture.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include masm32includemasm32rt.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

comment * ——————————————————
                        Build this  template with
                       «CONSOLE ASSEMBLE AND LINK»
        —————————————————— *

    testproc PROTO :DWORD,:DWORD,:DWORD

    .code

start:

   ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    invoke testproc,1,2,3

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

testproc proc arg1:DWORD,arg2:DWORD,arg3:DWORD

    LOCAL var1  :DWORD
    LOCAL var2  :DWORD
    LOCAL var3  :DWORD

    mov eax, var1
    mov ecx, var2
    mov edx, var3

    ret

testproc endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start


Logged


  1. В общем, я не знаю что произошло, но у меня вдруг перестала работать опция /I (путь к include-файлам) в ml. Раньше всё работало, теперь выдаёт ошибку типа такого:

    1. pe.asm(8) : fatal error A1000: cannot open file : WINDOWS.INC

    В исходнике указано имя файла без пути:

    Файл этот точно есть и точно по указанному пути.
    Если установить переменную окружения INCLUDE=этому пути или задать полный путь в исходнике, всё ок.

    Но это ещё не всё. Линкер тоже выдаёт (даже если прописать в исходнике полные пути к lib’ам):

    1. D:pe.obj : warning LNK4033: converting object format from OMF to COFF
    2. pe.obj : error LNK2001: unresolved external symbol _ExitProcess@4
    3. LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
    4. pe.exe : fatal error LNK1120: 2 unresolved externals

    Т.е. ощущение, что не только /I перестал работать, но и /coff, например. Да и lib’ы почему-то не линкуются, судя по всему…

    Переустановка masm32 не помогает…
    Пробовал подменить даже содержимое папки bin (версия 6.14) файлами версии 6.11 (скачанной из инета) — та же ерунда.

    Т.е. проблема явно не в компиляторе самом, а в чём — ума не приложу! Загадка какая-то!

    Понимаю, что инфы мало, но даже не знаю что ещё сообщить. Всё, что было сделано (перед тем, как проблема появилась) — это компиляция пары исходников через ml64. Попытка установить MASMsetup.EXE, скачанный с сайта Microsoft (но вышла ошибка «MS Visual C++ Express Edition 2005 required» и забил это). Ну ещё я случайно скопировал несколько *.lib-файлов для 64 бит в папку lib для 32 бит (без замены, но потом удалил эти файлы). Обновление Notepad ++ я уж не беру в расчёт. Но в любом случай, повторюсь, masm32 (скачанный с masm32.com) я переустанавливал!

    Что делать?
    Может, кто-то сталкивался с этим уже?

    p.s. Исходник пустой:

    Последнее редактирование: 8 апр 2017


  2. Indy_

    Indy_

    Well-Known Member

    Публикаций:

    4

    Регистрация:
    29 апр 2011
    Сообщения:
    4.780

    Пути пропишите. И версию смените компиля между прочим.

    Вложения:

    • ml.zip
      Размер файла:
      169,5 КБ
      Просмотров:
      669
  3. Indy_, спасибо, заработало.
    Но! У меня несколько (хочется даже сказать «пару») дней назад стоял ml 6.14 и всё работало. И пути я не прописывал!
    Как это можно понять?


  4. Indy_

    Indy_

    Well-Known Member

    Публикаций:

    4

    Регистрация:
    29 апр 2011
    Сообщения:
    4.780

    Jin X,

    Причин множество может быть, может авер или есчо какой софт мешает, может что то заразило систему или обновления.


WASM

  • Remove From My Forums
  • Question

  • Assembly code will not compile correctly in VC++ Express 2010

    I get this error every time:

    MASM : fatal error A1000: cannot open file : filename.asm

    I want to learn assembly and I am setting up my IDE

    Help would be appreciated

Answers

  • If you are sure that you did that then I would have to come to the conclusion that your install of VC Express is corrupt somehow.

    Here, when I enable the build customization, it immediately allows asm files to be built using masm.

    The reason why I took so long this time was because I was testing it out properly. I was using VS to do this, so I was being sure that there was no differences between the VS IDE and the VC Express IDE. Those two screenshots were taken using VC Express though,
    so the relationship does still hold, if masm is enabled in build customizations then the compile option gets enabled, if masm isn’t enabled then compile doesn’t occur and things start falling apart.

    So at this point I would suggest trying it out on another computer if possible to rule out VC Express being the problem. Also, as a bit of a thought, did you install service pack 1? I am using fully updated versions of VS so there could be a bug that was
    fixed getting in the way.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts
    is to aid in the learning process.

    • Marked as answer by

      Monday, February 6, 2012 9:15 AM

Понравилась статья? Поделить с друзьями:
  • Masm error a2006
  • Marymorals d20 коды ошибок
  • Marvell 91xx sata 6g controller ошибка код 10
  • Marvel ultimate alliance 2 ошибка 0xc0000142 как исправить
  • Marvel ultimate alliance 2 ошибка 0xc0000142 windows 10