Assignment#1: DUE DATE: Friday, February 17, 2006, by NOON, in my office. Warning: 1) For this assignment you must use only the instructions, macros, and directives that are described in lectures 1, 2, 3 and 4. Hence please make sure that you have understood these chapters before doing your assignment. 2) Make sure your program is well commented. 3) As you will see in lectures 6 and 7, your program may crash if you modify the content of register ESP. You may also get in trouble if you use register EBP. Hence, do not use these registers (ESP, and EBP) for this assignment. ============================================================================== Programming Exercise 1 (30 points): Write an ASM program that will count the total number of characters and the number of lowercase characters ( ASCII codes 61h to 7Ah inclusive) contained in a text file. In calculating total number of characters we do not count the carriage return character (ASCII code 0Dh). Use "<" to redirect the standard input from a text file on the Win32 command line. For example, suppose that the text file my_file.txt contains the following 3 lines of text: This is A sample input with Numbers 5 and 8. And suppose that your (executable) program is called "ass1-1.exe". Then your program should do the following from the Win32 command line: C:\Programming\asm>ass1-1 < my_file.txt This file contains 45 characters, out of which 29 are lowercase characters C:\Programming\asm> ================================================================================ Programming Exercise 2 (30 points): Write an ASM program that produces a summation table as shown below. Use putfint macro that allows you to provide a C printf style format string. For instance the following program snippet ----------------------------- .data frormatString db "%5d",0 .code mov eax, 6 putfint frormatString, eax ----------------------------- will output 6 In this output there are 4 space character before number 6. Make sure you are using the latest version of Cs266.inc . Here is an example of execution of your program named "ass1-2.exe": C:\Programming\asm>ass1-2 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 10 11 12 13 4 5 6 7 8 9 10 11 12 13 14 5 6 7 8 9 10 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 16 7 8 9 10 11 12 13 14 15 16 17 8 9 10 11 12 13 14 15 16 17 18 9 10 11 12 13 14 15 16 17 18 19 10 11 12 13 14 15 16 17 18 19 20 C:\Programming\asm> NOTE: Clearly your program needs to calculate the entries and then print them. You can write a more general program that takes as input a number indicating the dimensions of the table to be generated. For instance if we pass 3 to this more general program then it will generate a 3x3 table. To simplify the assignment, we have assumed that the size of the table is fixed to 10x10 i.e. as if we always pass 10 as input. However, your program still needs to do the calculations necessary to generate this 10x10 table. Also note that if you have written your program properly an extension to the more general case would be very trivial. You do not have to write a more general version of the program for this particular question, however if you have extra time I strongly encourage you to give it a try. ================================================================================ Programming Exercise 3 (40 points): Write an ASM program that prompts the user to enter a string of at most 128 characters and prints it in reverse order with every upper-case letter converted to the corresponding lower-case letter. Sample execution of "ass1-3.exe": C:\Programming\asm>ass1-3 Enter a string of at most 128 characters: An InpuT Line! Here it is in LOWERCASE and in reverse order: !enil tupni na C:\Programming\asm> HINT: You should copy the user input line into memory (possibly after converting to lower-case) and then print it in reverse order by using indirect addressing. You should avoid manipulating the input buffer since you do not have an explicit access to the character pointers of the input buffer. If the user enters more than 128 characters, only the first 128 characters must be processed (the rest are ignored but make sure that you cannot write outside the memory you have allocated for storing the string).