The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jimmm on December 05, 2010, 09:09:59 AM

Title: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 09:09:59 AM
To make a long story short, I have been working on a quicksort program for a project due on monday, and now that the code works, I am looking to spruce it up some.  However, my problem is some calls I want to use in the Irvine32.inc are inaccessible to me, as whenever I try to link and build I receive a set of errors, that probably stem from the fact that I grabbed the setupfile from the irvine site for visio studio, since I saw no "base file."

Basically, whenever I try to link I get this:    (the include path is correct in my program)

Assembling: C:\Users\Public\Documents\masm stuff\quicksort.asm
\irvine\SmallWin.inc(11) : warning A4011: multiple .MODEL directives found : .MO
DEL ignored
\irvine\SmallWin.inc(22) : error A2008: syntax error : TEXTEQU
\irvine\SmallWin.inc(73) : error A2005: symbol redefinition : FILE_ATTRIBUTE_ENC
RYPTED
\irvine\SmallWin.inc(184) : error A2008: syntax error : EQU
exit(1): Macro Called From
  \irvine\SmallWin.inc(184): Include File
\irvine\SmallWin.inc(184) : error A2034: must be in segment block
exit(2): Macro Called From
  \irvine\SmallWin.inc(184): Include File
\irvine\SmallWin.inc(184) : fatal error A1010: unmatched block nesting
exit(3): Macro Called From
  \irvine\SmallWin.inc(184): Include File


I can only assume this is because I do not have the right libraries for a "vanilla" install...

If anyone could set me in the right direction to get these libraries working with a basic install that would be amazing, I do not have the means to install any of the Microsoft development environments at the moment.
Title: Re: Setting up irvine libs with default masm install.
Post by: MichaelW on December 05, 2010, 09:41:24 AM
It looks to me like you have a problem with your code structure. All of my Irvine components are old, but I think you need something like this:

include Irvine32.inc
include macros.inc
includelib \masm32\lib\kernel32.lib
.data
  hw db "Hello World",0
.code
; your procedures here
start:
    mov edx, OFFSET hw
    call WriteString
    call ReadChar
    exit
end start

Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 09:52:41 AM
Thanks for the amazingly fast response.

I did not have a included macros.inc, just Irvine32, with that added, the assembler explodes again, but differently:

Assembling: C:\Users\Public\Documents\masm stuff\quicksort.asm
\Irvine\SmallWin.inc(11) : warning A4011: multiple .MODEL directives found : .MODEL ignored
\masm32\include\windows.inc(35) : error A2111: conflicting parameter definition
\masm32\include\windows.inc(150) : error A2008: syntax error : typedef
\masm32\include\windows.inc(7652) : error A2161: non-benign structure redefinition: too few labels : FILETIME
\masm32\include\windows.inc(8128) : error A2161: non-benign structure redefinition: too few labels : COORD
\masm32\include\windows.inc(8143) : error A2163: non-benign structure redefinition: incorrect initializers : MOUSE_EVENT_RECORD
\masm32\include\windows.inc(8147) : error A2161: non-benign structure redefinition: too few labels : MOUSE_EVENT_RECORD
\masm32\include\windows.inc(8155) : error A2163: non-benign structure redefinition: incorrect initializers : KEY_EVENT_RECORD
\masm32\include\windows.inc(8158) : error A2163: non-benign structure redefinition: incorrect initializers : KEY_EVENT_RECORD
\masm32\include\windows.inc(8159) : error A2161: non-benign structure redefinition: too few labels : KEY_EVENT_RECORD
\masm32\include\windows.inc(8159) : error A2163: non-benign structure redefinition: incorrect initializers : KEY_EVENT_RECORD
\masm32\include\windows.inc(8162) : error A2163: non-benign structure redefinition: incorrect initializers : WINDOW_BUFFER_SIZE_RECORD
\masm32\include\windows.inc(8163) : error A2164: non-benign structure redefinition: too few initializers : WINDOW_BUFFER_SIZE_RECORD
\masm32\include\windows.inc(8175) : error A2163: non-benign structure redefinition: incorrect initializers : INPUT_RECORD
\masm32\include\windows.inc(8177) : error A2163: non-benign structure redefinition: incorrect initializers : INPUT_RECORD
\masm32\include\windows.inc(8177) : fatal error A1016: Internal Assembler Error
_
Assembly Error


I would guess this means I am missing some sort of libary or something, but I am not that sure.



Here is what the current includes are:
include \Irvine\Irvine32.inc
include \Irvine\macros.inc     
include \masm32\include\windows.inc   
include \masm32\macros\macros.asm
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
Title: Re: Setting up irvine libs with default masm install.
Post by: donkey on December 05, 2010, 10:12:36 AM
no, it means that there are multiple definitions for various structures and they are incompatible. I would guess you don't need Windows.inc.
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 10:31:20 AM
Well, I am not sure why I ended up with all these includes, I did not need a vast majority of them, but when I need one last one (macros.asm) for my print statements, I get this batch of errors:
\Irvine\SmallWin.inc(11) : warning A4011: multiple .MODEL directives found : .MODEL ignored
\masm32\macros\macros.asm(2850) : error A2005: symbol redefinition : MsgBox
\masm32\macros\macros.asm(2851) : error A2006: undefined symbol : styl
\masm32\macros\macros.asm(2851) : error A2114: INVOKE argument type mismatch : argument : 4
\masm32\macros\macros.asm(2851) : error A2006: undefined symbol : titlemsg
\masm32\macros\macros.asm(2851) : error A2114: INVOKE argument type mismatch : argument : 3
\masm32\macros\macros.asm(2851) : error A2006: undefined symbol : txtmsg
\masm32\macros\macros.asm(2851) : error A2114: INVOKE argument type mismatch : argument : 2
\masm32\macros\macros.asm(2851) : error A2006: undefined symbol : hndl
\masm32\macros\macros.asm(2851) : error A2114: INVOKE argument type mismatch : argument : 1
\masm32\macros\macros.asm(2851) : error A2034: must be in segment block
\masm32\macros\macros.asm(2852) : fatal error A1008: unmatched macro nesting
_


Now, my best guess is its having stuff redefined by smallwin.inc, but what I don't understand is that I am commenting it out of my code, so I would think that it would not override whatever libraries are still in the code.  Clearly this is not the case, so I am still unsure how to fix it, but for now I need to sleep.  I really appreciate the quick responses.
Title: Re: Setting up irvine libs with default masm install.
Post by: MichaelW on December 05, 2010, 10:34:26 AM
Considering the limitations of the Irvine components, why not just eliminate them and go with MASM32 for everything.
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 12:52:37 PM
if it's for school, you are probably expected to use Kip's LIB
Michael has the right stuff....
include Irvine32.inc
include macros.inc
includelib \masm32\lib\kernel32.lib

don't use the masm32 stuff, including windows.inc
but - you may want to put your Irvine stuff in a seperate folder, like \masm32\Irvine
then, specify that path...
include    \masm32\Irvine\Irvine32.inc
include    \masm32\Irvine\macros.inc
includelib \masm32\lib\kernel32.lib


Michael - shouldn't there be an includelib for Irvine32.lib also ???
or is it all text
do you not need:
include    \masm32\include\kernel32.inc
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 06:51:45 PM
When I just include:

include \Irvine\Irvine32.inc
include \Irvine\macros.inc     
includelib \masm32\lib\kernel32.lib

I end up with the following set of errors:
\Irvine\SmallWin.inc(11) : warning A4011: multiple .MODEL directives found : .MODEL ignore
C:\Users\Public\Documents\masm stuff\quicksort.asm(110) : error A2008: syntax error : print

And a bunch more print errors, obviously caused because I am not referencing the appropriate print macros.

How can I link to them without blowing up the program?

EDIT: In relation to the comment about abandoning Irvine libs, I emailed the professor and I am not required to use them it turns out, the only reason I am interested is the functionality of some fileio and the readint command.  If someone could point me the right direction for using stdin/stdout I would use that instead.
Title: Re: Setting up irvine libs with default masm install.
Post by: jj2007 on December 05, 2010, 07:04:40 PM
Quote from: jimmm on December 05, 2010, 06:51:45 PM
If someone could point me the right direction for using stdin/stdout I would use that instead.

\masm32\macros\macros.asm

Search the file for a case-sensitive Std
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 07:09:54 PM
well - i don't recall what readint is (read integer maybe?)
but - the masm32 macros and libraries take care of just about everything else
if readint is read integer, you can use input and one of the string/math conversion routines together to replace it

however - there is every possibility that fixing your current program is something simple

