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 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 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...
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...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your solutions for each problem solved in a Word or Google document which includes (a) the pseudocode, (b) the C# codes and (c) the execution result (screen capture just the answer part using Snipping Tool, avoiding non-related or blank spaces). Notice for readability, that the (a) & (b) are in text mode and the (c) is in image mode. Use proper titles and wording in...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your solutions for each problem solved in a Word or Google document which includes (a) the pseudocode, (b) the C# codes and (c) the execution result (screen capture just the answer part using Snipping Tool, avoiding non-related or blank spaces). Notice for readability, that the (a) & (b) are in text mode and the (c) is in image mode. Use proper titles and wording in...
ASSEMBLY LANGUAGE ONLY OR I WILL DOWNVOTE write a program that will allow a person to...
ASSEMBLY LANGUAGE ONLY OR I WILL DOWNVOTE write a program that will allow a person to play a Guess a C♠rd Game. This section specifies the required functionality of the program. The interface must be a BlueJ Terminal Window, otherwise zero marks will be awarded. Only a simple screen presentation of the game is required; however, more marks will be gained for a game that is easy to follow with clear informative messages to the player. The aim of the...
Write a C program The Visual Studio project itself must make its output to the Console...
Write a C program The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 3%: Looping Menu with 3 main actions: View Cars, Sell Car, View Sales Note: A Car is defined by its price and model 3%: Must contain at least three arrays to record sales figures (maximum of 10 Car models) Two for recording the price and model of one...
Write the below C program using ARM assembly language and compile for Cortex A53. #include<stdio.h> void...
Write the below C program using ARM assembly language and compile for Cortex A53. #include<stdio.h> void quicksort(int number[25],int first,int last){ int i, j, pivot, temp; if(first<last) { pivot=first; i=first; j=last; while(i<j) { while(number[i]<=number[pivot]&&i<last) i++; while(number[j]>number[pivot]) j--; if(i<j){ temp=number[i]; number[i]=number[j]; number[j]=temp; } } temp=number[pivot]; number[pivot]=number[j]; number[j]=temp; quicksort(number,first,j-1); quicksort(number,j+1,last); } } int main() { int i, count, number[25]; printf("Enter some elements (Maximum 25): "); scanf("%d",&count); printf("Enter %d elements: ", count); for(i=0;i<count;i++) scanf("%d",&number[i]); quicksort(number,0,count-1); printf("The Sorted Order is: "); for(i=0;i<count;i++) printf(" %d",number[i]); return...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT