News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Irvine library SmallWin.inc error MASM Visual Studio 2015

Started by ISM34, October 21, 2016, 04:22:54 AM

Previous topic - Next topic

ISM34

I am trying to run the following code in Visual Studio 2015 that has MASM built in to it. I am trying to link the Irvine library files to the program. However, I get like 49 of the following errors.


A2C \Irvine\SmallWin.inc(11)or specified size
A2C \Irvine\SmallWin.inc(12)or specified size
A2C \Irvine\SmallWin.inc(299)for specified size


Here is my code


ExitProcess PROTO

includelib C:\Irvine\Kernel32.Lib
includelib C:\Irvine\User32.Lib
includelib C:\Irvine\Irvine32.lib
include Irvine32.inc

.data
str1 BYTE "This line is displayed in color",0

.code
main PROC

mov eax, black + (white * 16) ; black on white backgrouund
mov ecx,4 ; loop counter

L1: call SetTextColor
mov edx,OFFSET str1
call WriteString
call Crlf
add eax,2 ; add 2 to foreground color
loop L1

call ExitProcess
main ENDP
END


jj2007

Quote from: ISM34 on October 21, 2016, 04:22:54 AM
A2C \Irvine\SmallWin.inc(12)or specified size

Garbled error messages... looks suspiciously like a known bug in the latest MASM version ::)

Anyway, unless you have a really convincing excuse for using a) the Irvine lib on b) that VS behemoth, you'd better switch to Masm32. Assembler is fun, but you need the right tools for it :bgrin:

Welcome to the forum :icon14:

ISM34

Do you suggest I download the MASM32 software to write my code? Should I download the MASM32 SDK Version 11 from masm32.com? Are there tutorials or videos that provide help on how to use the software? I am new to programming in assembly language. I assume with MASM32 I can still import the Irvine libraries to compile my programs?

Thank you.


hutch--

> I assume with MASM32 I can still import the Irvine libraries to compile my programs ?

Not necessarily, the entire masm32 system is designed around proper compliance with the Intel ABI for production code where the Irvine libraries are designed for undergraduates who are doing a term in assembler language. Also the API call "ExitProcess" has an error code argument. You should be using,

push 0
call ExitProcess

mineiro

Quote from: ISM34 on October 21, 2016, 08:04:26 AM
Do you suggest I download the MASM32 software to write my code?
Masm32 is in my opinion the best assembly package that I ever see. No doubt about this.
Have good assemblers around the world, but about a package, masm32 is the best.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

jj2007

Quote from: ISM34 on October 21, 2016, 08:04:26 AM
Do you suggest I download the MASM32 software to write my code? Should I download the MASM32 SDK Version 11 from masm32.com? Are there tutorials or videos that provide help on how to use the software? I am new to programming in assembly language. I assume with MASM32 I can still import the Irvine libraries to compile my programs?

4 x YES. As Hutch writes above, the Irvine libraries are not the best choice, but you can import them indeed. After the installation (detailed steps here), you should open one of the examples in \Masm32\examples in \Masm32\qeditor.exe and check the build menus.

ISM34


jj2007

Yes. But you should learn walking before trying to run the marathon :bgrin:

rrr314159

Quote from: jj2007 on October 22, 2016, 02:52:15 AM
Yes. But you should learn walking before trying to run the marathon :bgrin:

I'd say "yes and no". The best way for a student to get to 64-bit is to learn 32-bit first with masm32. Then 64 is a natural evolution, pretty straightforward. But by the time you replace the 32-bit libraries with 64, and so forth, it's a stretch to say you're still using "masm32".

Also, I think a better analogy might be: 32-bit is like learning to walk. 64-bit is like learning to walk with 40 pounds of lead in your backpack.
I am NaN ;)

Zen

Hi, ISM34,
Here at the MASM Forum, we get a lot of questions from novice assembly programmers about problems they are having using the IRVINE32 Libraries and include files in very simple programs compiled with ml.exe (the COMPILER that comes with the MASM package) or Visual Studio.

