"Richard Russell" <news@MUNGED.microcosmotalk.com> wrote in message
news:4b2be0f8$0$5100$9a6e19ea@unlimited.newshosting.com...
>
> In browsing, I found this post from about 20 months ago:
>
> "Here's what you get with HLA v1.102:
> 1) The behavior of the FADD(); FSUB(); FSUBR(); FMUL(); FDIV();
> and FDIVR(); instructions (with no operands) has changed. Previously,
> these instructions, without operands, generated opcodes for faddp,
> fsubp, fsubrp, fmulp, fdivp, and fdivrp, respectively. This behavior
> is inconsistent with Intel documentation (and most other assemblers).
> This has been changed in HLA v1.102 so that these instructions,
> without operands, are equivalent to fadd( st1, st0 ); fsub( st1,
> st0 ); fsubr( st1, st0 ); fmul( st1, st0 ); fdiv( st1, st0 ); and
> fdivr( st1, st0 ); (i.e., no pop after the arithmetic operation)."
>
> As this is completely back-to-front - the no-operand instructions
> listed *should* pop the stack, in other words FADD should encode as
> FADDP ST(1),ST(0) - I expected to find a followup containing a
> correction, but I didn't! The reference to being "inconsistent with
> Intel documentation (and most other assemblers)" is strange, as the
> Intel docs - and every other assembler I've tried - confirm that the
> instructions pop the stack (despite the absence of a P suffix).
>
> What does the current version of HLA actually do?
>
Well, we happen to have a laboratory under our fingertips. Shall we conduct
a scientific experiment to discover the answer?
A typical FPU-using program that contains the 'p' suffix for the
instructions under question:
program GenerateSines;
#include( "stdlib.hhf" );
var
outFile: dword;
angle: int32;
r: int32;
readonly
RoundMode: uns16 := $23f;
begin GenerateSines;
// Open the file:
mov( fileio.openNew( "sines.hla" ), outFile );
// Emit the initial part of the declaration to the output file:
fileio.put
(
outFile,
stdio.tab,
"sines: int32[360] := " nl,
stdio.tab, stdio.tab, stdio.tab, "[" nl );
// Enable rounding control (round to the nearest integer).
fldcw( RoundMode );
// Emit the sines table:
for( mov( 0, angle); angle < 359; inc( angle )) do
// Convert angle in degrees to an angle in radians
// using "radians := angle * 2.0 * pi / 360.0;"
fild( angle );
fld( 2.0 );
fmulp();
fldpi();
fmulp();
fld( 360.0 );
fdivp();
// Okay, compute the sine of ST0
fsin();
// Multiply by 1000 and store the rounded result into
// the integer variable r.
fld( 1000.0 );
fmulp();
fistp( r );
// Write out the integers eight per line to the source file:
// Note: if (angle AND %111) is zero, then angle is evenly
// divisible by eight and we should output a newline first.
test( %111, angle );
if( @z ) then
fileio.put
(
outFile,
nl,
stdio.tab,
stdio.tab,
stdio.tab,
stdio.tab,
r:5,
','
);
else
fileio.put( outFile, r:5, ',' );
endif;
endfor;
// Output sine(359) as a special case (no comma following it).
// Note: this value was computed manually with a calculator.
fileio.put
(
outFile,
" -17",
nl,
stdio.tab,
stdio.tab,
stdio.tab,
"];",
nl
);
fileio.close( outFile );
end GenerateSines;
The output of said program:
sines: int32[360] :=
[
0, 17, 35, 52, 70, 87, 105, 122,
139, 156, 174, 191, 208, 225, 242, 259,
276, 292, 309, 326, 342, 358, 375, 391,
407, 423, 438, 454, 469, 485, 500, 515,
530, 545, 559, 574, 588, 602, 616, 629,
643, 656, 669, 682, 695, 707, 719, 731,
743, 755, 766, 777, 788, 799, 809, 819,
829, 839, 848, 857, 866, 875, 883, 891,
899, 906, 914, 921, 927, 934, 940, 946,
951, 956, 961, 966, 970, 974, 978, 982,
985, 988, 990, 993, 995, 996, 998, 999,
999, 1000, 1000, 1000, 999, 999, 998, 996,
995, 993, 990, 988, 985, 982, 978, 974,
970, 966, 961, 956, 951, 946, 940, 934,
927, 921, 914, 906, 899, 891, 883, 875,
866, 857, 848, 839, 829, 819, 809, 799,
788, 777, 766, 755, 743, 731, 719, 707,
695, 682, 669, 656, 643, 629, 616, 602,
588, 574, 559, 545, 530, 515, 500, 485,
469, 454, 438, 423, 407, 391, 375, 358,
342, 326, 309, 292, 276, 259, 242, 225,
208, 191, 174, 156, 139, 122, 105, 87,
70, 52, 35, 17, 0, -17, -35, -52,
-70, -87, -105, -122, -139, -156, -174, -191,
-208, -225, -242, -259, -276, -292, -309, -326,
-342, -358, -375, -391, -407, -423, -438, -454,
-469, -485, -500, -515, -530, -545, -559, -574,
-588, -602, -616, -629, -643, -656, -669, -682,
-695, -707, -719, -731, -743, -755, -766, -777,
-788, -799, -809, -819, -829, -839, -848, -857,
-866, -875, -883, -891, -899, -906, -914, -921,
-927, -934, -940, -946, -951, -956, -961, -966,
-970, -974, -978, -982, -985, -988, -990, -993,
-995, -996, -998, -999, -999,-1000,-1000,-1000,
-999, -999, -998, -996, -995, -993, -990, -988,
-985, -982, -978, -974, -970, -966, -961, -956,
-951, -946, -940, -934, -927, -921, -914, -906,
-899, -891, -883, -875, -866, -857, -848, -839,
-829, -819, -809, -799, -788, -777, -766, -755,
-743, -731, -719, -707, -695, -682, -669, -656,
-643, -629, -616, -602, -588, -574, -559, -545,
-530, -515, -500, -485, -469, -454, -438, -423,
-407, -391, -375, -358, -342, -326, -309, -292,
-276, -259, -242, -225, -208, -191, -174, -156,
-139, -122, -105, -87, -70, -52, -35, -17
];
Here is a version of the above program with the 'p' suffix removed:
program GenerateSinesSansPee;
#include( "stdlib.hhf" );
var
outFile: dword;
angle: int32;
r: int32;
readonly
RoundMode: uns16 := $23f;
begin GenerateSinesSansPee;
// Open the file:
mov( fileio.openNew( "sinesSansPee.hla" ), outFile );
// Emit the initial part of the declaration to the output file:
fileio.put
(
outFile,
stdio.tab,
"sines: int32[360] := " nl,
stdio.tab, stdio.tab, stdio.tab, "[" nl );
// Enable rounding control (round to the nearest integer).
fldcw( RoundMode );
// Emit the sines table:
for( mov( 0, angle); angle < 359; inc( angle )) do
// Convert angle in degrees to an angle in radians
// using "radians := angle * 2.0 * pi / 360.0;"
fild( angle );
fld( 2.0 );
fmul();
fldpi();
fmul();
fld( 360.0 );
fdiv();
// Okay, compute the sine of ST0
fsin();
// Multiply by 1000 and store the rounded result into
// the integer variable r.
fld( 1000.0 );
fmul();
fist( r );
// Write out the integers eight per line to the source file:
// Note: if (angle AND %111) is zero, then angle is evenly
// divisible by eight and we should output a newline first.
test( %111, angle );
if( @z ) then
fileio.put
(
outFile,
nl,
stdio.tab,
stdio.tab,
stdio.tab,
stdio.tab,
r:5,
','
);
else
fileio.put( outFile, r:5, ',' );
endif;
endfor;
// Output sine(359) as a special case (no comma following it).
// Note: this value was computed manually with a calculator.
fileio.put
(
outFile,
" -17",
nl,
stdio.tab,
stdio.tab,
stdio.tab,
"];",
nl
);
fileio.close( outFile );
end GenerateSinesSansPee;
Here is the output of this second version of the program:
sines: int32[360] :=
[
1000,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,
-17
];
Does this answer your question?
Nathan.
|