(1)
in Irvine32.lib, WriteString is used to output strings - not print
well - i can't find the macros file - i only have the lib

(2)
any program written for masm should begin with something like this...
       .486
       .MODEL  Flat,StdCall
       OPTION  CaseMap:None


fix those 2 things and it may work
it is easier for us if you post your code
below the reply window is a link for Additional Options
you may attach ZIP files to the post
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 07:20:09 PM
found the macro file

look up mWrite, mWriteLn, and mWriteStr in the macro file
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 07:27:09 PM
hang on - those macros are for 16-bit
i don't find a 32-bit macro file

SmallWin.inc takes care of the startup code
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 07:28:21 PM
dave: I am using that  set of opening flags:

Ill check the syntax for writestring and try replacing all my prints with that if what I am currently working on fails:

inputloop:
           mov edi, input("Enter number: ")
           mov array[esi],edi
           add esi,4
           sub count,1
           jnz inputloop


Is this what I should be doing?  I understand I will still need to find out how to convert string to int (working on that now) but for reading in numbers into an array, this would be the correct idea yes?

But depending on if I can replace all prints with the write stuff that I will look at now, I might not even need this, thank you.
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 07:33:47 PM
well - i may have a really old Irvine library, here

using input and print as you are indicates that you are mixing the masm32 library with the Irvine32 library
the Irvine stuff i have uses mWrite for print and mReadStr for input

for mReadStr....
        mReadStr offset Buffer,sizeof Buffer-1
i think sizeof Buffer-1 is correct
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 07:35:44 PM
it may be easier for you to use the masm32 library - lol
        include \masm32\include\masm32rt.inc
that takes care of all the startup code
then you can use input and print
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 07:41:53 PM
The code posted does not included any irvine libs, I figured I would see if I could avoid the external confusion since a vast majority of my code uses the masm32 libs.

And I flipped my mov statement in the example I posted...   :red
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 07:47:13 PM
ok
let's start fresh with masm32

see attached file...
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 07:58:41 PM
Quote from: dedndave on December 05, 2010, 07:47:13 PM
ok
let's start fresh with masm32

see attached file...
That I think I can follow, but why do you format your prints like that?  Mine have always been something like :
print chr$("Adjusting Pivot",13,10)

I am really new to masm so pardon my ignorance...
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 08:03:50 PM
both print and input accept several forms
in your previous example, you placed the address of the input buffer into a register
so, i followed that example and put it in edx
you could put it into a defined buffer and do it that way, too
or store the address returned by input and print StringPtr

i seem to recall that
        print     edx,13,10
does not work - i may be mistaken

this might...
        print     edx,chr$(13,10)

try this   :bg
        print   input("Enter some stuff: "),chr$(13,10)
something like that
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 08:22:15 PM
That explains a lot, I had no idea you could print so many different ways....  :eek


Anywho, I have great progress with my inital problem:

I can't post the full code since I do not have full rights to it (its a group project)

but what I have is the following:

I don't yet have empty array allocation working, still reading the example programs, so I just overwrite our test array

;---------------------------------------------------------------------------------
;DATA
;---------------------------------------------------------------------------------
.data
    array dd 9,8,7,6,5,4,3,2,1        ;test array. This will need to be replaced
                                      ;with a dynamic array read from a file or
                                      ;command line, preferrably both.


getarray proc
        LOCAL count :DWORD
        mov esi, 0                      ;initialize array addr counter
        mov count, 8                    ;init loop counter
        mov edi,0
         print chr$("input numbers now")
         inputloop:
            mov edi,0
            invoke atodw, input("Enter a number: ")
            mov array[esi],eax
            add esi,4
            sub count,1
            jnz inputloop
        mov edi, input("Enter number: ")
        invoke atodw, input("Enter a number: ")
        mov array[esi],eax
       
getarray endp


Now what I do not understand is that when I go to print my array after the data input, all but the last number shows up, and then the program crashes, I have the last number be read outside the loop to avoid any sort of oob error...
Title: Re: Setting up irvine libs with default masm install.
Post by: MichaelW on December 05, 2010, 08:36:47 PM
Quote from: dedndave on December 05, 2010, 12:52:37 PM
Michael - shouldn't there be an includelib for Irvine32.lib also ???

Yes. My copy of SmallWin.inc starts with:

.386
.MODEL flat, stdcall
.STACK 4096

includelib irvine32.lib


