Programming Exercise
Write an ASM program that will count the total number of characters, the number of lowercase characters, the numbers of decimal digits, and the number of blank characters contained in a text. You can implement anyone of the following alternatives.

Alternative 1:
You can read the input text from the keyboard. For example, if you read the following three-line text from the keyboard
This is :
A Sample Input,
With Numbers 5 and 8.
Then your program Ass_1-a.exe should display the following 2 lines:
This file contains 45 characters: out of which,
26 are lowercase characters; 2 are decimal numbers; and, 8 are blank characters.
The trick, in this alternative is how to read the three lines, one after another, until the ‘period’ (the ‘period’ is part of the text.

Alternative 2:
You can read the input text above from a text file, say, “my_file.txt” (if you want). In this case, use "<" to redirect the standard input from a text file on the Win32 command line.
For example, suppose that your (executable) program is called “Ass_1-a.exe". Then you
should do the following from the Win32 command line:
C:\Programming\asm> Ass_1-a < my_file.txt
and then your program should display the following 2 lines:
This file contains 45 characters: out of which, 26 are lowercase characters; 2 are decimal digits; and, 8 are blank characters. In calculating the total number of characters you should not count the "end-of-line" characters (ASCII codes 0Dh,0Ah).

Programming Exercise 2
Write an ASM program that reads an integer number N and then displays the first N values of the Fibonacci number sequence, described by: Fib(0) = 0, Fib(1) = 1, Fib(N) = Fib(N-2) + Fib(N-1)
Thus, if the input is N = 10, your program Ass_1-b.exe should display the following single line:
Fibonacci sequence with N = 10 is: 0 1 1 2 3 5 8 13 21 34 55

Programming Exercise 3
Write an ASM program that prompts the user to enter a string of at most 128 characters and then displays the string in reverse order, with each upper-case letter converted to its corresponding lower-case letter. For instance, a sample execution of “Ass1-3.exe" with the input string “An InpuT Line!” is shown below

Enter a string of at most 128 characters: An InpuT Line!

Here it is in LOWERCASE and in reverse order:
!enil tupni na

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 (or indexed addressing, if you wish). 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). Also, try to make use of operators SIZEOF, TYPE, LENGTHOF, or PTR, in order to make your program as flexible as possible (and as short —efficient— as possible);

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.



inpmsg BYTE "Enter the number N: ",0
outmsg1 BYTE "Fibonacci sequence with N = ",0
outmsg2 BYTE " is: ",0
main PROC

;print out the instructions
mov edx, OFFSET inpmsg
call WriteString
call Crlf

;read the number and store it in N
call ReadDec
mov N,eax

;print out the output message until the sequence start
mov edx, OFFSET outmsg1
call WriteString
mov eax, N
call WriteDec
mov edx, OFFSET outmsg2
call WriteString

mov eax, 0
call WriteDec ;sequence always starts with 0
mov al, 20h
call WriteChar ;write space

mov eax, N
cmp eax, 0 ;if N is 0, finish the program

mov ecx, N
mov eax, 0 ;f2
mov ebx, 1 ;f1
mov edx, eax
add edx, ebx ;fnew = f1 + f2
mov eax, ebx ;f2 = f1
mov ebx, edx ;f1 = fnew...

By purchasing this solution you'll be able to access the following files:

50% discount

$15.00 $7.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats