Question

In: Computer Science

MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write...

MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO

You will write a simple assembly language program that performs a few arithmetic operations. This will require you to establish your programming environment and create the capability to assemble and execute the assembly programs that are part of this course.

Your \student ID number is a 7-digit number. Begin by splitting your student ID into two different values. Assign the three most significant digits to a variable called 'left' and the four least significant digits to a variable called 'right'.

You must choose the data type that is appropriate for the range of decimal values each variable can store. You will choose a data type when you define each of the variables in your program. Try to make efficient use of memory.

Calculate the sum of the two variables 'left' and 'right'. Store this result in a variable called 'total'.

Calculate the positive difference between the variables 'left' and 'right'. Store this result in a variable called 'diff'.

Define a character string called 'message' that contains the characters, "Hello world!".

Define an array of data type WORD called 'Array' that is initialized to the following values: 1, 2, 4, 8, 16, 32, and 64.

Write assembly language code using what you know so far (do not look ahead in the book just yet) to determine the length of 'Array'. Store this value in a variable called 'ArrayLength'.

Move the contents of the variable 'left' into the EAX register.

Move the contents of the variable 'right' into the EBX register.

Move the contents of the variable 'total' into the ECX register.

Move the contents of the variable 'diff' into the EDX register.

Move the contents of the variable 'ArrayLength' into the ESI register.

Call the author's DumpReg routine to display the contents of the registers.

Solutions

Expert Solution

MOV ID,#1234567h #input from user

MOV B,#10000h

MOV C,ID MOD B

DIV ID,B

MOV LEFT,ID #Moves 3 most significant bits into left

MOV RIGHT,C # Moves 4 least significant bits into right

MOV EAX,LEFT #moves left value into EAX register

MOV EBX,RIGHT #moves right value into EBX register

ADD LEFT,RIGHT #adds left and right bits

MOV SUM,LEFT #moves addtion value into SUM variable

MOV ECX,SUM #moves SUM variable into ECX register

SUBB RIGHT,LEFT #finds difference between left and right

MOV DIFF,RIGHT #shifts diffenece into DIFF variable

MOV EDX,DIFF #moves DIFF variable into EDX register

MESSAGE DB 10, 13, ‘HELLO WORLD $’ # declaring string

A WORD 1, 2, 4,8,16,32,64 #declaring an array

ListSize = ($ - A) #finding size of an array

MOV ARRAYLENGTH,ListSize # moving size value into ARRAYLENGTH variable

MOV ESI,ARRAYLENGTH #moving ARRAYLENGTH variable into ESI register

Call DumpReg #calling DumpReg to display the contents of the register


Related Solutions

Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio Write a program to add the following word size numbers:15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length...
In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will hold the random string. Write a test program that calls your procedure 20 times and displays the strings in the console window. In your program, the random string size shall be preset as a constant. Please include...
You must write the code in 80x86 assembly language and must attach a screenshot of the...
You must write the code in 80x86 assembly language and must attach a screenshot of the output. # Pennies for Pay Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality:...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality: Configures pin RA2 of the PIC24to be an output to control an attached LED. Configures pin RB13 of the PIC24 to be an input to read the value on an attached switch (this switch will connect to ground when pressed). Configures pin RB13 to use the internal pull-up resistor. After configuration, the LED will be "off" when the push-button is pressed, and "on" when...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
Write a C-based language program in visual studio that uses an array of structs that stores...
Write a C-based language program in visual studio that uses an array of structs that stores student information including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,”). Write the same program in the same language without using structs.
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
Assembly Language Visual Studio. Problem 1 College Registration Using the College Registration example from Section 6.7.3...
Assembly Language Visual Studio. Problem 1 College Registration Using the College Registration example from Section 6.7.3 (textbook) as a starting point, do the following: 1. Recode the logic using CMP and conditional jump instructions (instead of the .IF and .ELSEIF directives). 2. Perform range checking on the credits value; it cannot be less than 1 or greater than 30. If an invalid entry is discovered, display an appropriate error message. 3. Prompt the user for the grade average and credits...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT