Question: PLEASE READ THE ASSIGNMENT CAREFULLY AND FOLLOW ALL INSTRUCTIONS. Bitwise instructions with keyboard input and ASCII output The purpose of this assignment is to give
PLEASE READ THE ASSIGNMENT CAREFULLY AND FOLLOW ALL INSTRUCTIONS.
Bitwise instructions with keyboard input and ASCII output
The purpose of this assignment is to give you combined practice with bitwise instructions, keyboard input, and console output all working together to form a cohesive small program.
Steps:
Open the Online Assembler
Near the top of the source code file, use comments to place your name into the code for credit No name, no credit!
Make sure every line of code you write has comments to explain what you are doing!
Follow the specifications below to get full credit for the assignment. Any errors or warnings will result in zero points for the code line in question:
SPECIFICATIONS
For this assignment, you are expected to do the following before we get to the text section:
Reserve byte of uninitialized data called "bite" to hold our second value for XOR
Reserve byte of uninitialized data called "result" to hold our computation result in ASCII form
Description of functionality
Your program should assume byte value or being typed in the stdin box before running. Your program should retrieve this number and place it into the "bite" reference above.
Your program needs to convert this input digit into a raw value not an ASCII character XOR the value with and place the result into the "result" piece of uninitialized data mentioned above. Be sure to add back the ASCII code so it can be displayed.
Display the "result" to the console.
Make sure to properly exit the program as always
Expected Output
If you did everything correctly assuming input of your output should be:
You should also have no errors or warnings.
Caveat
IMPORTANT!!!!!!!
USE ONLY NASM instructions: and, or xor, shr shl mov, int, add, sub, mul, div. in the text portion of the program. DONT USE OTHER INSTRUCTIONS.
Be aware that the digit will be in ASCII format coming from the keyboard. Therefore, we need to convert this input character to a number before doing calculations on it bitwise or arithmetic Here is an example:
section bss
bite db ; create a singlebyte to hold input digit
result db ; this will hold result of our computation eventually
section text
global start
start:
mov eax, ; sysread
mov ebx, ; stdin
mov ecx, bite ; input buffer
mov edx, ; read byte
int x ; system call
mov eax, bite ; transfer character to register
sub eax, ; convert from ASCII to raw digit value
mov bite eax ; transfer back into input buffer
add eax, ; convert result to ASCII
mov result eax ; transfer value to result
From here, we can easily output the result to console:
mov eax, ; syswrite
mov ebx, ; stdout
mov ecx, result ; output buffer
mov edx, ; display byte
int x ; system call
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
