The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: roddym on February 28, 2010, 06:48:46 PM

Title: Getting started
Post by: roddym on February 28, 2010, 06:48:46 PM
Hi I'm pretty new to assembly language ( though I've tried a few online tutorials( failed in all)) I'm on a compaq presario SR2050NX( added ram) can anyone help me? ( best I've done with any assembler is no codes like mov or include statement or anything like that(aka blank slate lol))
Title: Re: Getting started
Post by: roddym on February 28, 2010, 06:53:31 PM
oh one other thing I'm on windows 7
Title: Re: Getting started
Post by: ragdog on February 28, 2010, 07:01:40 PM
Hi

For learn if Izelion tutorials a good adress
http://win32assembly.online.fr/tutorials.html

best greets
Title: Re: Getting started
Post by: roddym on February 28, 2010, 07:10:48 PM
no matter what code I've tried I get:

LINK : fatal error LNK1181: cannot open input file "C:\try1.obj"
Title: Re: Getting started
Post by: roddym on February 28, 2010, 07:15:50 PM
 I stand corrected I tried:

.386
.model small
.data
.code
start:
end start


and got this:

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\try2.asm
C:\try2.asm(6) : warning A4023: with /coff switch, leading underscore required f
or start address : start
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : error LNK2001: unresolved external symbol _start
try2.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
Press any key to continue . . .
Title: Re: Getting started
Post by: ragdog on February 28, 2010, 07:40:15 PM
I have test it

here is my solution
.model small,STDCALL

this works
Title: Re: Getting started
Post by: roddym on February 28, 2010, 10:19:28 PM
nope nothing works for me , even in a math program that can write to file I can't open a a file for writing(i/o disabled by virus ?(or my own idiocy?)) so that stops that
Title: Re: Getting started
Post by: roddym on February 28, 2010, 10:22:05 PM
which is weird as my antivirus looks to be working
Title: Re: Getting started
Post by: dedndave on February 28, 2010, 10:32:28 PM
the model directive will be different for 16-bit and 32-bit code - they also require different linkers
so, it depends on which type you are trying to write
give us some info
have you installed the masm32 package ?
maybe you could post some code
or - go to this link and d/l the attachment
there is a simple program of both types with batch files to assemble...

http://www.masm32.com/board/index.php?topic=12621.msg97236#msg97236
Title: Re: Getting started
Post by: roddym on February 28, 2010, 10:45:35 PM
Quote from: dedndave on February 28, 2010, 10:32:28 PM
the model directive will be different for 16-bit and 32-bit code - they also require different linkers
so, it depends on which type you are trying to write
give us some info
have you installed the masm32 package ?
maybe you could post some code
or - go to this link and d/l the attachment
there is a simple program of both types with batch files to assemble...

http://www.masm32.com/board/index.php?topic=12621.msg97236#msg97236
dedndave the error I get is it can't open the .asm file but unless I've affected the i/o structure of my pc( or a virus) that shouldn't affect a math program totally unrelated to masm as for code I've posted all the code I've tried.
Title: Re: Getting started
Post by: dedndave on February 28, 2010, 11:08:42 PM
QuoteLINK : fatal error LNK1181: cannot open input file "C:\try1.obj"

ok - it can't open the OBJ
first - the root directory isn't the best place - lol - but it should work
does that OBJ exist ?
is it the right kind of OBJ file ?
you might want to look at the d/l from that link
in the batch files are the appropriate assembly and link command line parameters
it sounds like you may not have a COFF OBJ file
i can't tell, as you are not providing us with sufficient information

also, make sure you have a 16-bit linker for 16-bit code or a 32-bit linker for 32-bit code

have you installed the masm32 package ?
we can't help you without info   :P
Title: Re: Getting started
Post by: roddym on February 28, 2010, 11:16:38 PM
figured it out though I still think my i/o is broke lol. I have the basics working lol
Title: Re: Getting started
Post by: roddym on February 28, 2010, 11:17:40 PM
now what's the easiest way to print hello world ? or write to file ( test for io)
Title: Re: Getting started
Post by: roddym on February 28, 2010, 11:44:46 PM
okay I've got code working in masm but apparently it's not valid win 32
Title: Re: Getting started
Post by: roddym on February 28, 2010, 11:45:24 PM
.386
.model small,STDCALL
.data
.code
start:
mov eax,32h
end start
Title: Re: Getting started
Post by: jj2007 on February 28, 2010, 11:48:16 PM
This will work if you have installed Masm32.

