Discussion:
JWASM: Problems with EQU and floating point calculations
(too old to reply)
Binarus
2014-02-27 19:27:30 UTC
Permalink
Hi all,

I am currently porting some C code to assembly (using JWasm) for performance optimization. The C code makes excessive use of (preprocessor) code like that:

Header file:
#define A 1.0
#define B 2.0
#define C (B-A)

C file:
Test = sin(2.0 + C)

The OpenWatcom C compiler (target DOS) puts these constants just into the text segment (they are in the code segment at runtime).

When trying to port that code to assembly, I have done the following:

Assembly file:
A EQU 1.0
B EQU 2.0
C QWORD (B-A)

But this did not work. It seems that JWasm just inserts all zeros at the place in memory where the constant C (i.e. the binary representation of 1.0) should be.

Probably I didn't understand properly how to use EQU (it seems that some assemblers can do calculations with symbols which have been created using EQU, while others treat the right part always as string, i.e. the symbol A would represent the string "1.0" in the above example).

On the other hand, I didn't get any warning or error message when assembling the code. So how exactly can I do simple calculations (double precision) with symbols?

I hope that my problem description was not too worrying.

Thank you very much for any help,

Binarus
Binarus
2014-02-28 10:01:24 UTC
Permalink
Post by Binarus
A EQU 1.0
B EQU 2.0
C QWORD (B-A)
But this did not work. It seems that JWasm just inserts all zeros at the place in memory where the constant C (i.e. the binary representation of 1.0) should be.
To answer one part of my own question: Obviously, if I include the value in brackets, JWasm considers them being floating point numbers.

DQ 1.0 ;Works - 1.0 in binary format (8 bytes) is placed at the respective location

EQU A 1.0
DQ A ;Does not work; the respective memory location is all zeroes

EQU A <1.0>
DQ A ;Works - 1.0 in binary format is placed at the respective location

But I still haven't found out how to do simple calculations:

EQU A <1.0>
EQU B <2.0>
DQ B - A

The last line produces the error message "A2270: real or BCD number not allowed". I can't make any sense out of it because real numbers *are* allowed after DQ (otherwise, "DQ 1.0" would lead to an error message as well, but it works and behaves like expected).

I also have found out that such a simple thing as

DQ 2.0 - 1.0

leads to the same error message.

I also have tried

DQ <2.0> - <1.0> and
DQ <2.0 - 1.0>,

but these only lead to another error message ("A2151: Unexpected literal found in expression ...").

Seems like I can't do even the simplest calculations with constants. Is anybody out there who can confirm?

Thank you very much,

Binarus
Uwe Schmelich
2014-02-28 22:08:25 UTC
Permalink
I'm not really sure about this but could it be that compile time expressions
are only supported with integers and not with reals? At least Masm 10 gives
similiar errors and the Nasm docs state that there it isn't supported
either.

Uwe
[snip]
Seems like I can't do even the simplest calculations with constants. Is
anybody out there who can confirm?
Thank you very much,
Binarus
Binarus
2014-03-09 08:10:04 UTC
Permalink
Post by Uwe Schmelich
I'm not really sure about this but could it be that compile time expressions
are only supported with integers and not with reals? At least Masm 10 gives
similiar errors and the Nasm docs state that there it isn't supported
either.
Uwe,

thank you very much for helping.

In the meantime, I have calculated all expressions by hand and have inserted the numbers directly.

This has been a lot of work (several hundred expressions, but all derived from only a few constants). I also have done some further investigations, but there really seems to be no other way.

Regards,

Binarus

Loading...