I’m not sure why I get a memory access violation whenever I input a number.
Enter FTES: 9000.7
size returned in AL is: S
I’ve tried using fild but it won’t allow the program to execute and it leads to this error
Operand must be a 16, 32, or 64-bit value.
Near: << ftes >>
program Compare;
#include( "stdlib.hhf" );
static
ftes: real32;
SizeS : real32 := 10000.0;
SizeM : real32 := 15000.0;
SizeL : real32 := 20000.0;
procedure ccsize( ftes : real32 ); @nodisplay; @noframe;
begin ccsize;
fld( ftes ); // load ftes into FPU stack
fld( SizeL ); // load SizeL constant into FPU stack
fcomp(); // compare ftes with SizeL, pop both
fstsw( ax ); // store FPU status word in AX
sahf; // load AX into FLAGS
jae L1; // jump to L1 if ftes >= SizeL
fld( ftes ); // load ftes into FPU stack
fld( SizeM ); // load SizeM constant into FPU stack
fcomp(); // compare ftes with SizeM, pop both
fstsw( ax ); // store FPU status word in AX
sahf; // load AX into FLAGS
jae L2; // jump to L2 if ftes >= SizeM
fld( ftes ); // load ftes into FPU stack
fld( SizeS ); // load SizeS constant into FPU stack
fcomp(); // compare ftes with SizeS, pop both
fstsw( ax ); // store FPU status word in AX
sahf; // load AX into FLAGS
jae L3; // jump to L3 if ftes >= SizeS
mov( 'S', al ); // load 'S' into AL
jmp Done; // jump to Done
L1:
mov( 'X', al ); // load 'X' into AL
jmp Done; // jump to Done
L2:
mov( 'L', al ); // load 'L' into AL
jmp Done; // jump to Done
L3:
mov( 'M', al ); // load 'M' into AL
Done:
end ccsize;
begin Compare;
stdout.put( "Enter FTES: ");
stdin.get( ftes );
ccsize(ftes);
stdout.put( "size returned in AL is: ", al, nl );
end Compare;
New contributor
Hooray is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.