include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
invoke ExitProcess, 0

end start
Title: Re: Getting started
Post by: roddym on February 28, 2010, 11:51:42 PM
still tells me it's not win32
Title: Re: Getting started
Post by: roddym on March 01, 2010, 12:24:27 AM
anyone want to help me do win32 assembly ? apparently nothing I've tried works to be
Title: Re: Getting started
Post by: dedndave on March 01, 2010, 01:49:37 AM
best thing i can suggest is to download and install the masm32 package
it will make your life a lot easier   :U

http://www.masm32.com/masmdl.htm

when you install it, close all other programs and do not interrupt it until it is done
Title: Re: Getting started
Post by: hutch-- on March 01, 2010, 02:08:53 AM
roddym,

If you install masm32 on Win7, do nnot trey to install or run it from a limited or restricted profile as you may not have permission to write to disk or run EXE files that are used by the install.
Title: Re: Getting started
Post by: GregL on March 01, 2010, 02:25:10 AM
Hutch,

For me, MASM32 installed OK on Windows 7 with a non-admin account, more than once.

Probably because Windows Vista and 7 elevate setup.exe and other installation programs automatically.

Title: Re: Getting started
Post by: hutch-- on March 01, 2010, 03:04:59 AM
Thanks Greg, you should see the hassles of running anything in a restricted profile in XP SP3.  :dazzled:
Title: Re: Getting started
Post by: GregL on March 01, 2010, 03:22:16 AM
I vaguely remember running XP SP3.  They improved things regarding running as non-admin in Vista and have improved it a lot more in Windows 7.  Vista and 7 were designed from the ground up with running as non-admin in mind.  In XP SP3 it was kind of an after thought.

You should just bite the bullet and install Windows 7.  I think you'd like it.

Title: Re: Getting started
Post by: hutch-- on March 01, 2010, 05:45:56 AM
 :bg

Probably would but I must span backwards to Win2000, the other factor is a professional version of Win7 is worth a fortune out here at the moment so I am in no mad rush.
Title: Re: Getting started
Post by: Ghandi on March 01, 2010, 06:54:40 AM
Not counting pre-NT systems, i've used MASM32 on XP , Vista and Windows 7 and i can honestly say that for my own experience, UAC made the only real difference when it came to assembling and linking and that was dependant on where i was trying to actually create files. If the folder had access restrictions, then it would fail to create files but if it didnt then it had no trouble. I use WinASM for a MASM IDE and the simplest solution i came up with was to open the properties view of the shortcut via right click and going to the Compatibility tab to check the "Run as Administrator" tickbox  so the IDE would ask me for elevated privileges every time i would run it.

I applied this solution to OllyDbg also, because it would complain that it wasnt running as Administrator also and i like to be able to debug my own projects so i can see it all in action. I know that this isn't exactly in the spirit of security, UAC is there for a reason and i probably should have made a better selection when deciding where to place my projects, so dont think that i'm saying this is a good idea, its just what i did as a workaround for my particular problem.

HR,
Ghandi
Title: Re: Getting started
Post by: roddym on March 01, 2010, 12:38:24 PM
dendave I have in fact this is where i got it. before I complained how do I change my admin status on windows etc. ?
Title: Re: Getting started
Post by: roddym on March 01, 2010, 12:39:57 PM
oh wait I'm automatic an admin and it still won't allow it lol
Title: Re: Getting started
Post by: hutch-- on March 01, 2010, 02:01:42 PM
roddym,

Instead of feeding us results, tell us the necessary things.

