logo Use CA10RAM to get 10%* Discount.
Order Nowlogo

Create an HLA function that loops through a single string argument and counts all the non-lower case letters.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Create an HLA function that loops through a single string argument and counts all the non-lower case letters. This function should have the following signature: procedure countNonLowerCase( string data : dword ); @nodisplay; @noframe;

This function should return into EAX an int32 value which is the number of non-lowercase letters (that is, counts everything EXCEPT a-z) found in the stringData parameter. To receive full credit, your countNonLowerCase( ) procedure must not allocate any storage. You must use the utility functions gets and puts provided here (Links to an external site.) by downloading this file. 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( "cs17Final.hla" );

Your function should replicate the following C code: int countNonLowerCase( char * stringData ) { int i = 0; int count = 0; while ( stringData[ i ] != NULL ) { int letter = stringData[ i ]; // lowercase letters are ASCII(97) thru ASCII(122) if (letter > 122 || letter < 97) { count = count + 1; } i = i + 1; } return( count ); } 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 prepare and 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. // I hope it will help simplify your development task. // Please look at the two TODO: notes below program StringProgram; #include( "stdlib.hhf" ); // The file cs17Final.hla is downloadable from the hyperlink shown above. // Place it in the same folder as this hla file you are working on #include( "cs17Final.hla" ); static stringData : dword; // TODO: CS 17 Students add code below to implement this function // Several hints are supplied procedure countNonLowerCase( stringData : dword ); @nodisplay; @noframe; static dReturnAddress : dword; begin countNonLowerCase; // TODO: CS 17 Students will need to preserve registers pop( dReturnAddress ); // this is the return address // push back the return address push( dReturnAddress ); // preserve registers // begin sub-task // leave the count in EAX // restore the registers used ret(); end countNonLowerCase; 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: send a string parameter to the function call countNonLowerCase; // show the results stdout.put( "result=" ); stdout.put( EAX ); stdout.newln(); end StringProgram; this is the code // File: cs17Final.hla // Provides the string manipulation functions puts and gets for students to use // this procedure prompts for a string, writing atmost maxLength bytes into a previously declared array

// this maxLength should not include the terminating null in its count // the string parameter is being passed by its base address procedure gets( baseStringAddress: dword; maxLength : uns16 ); @nodisplay; @noframe; // uses the register DX, DI, ECX, EBX and EAX static dReturnAddress : dword; wDIRegister : word := 0; // preserve DI wDXRegister : word := 0; // preserve DX dEAXRegister : dword := 0; // preserve EAX dEBXRegister : dword := 0; // preserve EBX dECXRegister : dword := 0; // preserve ECX // I am trying to hide the datatype string for use by CS 17 sData : string; begin gets; // entry sequence // preserve registers mov( ECX, dECXRegister ); mov( EBX, dEBXRegister ); mov( EAX, dEAXRegister ); mov( DX, wDXRegister ); mov( DI, wDIRegister ); pop( dReturnAddress ); // This is the return address pop( DI ); // This is the max length able to read pop( EBX ); // This is the base address of the string // push back the return address push( dReturnAddress ); // preserve registers push( wDIRegister ); push( wDXRegister ); push( dECXRegister ); push( dEBXRegister ); push( dEAXRegister ); // begin sub-task // prompt for a string stdin.flushInput(); stdin.a_gets(); // allocate and read string into EAX mov( EAX, sData ); // save address so it can be free'd later

 // copy data in sData over into starting at [EBX] mov( 0, DX ); // EBX will be the address of string[i] mov( 0, ECX ); getsRepeatLoop: // read no more than DI chars cmp( DI, 0 ); je getsEndLoop; cmp( [ EAX + ECX ], DH ); je getsEndLoop; mov( [ EAX + ECX ], DL ); // move character desired mov( DL, (type char [ EBX ]) ); inc( ECX ); inc( EBX ); dec( DI ); jmp getsRepeatLoop; getsEndLoop: // set ending null mov( DH, (type char [ EBX ]) ); // release sData strfree( sData ); // exit sequence // restore registers pop( EAX ); pop( EBX ); pop( ECX ); pop( DX ); pop( DI ); // transfer control ret( ); end gets; // this procedure prints the contents of a null-terminated string // the string parameter is being passed by its base address procedure puts( baseStringAddress: dword ); @nodisplay; @noframe;

 // uses the register EBX static dReturnAddress : dword; wDXRegister : word := 0; // preserve DX dEBXRegister : dword := 0; // preserve EBX begin puts; // entry sequence // preserve registers mov( EBX, dEBXRegister ); mov( DX, wDXRegister ); pop( dReturnAddress ); // This is the return address pop( EBX ); // This is the base address of the string // push back the return address push( dReturnAddress ); // preserve registers push( dEBXRegister ); push( wDXRegister ); // begin sub-task // print null-terminated string mov( 0, DX ); // EBX will be the address of string[i] putsRepeatLoop: cmp( [ EBX ], DH ); je putsEndLoop; stdout.putc( [ EBX ] ); inc( EBX ); jmp putsRepeatLoop; putsEndLoop: // exit sequence // restore registers pop( DX ); pop( EBX ); // transfer control ret( ); end puts;

 

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

623 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

704 Answers

Hire Me
expert
Husnain SaeedComputer science

731 Answers

Hire Me
expert
Atharva PatilComputer science

664 Answers

Hire Me
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30