Subject Computer Science Assembly Language Programming

Question

For this program, you will replace all the occurrences of a certain character in a string with another character.

The terminal interaction will look as follows:

String? abcdef
Character To Replace?
Replacement Character?
String With Replaced Character is: abxdef

In this example Character To Replace was input as 'c' and Replacement Character was input as 'x'.

Another example is:

String? abcdcdcdefg
Character To Replace?
Replacement Character?
String With Replaced Character is: abxdxdxdefg

For this program, you MUST use the following Irvine32 procedures:

ReadString
WriteString
ReadChar
CfLf

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

INCLUDE Irvine32.inc

ExitProcess PROTO, dwExitCode:DWORD

.data

msg1 BYTE "String? ", 0 ; message to ask for string
msg2 BYTE "Character to replace? ", 0 ; message to ask for character to replace
msg3 BYTE "Replacement character? ", 0 ; message to ask for replacement character
msg4 BYTE "String with replaced character is: ", 0 ; message to print the result
string BYTE 41 DUP(?) ; string of 40 characters for input
charToReplace BYTE ? ; character to replace
replacementChar BYTE ? ; replacement character   

.code

main PROC

mov edx, OFFSET msg1 ; move memory address of msg1 to edx for printing
call WriteString ; print string
mov edx, OFFSET string; prepare reading buffer
mov ecx, 41; set the size of input string
call ReadString ; read the string...

This is only a preview of the solution. Please use the purchase button to see the entire solution

$18.00

or $1 if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats