News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Setting up irvine libs with default masm install.

Started by jimmm, December 05, 2010, 09:09:59 AM

Previous topic - Next topic

jimmm

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

dedndave

ok
let's start fresh with masm32

see attached file...

jimmm

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...

dedndave

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

jimmm

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...

MichaelW

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.

eschew obfuscation

dedndave

Jim - is it just me, or is that PROC missing a RET   :bg

thanks Michael
i think we have an "Irvine2masm32" convert, though   :U

dedndave

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

dedndave

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

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

i think that has been done, Edgar
he seems happy to have done away with Irvine altogether and stick with masm32

jimmm

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.

dedndave

"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