News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

starter with masm32 help

Started by ratten, February 26, 2018, 07:37:17 AM

Previous topic - Next topic

ratten

Hi I am in a assembly course this semester and I just begun reading the book, I am required to do a program that calculates the following expression: A = (B) + (C-D), using registers here is what I got:

include c:\masm32\include\Irvine32.inc
includelib c:\masm32\lib\irvine32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib

.data
A DWORD 150
B DWORD 100
F DWORD 50
D DWORD 40               
.code
main PROC
   
    mov eax,A
    mov ebx,B
    mov ecx,F
    mov edx,D
   
    add eax,ebx
    add ecx,edx
    sub eax,ecx
   
    mov A,eax
   
    exit
   
    main ENDP

END main

but when I compile it? I think it goes thorugh but then I get this:
/z2
"first.obj"
"first.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
first.obj : warning LNK4033: converting object format from OMF to COFF
first.exe : fatal error LNK1136: invalid or corrupt file

I got expirience with c++ but I am new with assembly so would appreciate some advice and also if anyone knows about a good "tutorial" or lessons wold be good

Thanks!

LordAdef

Welcome,

Masm32 is all you need. The examples in the package are very instructive. Also, search what you need here in the Campus.
There´s a lot you can learn by doing this.

BTW, you know you don´t need Irvine´s includes for what you are doing right? If in the masm32 environment, just include include "\masm32\include\masm32rt.inc" and you will be fine.

I´m building your example without a problem

jj2007

LordAdef is right. Here is your example in Masm32 version (installation hints):
include \masm32\include\masm32rt.inc

.data
A DWORD 150
B DWORD 100
F DWORD 50
D DWORD 40               
.code
main PROC
   
    mov eax,A
    mov ebx,B
    mov ecx,F
    mov edx,D
   
    add eax,ebx
    add ecx,edx
    sub eax,ecx
   
    mov A,eax
    inkey str$(A), " is the result" ; a Masm32 macro
    exit
   
    main ENDP

END main


Output: 160 is the result

There are very good reasons to dump the Irvine library: outdated, not ABI-compliant, etc etc; problem is that apparently many assembler teachers have no idea what they are talking about. If your prof is a reasonable person, try to convince him to look at the Masm32 SDK.

LordAdef

Quoteproblem is that apparently many assembler teachers have no idea what they are talking about

I don´t understand them either... laziness? You could "even" keep Irvine´s book for starter/reference but use masm32 as the working environment. Only god knows...

jj2007

Quote from: LordAdef on February 26, 2018, 08:36:32 AMlaziness?

Most probably they are proficient in several popular languages like Java, C, Python, but they suddenly find out that they are obliged to teach assembly. So they find the Irvine book in the university library and hack together some exercises. Look at the example above: single letter variables A, B, CF, D - really, really old members here may remember Dartmouth BASIC 8)

But it works to a certain degree - why drive a Ferrari (Masm32) if you can ride a bicycle (Irvine)?  ;)

ratten

Hi thank you for the replies!, but I am still unable to get the code going I am using qeditor that comes with masm should I use a different one? the problems that I have are when I compile anything I get the following error:
Using codepage 1252 as default
Creating rsrc.RES
RC: RCPP -CP 1252 -f C:\WINDOWS\system32\RCa06116 -g C:\WINDOWS\system32\RDa06116 -DRC_INVOKED -D_WIN32 -pc\:/ -E -I. -I .

RC : fatal error RC1110 : could not open rsrc.rc

I dont know what to do there and if I build it i get:

LINK : fatal error LNK1181: cannot open input file "C:\masm32\bin\first.obj"
_
Link error

linking it doest help either. I am sorry if Im asking basic stuff but this is the first program that I am creating on assembly language


jj2007

With qeditor, Project/Console build all 32 should be OK for your project. The rc stuff is a bit mysterious, though. Is your *.asm file in the folder C:\Masm32\ ?

And don't be shy to ask basic stuff. Something in your setup is not "basic", personally I have never seen a commandline that contained C:\WINDOWS\system32\RDa06116, so I really wonder where that crept in...

ratten

I have the asm file here: C:\masm32\bin\first.asm

jj2007

OK, move it to C:\Masm32\first.asm and open it in qEditor.exe. When you click menu Project/Console build all, what do you see? Which error messages if any?

ratten

Assembling: C:\masm32\first.asm

***********
ASCII build
***********

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Volume in drive C has no label.
Volume Serial Number is C4C7-D18C

Directory of C:\masm32

02/25/2018  04:18 PM               323 first.asm
02/25/2018  04:20 PM             2,560 first.exe
02/25/2018  04:20 PM               937 first.obj
               3 File(s)          3,820 bytes
               0 Dir(s)  31,231,934,464 bytes free
Press any key to continue . . .

No errors whatsoever, I can do almost everything except compile it and when I click run nothing happens, thanks for sticking up with me!

LordAdef

ratten,

Try JJ´s code first!

Your code doesn´t have any output to console, so you will never see anything

ratten

oh with JJ's code it promps me the following when I build it:

***********
ASCII build
***********

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : fatal error LNK1104: cannot open file "first.exe"
_
Link error

and if I try to run it, the program kinda frezzes, and it still gives me the same error when I tried to compile it

LordAdef

So, it builds fine here with qEditor:
Quoteinclude \masm32\include\masm32rt.inc

.data
A DWORD 150
B DWORD 100
F DWORD 50
D DWORD 40               
.code
main PROC
   
    mov eax,A
    mov ebx,B
    mov ecx,F
    mov edx,D
   
    add eax,ebx
    add ecx,edx
    sub eax,ecx
   
    mov A,eax
    inkey str$(A), " is the result"   ; a Masm32 macro
    exit
   
    main endp

end main

Are you saving your file as "whatever.asm" with asm at the end?
Where is your masm32 installed?

LordAdef

QuoteLook at the example above: single letter variables A, B, CF, D - really, really old members here

O noticed that too! Not too asm like

jj2007

Quote from: ratten on February 26, 2018, 09:34:26 AMLINK : fatal error LNK1104: cannot open file "first.exe"

"cannot open" typically means that the file is in use. If you can see the process in Task Manager, kill it and assemble again.

Note it must be Project/Console assemble & link, otherwise it assembles as a Windows GUI application, and you can't see any output, plus the inkey won't work.

If it builds successfully, click Project/Run program.