Question: Project: Alice s Reversal Through the Looking Buffer Scenario: Alice finds herself once again in Wonderland, tasked by the mysterious Caterpillar with a peculiar request:
Project: "Alices Reversal Through the Looking Buffer"
Scenario: Alice finds herself once again in Wonderland, tasked by the mysterious Caterpillar with a peculiar
request: to reverse a string using two enchanted buffers, Tweedledum and Tweedledee. However, the reversal
must be done with finesseno condiConal jumps, only a single loop, and indirect addressing! With the help of
magical scrolls BYTE arrays and some assembly wizardry, Alice is ready for the challenge.
The Task:
You, as Alices assistant, will write a MASM program that:
Reads a string from the Caterpillar user input into the Tweedledee buffer using the ReadString
procedure.
Reverses the string from Tweedledee into the Tweedledum buffer using indirect addressing in a single
loop, without using condiConal or uncondiConal jumps.
Displays both the original and reversed strings to the Caterpillar using the WriteString procedure.
Rules of Wonderland InstrucHons:
You MUST use OFFSET to manage the buffers memory addressesno LEA instrucCons allowed!
You MUST use the LOOP instrucCon, and no condiConal or uncondiConal jumps CMP JMP etc. are
permiWed.
The code MUST be formaWed correctly so even the Mad HaWer can read it clearly before the
Jabberwocky arrives.
File Naming: Name the source code file in the format eofprojUSERNAME.asm replace
USERNAME with your username
CollaboraHon: You may assist each other, but no plagiarismeach soluCon must be your own!
Detailed DirecHons:
Buffer Setup:
o Define two byte arrays of size : Tweedledee which will hold the input string and
Tweedledum which will hold the reversed string
o Ensure Tweedledum is empty at the start.
Procedures to Use:
o ReadString: Read the string from the user into Tweedledee. The user can input up to
characters the th byte is reserved for the null terminator
o WriteString: Display the contents of both Tweedledee original and Tweedledum reversed
Using Indirect Addressing with ESI and EDI:
o Set up ESI to point to the last character of the string in Tweedledee.
o Set up EDI to point to the first posiCon of Tweedledum.
o In each iteraCon of the LOOP:
Move the character from ESITweedledee to the AL register.
Move the character from AL into EDITweedledum
Decrement ESI move backward through Tweedledee
Increment EDI move forward through Tweedledum
Using the LOOP InstrucHon:
o Use a counter to control the number of iteraCons based on the length of the input string.
o The LOOP instrucCon will automaCcally decrement the counter and conCnue the loop unCl it
reaches zero.
NullTerminate the Reversed String:
o Aber the loop, place a null terminator at the end of Tweedledum.
Display the Results:
o Use WriteString to print both the original string from Tweedledee and the reversed string
from Tweedledum
Reminders:
OFFSET, not LEA: Use the OFFSET direcCve to handle the memory addresses of Tweedledee and
Tweedledum.
LOOP: The loop must be controlled solely by the LOOP instrucConno condiConal or uncondiConal
jumps.
File Naming: The source code file must be named in the format eofprojUSERNAME.asm replace
USERNAME with your username
CollaboraHon: Help each other, but make sure the work is your ownplagiarism is not permiWed!
Final Call:
The Caterpillar awaits your help, Alice! By using indirect addressing and a single LOOP, reverse the string and
display it before the Jabberwocky arrives!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
