I don’t understand why my program outputs this error
<code>syntax error, unexpected ')', expecting '('.
<code>syntax error, unexpected ')', expecting '('.
Near: << ) >>
</code>
syntax error, unexpected ')', expecting '('.
Near: << ) >>
This is what I’m supposed to do
write an HLA Assembly language program that implements a function which correctly adjusts each parameter value to hold the largest value passed to the function. This function should have the following signature:
procedure biggest( var x : int16; var y : int16; var z : int16 ); @nodisplay; @noframe;
After invoking the function, the caller’s version of the variables x, y and z should all set to the same value which is the biggest value supplied to the function. Your function must use reference parameters, changing the callers version of the variables passed to the function.
This is my code any help is greatly appreciated.
<code>program biggestval;
procedure biggest( var x : int16; var y : int16; var z : int16 ); @nodisplay; @noframe;
dEDXRegister : dword := 0; // preserve EDX
dECXRegister : dword := 0; // preserve ECX
dEBXRegister : dword := 0; // preserve EBX
mov( EBX, dEBXRegister );
mov( ECX, dECXRegister );
mov( EDX, dEDXRegister );
pop( dReturnAddress ); // This is the return address
pop( EBX ); // This is the address of x
pop( ECX ); // This is the address of y
pop( EDX ); // This is the address of z
mov( [EBX], MaxVal ); // Assuming x is the max value
cmp( [ECX], MaxVal ); // Comparing y with x
jle CompareZ; // Jump if y is less than x
mov( [ECX], MaxVal ); // Move y to max value if greater than x
cmp( [EDX], MaxVal ); // Comparing z with x
jle SetValues; // Jump if z is less than x
mov( [ECX], MaxVal ); // Mov z to max value if greater than x
stdout.put( "Enter X: " );
stdout.put( "Enter Y: " );
stdout.put( "Enter Z: " );
stdout.put("After biggest, X = ", x, ", Y = ", y, ", Z = ", z);
<code>program biggestval;
#include("stdlib.hhf");
static
x : int16:= 0;
y : int16:= 0;
z : int16:= 0;
procedure biggest( var x : int16; var y : int16; var z : int16 ); @nodisplay; @noframe;
static
dReturnAddress : dword;
MaxVal : int16;
dEDXRegister : dword := 0; // preserve EDX
dECXRegister : dword := 0; // preserve ECX
dEBXRegister : dword := 0; // preserve EBX
begin biggest;
mov( EBX, dEBXRegister );
mov( ECX, dECXRegister );
mov( EDX, dEDXRegister );
pop( dReturnAddress ); // This is the return address
pop( EBX ); // This is the address of x
pop( ECX ); // This is the address of y
pop( EDX ); // This is the address of z
push( dReturnAddress );
// preserve registers
push( dEDXRegister );
push( dECXRegister );
push( dEBXRegister );
mov( [EBX], MaxVal ); // Assuming x is the max value
cmp( [ECX], MaxVal ); // Comparing y with x
jle CompareZ; // Jump if y is less than x
mov( [ECX], MaxVal ); // Move y to max value if greater than x
CompareZ;
cmp( [EDX], MaxVal ); // Comparing z with x
jle SetValues; // Jump if z is less than x
mov( [ECX], MaxVal ); // Mov z to max value if greater than x
SetValues:
mov( MaxVal, [EBX] );
mov( MaxVal, [ECX] );
mov( MaxVal, [EDX] );
// Restoring registers
pop( EBX );
pop( ECX );
pop( EDX );
ret();
end biggest;
begin biggestval;
stdout.put( "Enter X: " );
stdin.get( x );
stdout.put( "Enter Y: " );
stdin.get( y );
stdout.put( "Enter Z: " );
stdin.get( z );
// Getting addresses
lea( EAX, x);
push( EAX );
lea( EAX, y);
push( EAX );
lea( EAX, z);
push( EAX );
call biggest;
stdout.put("After biggest, X = ", x, ", Y = ", y, ", Z = ", z);
end biggestval;
</code>
program biggestval;
#include("stdlib.hhf");
static
x : int16:= 0;
y : int16:= 0;
z : int16:= 0;
procedure biggest( var x : int16; var y : int16; var z : int16 ); @nodisplay; @noframe;
static
dReturnAddress : dword;
MaxVal : int16;
dEDXRegister : dword := 0; // preserve EDX
dECXRegister : dword := 0; // preserve ECX
dEBXRegister : dword := 0; // preserve EBX
begin biggest;
mov( EBX, dEBXRegister );
mov( ECX, dECXRegister );
mov( EDX, dEDXRegister );
pop( dReturnAddress ); // This is the return address
pop( EBX ); // This is the address of x
pop( ECX ); // This is the address of y
pop( EDX ); // This is the address of z
push( dReturnAddress );
// preserve registers
push( dEDXRegister );
push( dECXRegister );
push( dEBXRegister );
mov( [EBX], MaxVal ); // Assuming x is the max value
cmp( [ECX], MaxVal ); // Comparing y with x
jle CompareZ; // Jump if y is less than x
mov( [ECX], MaxVal ); // Move y to max value if greater than x
CompareZ;
cmp( [EDX], MaxVal ); // Comparing z with x
jle SetValues; // Jump if z is less than x
mov( [ECX], MaxVal ); // Mov z to max value if greater than x
SetValues:
mov( MaxVal, [EBX] );
mov( MaxVal, [ECX] );
mov( MaxVal, [EDX] );
// Restoring registers
pop( EBX );
pop( ECX );
pop( EDX );
ret();
end biggest;
begin biggestval;
stdout.put( "Enter X: " );
stdin.get( x );
stdout.put( "Enter Y: " );
stdin.get( y );
stdout.put( "Enter Z: " );
stdin.get( z );
// Getting addresses
lea( EAX, x);
push( EAX );
lea( EAX, y);
push( EAX );
lea( EAX, z);
push( EAX );
call biggest;
stdout.put("After biggest, X = ", x, ", Y = ", y, ", Z = ", z);
end biggestval;