OS version.
MASM (ML version)
What have you done to build your code. (options, command line switches etc ....
If you have installed the masm32 project, did it install correctly and build all of the libraries ?
Title: Re: Getting started
Post by: GregL on March 01, 2010, 10:05:01 PM
I'm going on the assumption that you have MASM32 installed.

Looking at your original code, you should be using .MODEL FLAT,STDCALL instead of .MODEL SMALL,STDCALL.

Title: Re: Getting started
Post by: roddym on March 01, 2010, 10:06:25 PM
OS : listed

MASM32 editor

I've tried every combo of assemble asm link and build I think

I don't know all libraries I saw it build something lol
Title: Re: Getting started
Post by: roddym on March 01, 2010, 10:12:20 PM
Microsoft (R) Windows (R) Resource Compiler, Version 5.00.1823.1 - Build 1823
Copyright (C) Microsoft Corp. 1985-1998. All rights reserved.

Using codepage 1252 as default
Creating rsrc.RES
RC: RCPP -CP 1252 -f C:\masm32\RCa02072 -g C:\masm32\RDa02072 -DRC_INVOKED -D_WI
N32 -pc\:/ -E -I. -I .


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


Microsoft (R) Windows Resource To Object Converter Version 5.00.1736.1
Copyright (C) Microsoft Corp. 1992-1997. All rights reserved.

CVTRES : fatal error CVT1101: cannot open rsrc.res for reading
Press any key to continue . . .
even with this if I/o doesn't work doesn't matter also
Title: Re: Getting started
Post by: jj2007 on March 01, 2010, 11:23:32 PM
If nothing else helps, try your luck with the RichMasm IDE (http://www.masm32.com/board/index.php?topic=12460). It is set up to run most if not all Masm32 examples by simply pressing F6.
Title: Re: Getting started
Post by: roddym on March 02, 2010, 12:11:51 AM
if I/O is down like it acts like it won't matter it won't work anyone know how to fix the I/O register of and intel chip ?
Title: Re: Getting started
Post by: jj2007 on March 02, 2010, 12:34:41 AM
Your OS would not even say blurp! if I/O was down on the chip...
Title: Re: Getting started
Post by: dedndave on March 02, 2010, 12:38:04 AM
Roddy
you must understand that we have been through this countless times with other n00bs   :bg
95% of the time, it is a setup issue
the other 5%, it is the code
so, if you have it set up as we suggested
and you are assembling a program we know assembles
it will probably work
Title: Re: Getting started
Post by: roddym on March 02, 2010, 12:52:16 AM
well obviously you haven't had the situation and data I've shown you as you don't know how to use it... I did the file as said by you the .res can't be done as it can't be accessed the build part works but the file says it's not win32  also when I get errors it says can't access the files I get a write error in a math program that I use ( which can write to disk) I'm an admin so unless windows 7 doesn't let you alter files with code I'm stumped unless it's the new version of avast I have. or an i/o partial failure.
Title: Re: Getting started
Post by: hutch-- on March 02, 2010, 01:16:41 AM
roddym,

If you are not willing to tell us the minimum to answer your questions perhaps you should be trying to use something else that is simple enough for you to understand. If you computer is not configured correctly, fix it and then try and install the software. members here go out of their way to help new programmers but they are not here to have their time wasted.
Title: Re: Getting started
Post by: roddym on March 02, 2010, 01:39:05 AM
Quote from: roddym on February 28, 2010, 06:48:46 PM
I'm on a compaq presario SR2050NX(added ram) ( best I've done with any assembler is no codes like mov or include statement or anything like that(aka blank slate lol))
Quote from: roddym on February 28, 2010, 06:53:31 PM
I'm on windows 7
Quote
.386
.model small
.data
.code
start:
end start

Quote from: roddym on February 28, 2010, 10:19:28 PM
nope nothing works for me , even in a math program that can write to file I can't open a a file for writing(i/o disabled by virus ?(or my own idiocy?)) so that stops that
Quote
dedndave the error I get is it can't open the .asm file but unless I've affected the i/o structure of my pc( or a virus) that shouldn't affect a math program totally unrelated to masm as for code I've posted all the code I've tried.
Quote from: roddym on February 28, 2010, 11:45:24 PM
.386
.model small,STDCALL
.data
.code
start:
mov eax,32h
end start

I'm not trying to waste time it's masm32 v 4.0 . I let it install itself so if it's not installed right I don't understand it. 
OS = win 7
I've got the code you gave me assembling using almost any combo now my problem is it comes up with <filename> is not a valid win32 application and that if I select compile resource file it come to an error I posted earlier about how it can't gain access to it. this fits all her necessaries if she can't help me now I start lowering iq's!
Title: Re: Getting started
Post by: qWord on March 02, 2010, 01:43:47 AM
it must be
.model flat,STDCALL
also a ret befor end start is missing
Title: Re: Getting started
Post by: roddym on March 02, 2010, 01:52:02 AM
Quote from: qWord on March 02, 2010, 01:43:47 AM
it must be
.model flat,STDCALL
also a ret befor end start is missing


the ret I don't know how to write and I've tried the flat change still came up with ... is not a valid win32 application.
Title: Re: Getting started
Post by: qWord on March 02, 2010, 02:00:25 AM
.686p
.model flat,STDCALL
option casemap :none
.code
start:
xor eax,eax
ret
end start

compile & link:

C:\masm32\bin\ML.EXE /c /coff /I"C:\masm32\include" YourFile.asm
C:\masm32\bin\LINK.EXE /SUBSYSTEM:CONSOLE /LIBPATH:"C:\masm32\lib" YourFile.obj
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:09:28 AM
THANK YOU without the last 2 lines I saw in the post it doesn't give me an error now can you help me through hello world( seen many variants online)
Title: Re: Getting started
Post by: qWord on March 02, 2010, 02:16:54 AM
Quote from: roddym on March 02, 2010, 01:39:05 AMit's masm32 v 4.0
you should install  version 10 (http://masm32.com/) - that's make live easier.
.686p
.model flat,STDCALL
option casemap :none
include kernel32.inc
includelib kernel32.lib
.data
szText db "Hello World",0
szCaption db "Hello",0
.code
start:
invoke MessageBox,0,OFFSET szText,OFFSET szCaption,0
xor eax,eax
ret
end start
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:23:50 AM
I can't find masm in my uninstall list how do i get the old version off
Title: Re: Getting started
Post by: qWord on March 02, 2010, 02:25:05 AM
simply delete(or rename) the masm32-folder
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:32:12 AM
I installed the new one says it can't open kernel32.inc
Title: Re: Getting started
Post by: hutch-- on March 02, 2010, 02:35:28 AM
roddym,

We have a solution for smartarses, we show them the door. Now after wasting many peoples time we find out you are trying to install a version of masm32 that is something like 10 years old on a machine that appears to be viral damaged.

Fix your computer so its clean and has a properly installed operating system then install the current version. Any more nonsense and you can "lol" somewhere else.
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:43:49 AM
Sorry about the comments , I just felt like I wasn't getting anywhere. As far as I can tell it might be but I tried to convey that this whole time everyone told me I was wrong. can you help me figure out how to fix it ? I wouldn't be surprised no antivirus is worth it I was on a trial avast then switched to another one avast had told me 0 infected files (the other found a Trojan horse), I stupidly clicked a link one time from an aunt on facebook and It tried downloading a Trojan downloader(never made that one twice). also can anyone tell me why it always seems to have trouble accessing files if it isn't viral ?
Title: Re: Getting started
Post by: qWord on March 02, 2010, 02:46:59 AM
try to replace
.686p
.model flat,STDCALL
option casemap :none
include kernel32.inc
includelib kernel32.lib

with
include C:\masm32\masm32rt.inc
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:47:53 AM
so exchange ~6 lines with 1 ?
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:48:58 AM
still didn't work
Title: Re: Getting started
Post by: hutch-- on March 02, 2010, 02:49:28 AM
roddym,

Try one of the very reliable AV scanners like ESET or KASPERSKY. Download their trial version and see if you can fix it with either of those. If there is too much damage done you may have to re-install your OS to be safe. I don't yet use Win7 but see if you7 can do a revert back to an earlier configuration that may solve the problem. Idea is to get the machine clean and working properly, then normal stuff will work OK.
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:55:05 AM
Okay I might try that, though I've never heard of either it was installed within 3 days ago
Title: Re: Getting started
Post by: roddym on March 02, 2010, 02:58:43 AM
in fact when I first learned C ( I also know some VB) I was thinking of building my own AV ( never came through), my programming background comes HTML, javascript,and CSS + an urge by a "non-programming" sisters boyfriend ( annoying). how will reinstalling my OS help if it's got to my CPU ?
Title: Re: Getting started
Post by: dedndave on March 02, 2010, 03:01:02 AM
i use Malwarebyte's Anti-Malware
i wouldn't use any other AV program
Title: Re: Getting started
Post by: roddym on March 02, 2010, 03:03:00 AM
can someone tell me how reinstalling my OS will get rid of something that may be in my CPU( if it's a virus affecting I/O)
Title: Re: Getting started
Post by: dedndave on March 02, 2010, 03:05:11 AM
i think there is a flaw in the conclusion that you have a bad CPU
if your CPU were bad, you probably wouldn't get past BIOS, or even into it, at boot
Title: Re: Getting started
Post by: jj2007 on March 02, 2010, 07:51:53 AM
Try the code below, please.

include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start


Where exactly is your \masm32 folder?
Title: Re: Getting started
Post by: roddym on March 03, 2010, 12:40:25 PM
 I tried reinstalling and finally got kaspersky working  it found nothing even on a deep scan of everything I found in their list the code last posted I've tried it worked however Kaspersky obviously can't find a visual problem ( any idea how to restore to normal (or write over) visual memory so it looks good). if I apply that to math operations I think I'll have what i want lol though pari GP can right out numbers bigger than 32 bit.
Title: Re: Getting started
Post by: roddym on March 03, 2010, 12:41:59 PM
so anyone want to run me through math operations ?
Title: Re: Getting started
Post by: roddym on March 03, 2010, 03:38:34 PM
Quote from: jj2007 on March 02, 2010, 07:51:53 AM

include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start


I've also tried :

include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start:
mov eax,9h
mov ebx,9h
add eax,ebx
MsgBox 0, eax, addr AppName, MB_OK
exit

end start


trying to find out how to show the result in the message box can anyone walk me through it ?
Title: Re: Getting started
Post by: roddym on March 03, 2010, 03:39:13 PM
I forgot about this site:

http://www.jegerlehner.com/intel/opcode.html
Title: Re: Getting started
Post by: qWord on March 03, 2010, 03:40:42 PM
MsgBox 0, str$(eax), addr AppName, MB_OK
Title: Re: Getting started
Post by: roddym on March 03, 2010, 03:56:03 PM
see now I love it as I now can figure things out faster thank you all I'll see what I can do for now
Title: Re: Getting started
Post by: roddym on March 03, 2010, 04:15:02 PM
is there a list I'm not seeing that list how to get things like menus etc ?
Title: Re: Getting started
Post by: qWord on March 03, 2010, 04:35:20 PM
read Iczelion's Tutorials (http://website.masm32.com/iczelion/iczelion.zip)
Title: Re: Getting started
Post by: roddym on March 03, 2010, 04:56:32 PM
can't get it to work wonder if I have winrar lol
Title: Re: Getting started
Post by: roddym on March 03, 2010, 05:57:06 PM
include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0
AppName2 db "Masm33:", 0
AppName3 db "Masm34:", 0

start:
mov eax,1h
MsgBox 0, str$(eax), addr AppName, MB_OK
add eax,eax
inc eax
MsgBox 0, str$(eax), addr AppName2, MB_OK
add eax,eax
inc eax
MsgBox 0, str$(eax), addr AppName3, MB_OK
exit

end start


It works for the first 2 but the third only changes the title the number should change but it doesn't it's the mersenne sequence if you'd like to know so 1,3,7, right now it's going 1 3 & 3

Title: Re: Getting started
Post by: qWord on March 03, 2010, 06:14:51 PM
eax,edx and ecx can be used by API-call without saving them. Edi, esi and ebx are preserved (inside API-callback you must preserve them if used). Also eax is used as return value for functions, so that its content allways change. This is called WinABI - Windows Application Binary Interface.
You must save EAX (e.g. on stack), because it is changed by MessageBox.
Title: Re: Getting started
Post by: roddym on March 03, 2010, 07:05:21 PM
thanks I changed it to ebx it worked better