News:

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

Really new and need help

Started by newbieinfl, March 24, 2006, 03:46:29 PM

Previous topic - Next topic

newbieinfl

I am very new to MASM and taking a course in it.  I have one of the worst teachers in the world so I am coming here to more competent people for help.  I am trying to write a program that finds the square root of a number input by a user with a call to an external procedure for computing the square root.  We have a very rudimentary square root program provided in the text.  I have two problems.  First, I first tried writing the program in one asm file to make sure it worked but I was unable to get the answer in the correct format.  I have attached the first go round and labeled it sqrt1.asm. My second problem is when I tried to split out the procedure and used a call function, the link process said it could not open my include file even though it was in the same directory.  I have included bothe of those files and called them main.asm and sqrt.inc.  Any help would be greatly appreciated as I have many other programs to write for this class and can't seem to get beyond this simple program.  Thanks!

-JR

[attachment deleted by admin]

MichaelW

The statement to include sqrt.inc is not formatted correctly. It needs to be like the include statement that is working. Including the file above the model directive will not work. You need to move the include statement down below the model directive, in the area where the working include statement is located. The root procedure seems to work OK.

eschew obfuscation

newbieinfl

Thank so much for the post.  I took yoru advice but I am still getting the following message:

Assembling: richard_6.2.2.asm
richard_6.2.2.asm(10): fatal error A1000: cannot open file : "sqrt.inc"

Any other ideas?

Mark Jones

Hi JR, welcome to the group! :bg

Q: Why the % in front of INCLUDE? Is that part of the syntax?

Note: In main.asm and sqrt1.asm you prototype ExitProcess, which should already be prototyped. (It is part of \masm32\include\windows.inc so if that is included somewhere else, this prototype is redundant.)

Q: Do you need ".STACK  4096"?  It can probably be omitted; this only needs to be set when you're using lots of local variables, which use stack bytes.

Note: ALL code in a MASM32 .ASM file must reside within the "_start:" and "end _start" blocks; this is how MASM32 determines where to start program execution. In sqrt1.asm, is something outside the start block? :wink
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

P1

newbieinfl,

Welcome a Board !!!       :U

Forum 'Search' is your friend, along with Google.   

Please read the forum rules after your homework is done.   :naughty:

QuoteINCLUDE io.h
Missing In Action.

QuoteExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
Missing In Action.  Library?  32 bit code or 16?

We will assume IO.h is to support your functions, but It looks like you might be using them wrong.  I don't know that for sure, unless you provide the code.

Quote from: Mark Jones on March 24, 2006, 07:45:35 PM
Note: ALL code in a MASM32 .ASM file must reside within the "_start:" and "end _start" blocks; this is how MASM32 determines where to start program execution.
Not exactly right.  Procedures can go above the start/execution block, for proto-less use in .code blocks.

.data
szMessage   db "It Works!",0 
szMsgTitle  db "Hey",0

.code

MsgBox proc
invoke MessageBox,0,ADDR szMessage,ADDR szMsgTitle,MB_OK
ret
MsgBox endp

start:
invoke MsgBox
invoke ExitProcess,NULL

end start


I'll teach you techniques and help you spot errors, but beyond that, I don't do homework.

Regards,  P1  :8)

MichaelW

JR,

This works:

INCLUDE io.h

And this does not:

include "sqrt.inc"

And the problem is not 'INCLUDE' versus 'include'.

eschew obfuscation

newbieinfl

#6
P1-

I respect that.  Can you help me figure out why when I output my answer I get a heart instead of an integer?  I can't seem to figure it out and I have looked over every atod, atoi, etc. function.  Thanks.

Newbie


Quote from: P1 on March 24, 2006, 11:06:06 PM
newbieinfl,

Welcome a Board !!!       :U

Forum 'Search' is your friend, along with Google.   

Please read the forum rules after your homework is done.   :naughty:

QuoteINCLUDE io.h
Missing In Action.

QuoteExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
Missing In Action.  Library?  32 bit code or 16?

We will assume IO.h is to support your functions, but It looks like you might be using them wrong.  I don't know that for sure, unless you provide the code.

Quote from: Mark Jones on March 24, 2006, 07:45:35 PM
Note: ALL code in a MASM32 .ASM file must reside within the "_start:" and "end _start" blocks; this is how MASM32 determines where to start program execution.
Not exactly right.  Procedures can go above the start/execution block, for proto-less use in .code blocks.

.data
szMessage   db "It Works!",0 
szMsgTitle  db "Hey",0

.code

MsgBox proc
invoke MessageBox,0,ADDR szMessage,ADDR szMsgTitle,MB_OK
ret
MsgBox endp

start:
invoke MsgBox
invoke ExitProcess,NULL

end start


I'll teach you techniques and help you spot errors, but beyond that, I don't do homework.

Regards,  P1  :8)

newbieinfl

Michael-

I got it.  It's the quotes.  Thanks, I should have tried that but I was going by the book which seems to have some incorrect syntax.  Now to figure out why my answer is a heart and not an Integer.   :toothy  Thanks for the help!

JR


Quote from: MichaelW on March 25, 2006, 05:47:42 AM
JR,

This works:

INCLUDE io.h

And this does not:

include "sqrt.inc"

And the problem is not 'INCLUDE' versus 'include'.



newbieinfl

Ok guys-

I figured it out.  I was using doublewords instead of bytes for my input/ouput number and answer.  Thanks to all for helping and I will definitely use this forum (searching first) in the future. 

JR

Mark Jones

Quote from: P1 on March 24, 2006, 11:06:06 PM
Quote from: Mark Jones on March 24, 2006, 07:45:35 PM
Note: ALL code in a MASM32 .ASM file must reside within the "_start:" and "end _start" blocks; this is how MASM32 determines where to start program execution.
Not exactly right.  Procedures can go above the start/execution block, for proto-less use in .code blocks.

Oh yes you are right. This happened in a module file with a mis-named END label, sorry! :red :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08