Question: PLEASE READ THE ASSIGNMENT CAREFULLY AND FOLLOW ALL STEPS. Keyboard input and string concatenation The purpose of this assignment is to give you practice processing

PLEASE READ THE ASSIGNMENT CAREFULLY AND FOLLOW ALL STEPS.
Keyboard input and string concatenation
The purpose of this assignment is to give you practice processing keyboard input and then mixing initialized and uninitialized data together using string concatenation techniques. In this assignment, you will utilize both styles of string concatenation (dual sys_write calls and storing two strings in one piece of uninitialized data).
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 4-bytes of uninitialized data called "inp_buf" to hold our class number
Reserve 16-bytes of uninitialized data called "con" to hold our concatenated course name
Define a string of initialized data called "course" that holds 'CISP'
Define a string of initialized data called "hello" that holds 'My favorite class is '
Create pieces of initialized and uninitialized data as needed to hold the lengths of these strings
IMPORTANT
Use only instructions as: mov, int, add, sub, mul, div, etc. in the .text portion of the program.
Description of functionality
Your program should assume up to a 4-byte course number (for example, if the course is CISP310 then the course number would be 310) being typed in the stdin box before running. Your program should retrieve this number and place it into the "inp_buf" reference above.
You should transfer over the string in "course" to the "con" buffer. Afterward, you should transfer over the data in "inp_buf" to the "con" buffer at the end of the first data placed there. For example, if the user entered 310 as the input, your con buffer should contain 'CISP310' since that is the concatenation of the 'CISP' string with the input '310'.
You should do your first sys_write call (recall how to display text to the console) and write the "hello" string. You should also do a second sys_write call that writes the "con" buffer.
Make sure to properly exit the program (as always).
Expected Output
If you did everything correctly (assuming input of 310), your output should be:
My favorite class is CISP310
You should also have no errors or warnings.
THIS IS AN EXAMPLE HOW TO ORGANIZE THE CODE:
section .bss
count resd 1 ; holds number of bytes read
inp_buf: resb 16 ; our input buffer
inp_len equ $-inp_buf ; max 16 bytes
section .text
global _start
_start:
mov eax, 3 ; sys_read code
mov ebx, 0 ; stdin (keyboard)
mov ecx, inp_buf ; Our input buffer
mov edx, inp_len ; Max length
int 0x80 ; System call
mov [count], eax ; Save number of bytes read to count
mov eax, 4 ; sys_write code
mov ebx, 1 ; stdout (console)
mov ecx, inp_buf ; display input buffer
mov edx, [count] ; number of characters read from stdin
int 0x80 ; System call
mov eax, 1 ; sys_exit code
mov ebx, 0 ; exit is normal
int 0x80 ; System call

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!