Quote from: ZEN"I found the Fifth Edition [Assembly Language for x86 Processors, Kip Irvine] in the Library at the University of California,...and, I couldn't find anything else at that level, so I bought it.
It has many problems, though,...and, we get a lot of questions here at the MASM Forum from novices trying to use his source code examples and compiled libraries with the usual header files and libraries that are an integral part of the MASM package. They are not really compatible. Kip writes overly simplistic code, and his examples are designed to be used only with other routines from the Irvine library (his routines usually don't take any parameters, and don't return anything). This just confuses novice MASM programmers, who when compiling simple programs generate a lot of annoying errors, and, are lost when trying to call routines from Irvine's libraries that are included in the typical initial code of a MASM program."

Try the Forum Search feature, searching the Campus for the phrase IRVINE32.

Typical Irvine problem threads:
Irvine32 library, May 2016
x86 Assembly Beginner: Need help debugging a mess, May 2016
If you know how to use Visual Studio and Irvine's resources for masm, help me!, Feb 2016
How to print out values in MASM syntax?, June 2015
need help getting started , Mar 2015
LNK2001 error Irvine32.inc , Feb 2015
My first post: Array of Strings in Assembly, Aug 2014
Some starter questions about assembly language, July 2013
Irvine32 library problem, June 2013

...It goes on and on,...:bgrin:

ISM34

Thank you to everyone who has replied to my post. I appreciate the help. I went ahead and downloaded MASM32 and installed it. I tried running the following code:

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc

include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib

include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib


.data
str1 BYTE "This line is displayed in color",0

.code
start:

mov eax, black + (white * 16) ; black on white backgrouund
mov ecx,4 ; loop counter

L1: call SetTextColor
mov edx,OFFSET str1
call WriteString
call Crlf
add eax,2 ; add 2 to foreground color
loop L1


END start


I receive the following error message:

error A2006: undefined symbol: black
error A2006: undefined symbol: SetTextColor
error A2006: undefined symbol: WriteString
error A2006: undefined symbol: Crlf


Since I am trying to use the Irvine library functionality, do I need to include this line of code?

include \irvine\irvine32.inc


Do I also need to include this line of code?

includelib \irvine\irvine32.lib


Last question, is this line of code necessary, and what does it do?

include \masm32\include\windows.inc



rrr314159

The code as it stands should, indeed, give those error messages. You haven't defined "black" anywhere, for instance. But you've got the right idea: you need the correct includes and libraries.

The best way to start with masm32 is just this single include,

include \masm32\include\masm32rt.inc

which contains all the standard incs and libs you'll need. But it still doesn't define "black"! To do so, there's a missing line something like (not sure exactly)

black equ 1

If you put that line at the top that one error message will go away, but of course it still won't work. For one thing, it will give the same error message about "white". I'm guessing you must have glommed together some Irvine32 code with some masm32 headers. You certainly didn't find an example that was written just the way you present it.

I've never used irvine32 and don't want to, but others may be able to tell you how to fix this. Maybe you can simply throw in some more includes from irvine32, as you suggest, but I doubt it's that simple. There will be conflicts.

windows.inc often needs to be included. It defines a bunch of routines and symbols of general utility, just like other .inc files do. But masm32rt.inc takes care of that and all the other standard files automatically.

AFAIK it's no good to try to mix irvine32 and masm32. Once you understand both it can be done but it's not a beginner project. Therefore I, and probably everyone else here, recommend to just forget about irvine32 for the time being. Spend a week or a month getting used to masm32, by itself, see how that goes. You've got the right first step: find an example, and get it working. But this example wouldn't be the one to start with. There are lots of them in \masm32\examples. But I'd rather let jj2007, or others, recommend where to start. Many people are on top of beginner stuff, I'm not.

Perhaps the best reason to use masm32 is, all of us here can (and will) help you. But we can't do that with irvine32. It's not that masm32 is better (although I'm pretty sure it is) rather the user community is a lot better.

Good luck!
I am NaN ;)

jj2007

Quote from: ISM34 on October 24, 2016, 10:51:32 AMSince I am trying to use the Irvine library functionality, do I need to include this line of code?

include \irvine\irvine32.inc


Do I also need to include this line of code?

includelib \irvine\irvine32.lib

Why do you ask? Why don't you just try and see what happens? Is it laziness, or do you fear that the assembler might bite your hand if you do the wrong thing?