But now that I check I think I modified it at some point.

Quote
do you not need:
include    \masm32\include\kernel32.inc

The necessary prototypes, constants, and structures are in SmallWin.inc.

Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 08:38:17 PM
Jim - is it just me, or is that PROC missing a RET   :bg

thanks Michael
i think we have an "Irvine2masm32" convert, though   :U
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 08:45:15 PM
getarray proc
        LOCAL count :DWORD
        mov esi, 0                      ;initialize array addr counter
        mov count, 8                    ;init loop counter
        mov edi,0
         print chr$("input numbers now"),13,10                            ;added 13,10
         inputloop:
            mov edi,0
            invoke atodw, input("Enter a number: ")
            mov array[esi],eax
            add esi,4
            sub count,1
            jnz inputloop
    ;    mov edi, input("Enter number: ")                                 ;commented this line out
        invoke atodw, input("Enter a number: ")
        mov array[esi],eax
        ret                                                               ;added RET
getarray endp
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 08:46:51 PM
getarray proc
        LOCAL count :DWORD
        mov esi, 0                      ;initialize array addr counter
        mov count, 9                    ;init loop counter                 made it 9
        mov edi,0
         print chr$("input numbers now"),13,10                            ;added 13,10
         inputloop:
            mov edi,0
            invoke atodw, input("Enter a number: ")
            mov array[esi],eax
            add esi,4
            sub count,1
            jnz inputloop
    ;    mov edi, input("Enter number: ")                                 ;commented this line out
    ;    invoke atodw, input("Enter a number: ")                          ;commented this line out
    ;    mov array[esi],eax                                               ;commented this line out
        ret                                                               ;added RET
getarray endp
Title: Re: Setting up irvine libs with default masm install.
Post by: donkey on December 05, 2010, 08:47:30 PM
Maybe I'm mistaken but from what I gather reading through this thread I can't see any use for the MASM32 files at all. I mean the Irvine includes and/or libs are used by countless students every day and you would think that they must work or all heck would break loose. The problem as far as I can see is the attempt to mix and match different and incompatible libraries and includes. Most problems he has had so far have been solved by removing yet another component of MASM32 from his build, perhaps he is better to decide on one or the other but mixing them seems counter-productive.

Edgar
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 05, 2010, 08:49:07 PM
i think that has been done, Edgar
he seems happy to have done away with Irvine altogether and stick with masm32
Title: Re: Setting up irvine libs with default masm install.
Post by: jimmm on December 05, 2010, 08:59:24 PM
Quote from: donkey on December 05, 2010, 08:47:30 PM
Maybe I'm mistaken but from what I gather reading through this thread I can't see any use for the MASM32 files at all. I mean the Irvine includes and/or libs are used by countless students every day and you would think that they must work or all heck would break loose. The problem as far as I can see is the attempt to mix and match different and incompatible libraries and includes. Most problems he has had so far have been solved by removing yet another component of MASM32 from his build, perhaps he is better to decide on one or the other but mixing them seems counter-productive.

Edgar

That is what happened originally, we finished the quicksort and were looking at some more advanced things to do with it, so the first thing I found on google was the irvine libaries for the ReadInt, which did exactally what I was looking for at the time, as I was still unfamiliar overall with masm.  Considering all the other libaries we had in our code from masm32, it appears mixing them was just a disastrous thing to do.  Thankfully the other forummembers assisted me in finding all the appropiate code alternatives to use just masm.

In relation to my code that you folks helped correct:
EDIT: the problem has been solved, I had messed up my printarray function so it did not preserve registers.
Title: Re: Setting up irvine libs with default masm install.
Post by: dedndave on December 06, 2010, 12:01:21 AM
"uses" on the PROC line saves registers for you
in win32 code, EBX, ESI, EDI, EBP should be preserved and the DF should remain cleared
EAX, ECX, EDX may be trashed and are often used to status and/or return result values
getarray PROC uses esi edi

        LOCAL   count:DWORD

        mov     esi,0           ;initialize array addr counter
        mov     count,9         ;init loop counter
        mov     edi,0
        print   chr$("input numbers now"),13,10

inputloop:
        mov     edi,0
        invoke  atodw,input("Enter a number: ")
        mov     array[esi],eax
        add     esi,4
        sub     count,1
        jnz     inputloop

        ret

getarray ENDP

although, i dunno what you are doing with EDI   :P