News:

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

Need help with Floating Points

Started by rubsnick, November 10, 2010, 04:46:13 PM

Previous topic - Next topic

rubsnick

Alright so this is my program
I'm using Kip Irvines Library and it's using MASM
http://pastebin.com/UxRnigDD

I'm having two basic problems, One is floating point it gives me the result in Decimal but it also adds a 10 and has no decimal point so I dunno how to fix that.

THe other problem is that I don't know how to make the program STOP. When it does one of the procedures its fineshes up and continues to the next. I don't know how to EXIT IT I tried using the EXIT keyword but it won't work.... I hope this isn't too much of an issue....

Um... Already Fixed Procedure Error... Just need help with the floating points.

clive

The subroutines need RET's but you've probably figured that.

This is not a homework forum, post the code, the input and the output here. ZIP it up with the EXE so we don't have to dig up Kip's stuff.
It could be a random act of randomness. Those happen a lot as well.

rubsnick

Sorry I don't know how to save them to EXE's and stuff and I assume the code would be more then enough.... ya know?  On to of that it's not a simple code it has multiple codes so yeah.... Dunno what good would posting an EXE be.

dedndave

what Clive is telling you is, most of us do not have Kip's libraries
we would have to read the docs for all the functions used, just to understand the example code

as for posting...
below the reply window is a link for Additional Options
ZIP files of less than 160 Kb may be attached to the post

rubsnick

Quote from: dedndave on November 10, 2010, 07:34:28 PM
what Clive is telling you is, most of us do not have Kip's libraries
we would have to read the docs for all the functions used, just to understand the example code

as for posting...
below the reply window is a link for Additional Options
ZIP files of less than 160 Kb may be attached to the post
Yeah.... Sorry I"m just a bit stressed out. So yeah anyway Guides to doing the exe thing?

dedndave

well - you have to assemble it using MASM and Kip's LIB's
but - you can ZIP the source code   :bg

i can't tell you to ZIP the LIB's, as it is copyrighted material
but, any attachment must have a .ZIP filename

clive

You run (or what ever your command line is for MASM)
ML -Fl -coff FOO.ASM

it generates
FOO.LST and FOO.EXE

I'd like to be able to spend 2-3 mins running/testing/reviewing the application, not 20-30 mins recreating your build environment. I have a couple of Kip's books on the shelf, but this is a forum primarily supporting the MASM32 package/libraries which most of us have installed already.

If you can't do that, present the input to and output from the application.

This isn't going to work


pi real4 3.14
..
mov ebx,pi


You need to be using the floating point unit, not integer CPU registers. You could multiply by 22 and later by 7 for an approximation.
It could be a random act of randomness. Those happen a lot as well.

brethren

you've just about finished kips book, you're writing fpu code...........and you can't assemble an executable? :dazzled:

dedndave

i don't want to say anything bad about Kip
his books are easy to understand and great for beginners
however, using his libraries leaves you a little short
because, you fail to learn the "hard" way to do stuff
it does get you up and running, but you need to go back and learn the API's that his LIB's use and "wrap" for you

MichaelW

rubsnick,

In RectangleP there is a problem with your multiply. The MUL instruction does an unsigned multiply of a source operand by an implied destination operand. For a 32-bit source operand the implied destination operand is EAX. So to multiply EAX by EBX, you would load both of the registers and then do a MUL EBX. The 64-bit product would be stored in the EDX:EAX register pair, with the most significant DWORD in EDX and the least significant DWORD in EAX. For a product that will fit into 32 bits, you can ignore the value in EDX.

TriangleP appears to work OK, assuming that a truncated integer result is acceptable. I would change the 16-bit operands to 32-bit operands, and do the divide by 2 by simply shifting the result (EAX) right by one bit.

CircleP has the same problem as in TriangleP on one of the MUL instructions, and the problems that Clive pointed out.

What sort of environment are you working in and what were your instructions for assembling and linking?

If you are supposed to use floating-point calculations for this, how are you supposed to display the results?

eschew obfuscation

brethren

Quote from: dedndave on November 11, 2010, 12:44:11 AM
i don't want to say anything bad about Kip
his books are easy to understand and great for beginners
however, using his libraries leaves you a little short
because, you fail to learn the "hard" way to do stuff
it does get you up and running, but you need to go back and learn the API's that his LIB's use and "wrap" for you

i have to disagree with you on this, dave. by the time you've finished kips book you'll understand all the code in his library and would have no problem writing your own api's