Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an HLA function that loops through a single string argument and verifies that last character found in the string is a capital A .

Create an HLA function that loops through a single string argument and verifies that last character found in the string is a capital A. This function should have the following signature:
procedure endsWithA( stringData : dword ); @nodisplay; @noframe;
This function should return into EAX an int32 value which is either true or false, 1 or 0. To receive full credit, your endsWithA() function must not allocate any storage.
You must use the utility functions gets and puts provided here Download hereby downloading this file. Unzip it to find the .hla file inside. These are the some of the same routines you used in Unit 15. Once you acquire the file, you can include it in your code by saying: #include("cs17string.hla" );
Your function should replicate the following C code:
bool endsWithA( char * stringData )
{
int i =0;
char letter =;
while ( stringData[ i ]!= NULL )
{
// loop the last character
letter = stringData[ i ];
i = i +1;
}
return( letter ==A);
}
IN ORDER TO RECEIVE FULL CREDIT, YOU MUST USE THE TEMPLATE SOLUTION SHOWN BELOW. Of course, you will need to add code to the function to implement the desired algorithm explained above. In addition, you will need to push the parameters to the function.
// String Parameter Template Solution For CS 17 Final
// CS 17 Students must use this template as the basis for their solution.
// Please look at the two TODO: notes below
program StringProgram;
#include( "stdlib.hhf");
// The file cs17string.hla is downloadable from the hyperlink shown above.
// Place it in the same folder as this hla file you are working on
#include("cs17string.hla" );
static
stringData : dword;
answer : int32;
// TODO: CS 17 Students add code below to implement this function
// Several hints are supplied
procedure endsWithA( stringData : dword ); @nodisplay; @noframe;
static
dReturnAddress : dword;
begin endsWithA;
// TODO: CS 17 Students will need to preserve registers
pop( dReturnAddress );
// TODO: CS 17 Students need to get stringData off the stack
// push back the return address
push( dReturnAddress );
// preserve registers
// begin function implementation
// leave the answer in EAX
// restore the registers used
ret();
end endsWithA;
begin StringProgram;
stdout.put( "Please enter a string to process", nl );
// this code allocates a string of size 80
mov( @size( int8), AL );
mov(80, BL );
inc( BL );
mul( BL );
mov(0, EBX );
mov( AX, BX );
malloc( EBX );
mov( EAX, stringData );
// let's try reading a value into the string
mov( stringData, EAX );
push( EAX );
mov(80, CX );
push( CX );
call gets;
// print the string
stdout.put("----> here is the string you entered: ");
mov( stringData, EAX );
push( EAX );
call puts;
stdout.newln();
// initialize EAX before calling the function.
mov(0, EAX );
// TODO: CS 17 Students need to pass a string parameter to the function
call endsWithA;
mov( EAX, answer );
// show the results
stdout.put( "after endsWithA --- result=");
stdout.put( answer );
stdout.newln();
end StringProgram;
Create an HLA function that determines if a passed character parameter is a period or exclamation letter. This function should have the following signature:
procedure isPeriodOrExcl( c : byte ); @nodisplay; @noframe;
This function should return into EAX an int32 value which is either true or false, 1 or 0. To receive full credit, your isLower() function must not allocate any storage.
Your function should replicate the following C code:
bool isPeriodOrExcl( char c )
{
bool result = false;
if( c =='.' && c =='!')
{
result = true;
}
return( result );
}
IN ORDER TO RECEIVE FULL CREDIT, YOU MUST USE THE TEMPLATE SOLUTION SHOWN BELOW. Of course, you will need to add code to the function to implement the desired algorithm explained above. In addition, you will need to push the parameters to the function.
// Character Parameter Template Solution For CS 17 Final
// CS 17 Students must use this template as the basis for their solution.
// Please look at the two TODO: notes below
program CharProgram;
#include( "stdlib.hhf");
static
cMyCharacter : byte :=0;
answer : int32;
// TODO: CS 17 Students add code below to implement this function
// Several hints are supplied
procedure isPeriodOrExcl( c: byte ); @nodisplay; @noframe;
static
dReturnAddress : dword;
begin isPeriodOrExcl;
// TODO: CS 17 Students will need to preserve registers
pop( dReturnAddress );
// TODO: CS 17 Students need to get c off the stack
// push back the return address
push( dReturnAddress );
// preserve registers
// begin function implementation
// leave the answer in EAX
// restore the registers used
ret();
end isPeriodOrExcl;
begin CharProgram;
stdout.put( "Please enter a character process", nl );
stdin.flushInput();
stdin.getc(); // stores resu

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

Design a cross-cultural preparation program. page 313

Answered: 1 week ago

Question

Evaluate employees readiness for training. page 289

Answered: 1 week ago