Some links for you:
http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm
http://masm32.com/board/index.php?action=search;advanced;search=
http://www.masmforum.com/board/index.php?action=search;advanced

Zen

ISM34,
When you are first starting out with MASM assembly language, you make a lot of errors just because there are a gizzlion little details that you must be aware of, and, you're not, so you typically neglect them. The MASM COMPILER will recognize these errors and generate error messages so that you can write a program that operates correctly. So, it makes sense to start simple, and, read and understand every line of code in your example program. We all made the same errors when we were just starting out, so, we know what you are going through.
The most obvious thing is to find which DLLs contain the routines that you are calling in your program (if you haven't written these routines yourself). So, correcting the error: error A2006: undefined symbol: SetTextColor, is straightforward. You can GOOGLE the Windows function, SetTextColor, and you will find this: SetTextColor function, MSDN. SetTextColor is located in Gdi32.dll, which you have not included at the beginning of your program. So, to solve the error, you can merely add the following lines somewhere in the beginning of your main asm file: 
include \masm32\include\gdi32.inc   
includelib \masm32\lib\gdi32.lib


Note: when listing your include (asm) files and your include library statements at the beginning of your program file, the listing order is important. The reason for this should be obvious,...types and routines must be defined before they can be used or referenced (this is true of most higher level languages too),...the listing of includes should look like the listing in: masm32rt.inc (this is why the masm32rt.inc file was created),...open this file in HUTCH's Quick Editor to see what I mean. So,...the listing of includes at the beginning of your asm project file should be:


include \masm32\include\windows.inc

include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib

include \masm32\include\gdi32.inc   
includelib \masm32\lib\gdi32.lib

include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib



To fix the error: error A2006: undefined symbol: WriteString, you can go either of several ways. WriteString is one of Kip Irvine's routines. It is prototyped in Irvine32.inc, the complete source code is in Irvine32.asm, and, is compiled (presumably) in Irvine32.lib. The simplest way to fix this error is just to copy the original source code for WriteString into your asm project file (from, Examples\Lib32\Irvine32.asm): 

;--------------------------------------------------------
WriteString PROC
;
; Writes a null-terminated string to standard
; output. Input parameter: EDX points to the
; string.
; Last update: 9/7/01
;--------------------------------------------------------
pushad

CheckInit

INVOKE Str_length,edx    ; return length of string in EAX
cld ; must do this before WriteConsole

INVOKE WriteConsole,
    consoleOutHandle,      ; console output handle
    edx, ; points to string
    eax, ; string length
    OFFSET bytesWritten,  ; returns number of bytes written
    0

popad
ret
WriteString ENDP


...However, you will notice, that if you read and understand every line of code, that WriteString calls other unknown routines: CheckInit (a macro defined in Irvine32.asm). Also, WriteString calls: Str_length. WriteConsole, the mystrerious, cld (Clear Direction Flag, actually a processor instruction), and references a number of variables (consoleOutHandle and bytesWritten). Where the heck are these items (in source code or in memory) ???   

From, the Intel Developer's Manual (Volume 2A, Instruction Set Reference, A to M, IA 32 Software Developer's Manual pdf):
QuoteCLD—Clear Direction Flag
Description
Clears the DF flag in the EFLAGS register. When the DF flag is set to 0, string operations increment the index registers
(ESI and/or EDI). Operation is the same in all non-64-bit modes and 64-bit mode.

...So,...it would be MUCH easier, in this case to just include the following lines in your main asm project file:   
include \irvine\irvine32.inc
includelib \irvine\irvine32.lib


...assuming that the path to include files and libraries is correct for the directory structure on your computer. And, this little bit of code will reference the WriteString routine, and reference the other dependencies in the WriteString code listing. So, the MASM COMPILER (ml.exe) should not generate error messages for SetTextColor and WriteString anymore. The irvine32.lib should contain all this code in compiled form, which the MASM COMPILER just loves,...:bgrin:

...So,...what's left ???

ISM34

I appreciate everyone's help. After a lot of research and a lot of trial and error, I was able to build, compile and execute the program. I ran the program and it provided the desired output in the console window. My only question now is that does MASM32 come with a debugger? I would like a debugger to look at register values and memory values. Are there any suggestions on a good debugger program that I can download and run with MASM32?