Question

In: Computer Science

This program has to be written in assembly language using emu8086. Please choose the .EXE template....

This program has to be written in assembly language using emu8086. Please choose the .EXE template. The requirements and the action is contained in the docx file.

You’ve been hired by Spacely Sprockets and they need to be able to write order information out to a file. Using all of the knowledge that we’ve gained in the last few sections on structures and files, you need to write a program that does the following:

  1. Design a structure that can hold an order number (integer type data), a customer’s ID (integer type data), a sprocket type (string type data), a part quantity (integer type data) and an order total (floating point data). These will be simply stored in the structure as string data.
  2. When your program is run, prompt the user to enter each of these pieces of data into the structure.
  3. Once the last piece of structure data has been entered, prove the structure is working correctly by neatly printing the structure’s contents out to the screen.
  4. Open a file up for writing and write the structure out to the file. Print a message out to the screen once the file has been created.
  5. Clear any data in the structure out.
  6. Open the file back up for reading and pull the data back into the structure.
  7. Print the structure out to the screen again. If you are successful, the same data should appear twice on the screen (once from the filling\printing of the structure and the second time from reading the structure in from a file.

Here’s a sample run:

Order Number: 105

Customer ID: 405

Sprocket Type: Awesome Atomic Sprocket

Part Quantity: 3

Order Total: 105.74

Struct written to file C:\asm\test.txt

Order Number: 105

Customer ID: 405

Sprocket Type: Awesome Atomic Sprocket

Part Quantity: 3

Order Total: 105.74

Program Complete!

Hints: Think procedures! You can simplify the code and your debugging life by writing procedures. For example, a print structure routine, a save to file routine, a read from file routine, et cetera. Secondly, DO NOT code this application in a single shot – incrementally build up each piece of logic otherwise you will get lost when things don’t work right.

Solutions

Expert Solution

Solution :-

know that floating point addition is not associative: (a + b) + c in general does not equal a + (b + c). So this algorithm for sum can give a different result depending on the order of the input:

float naive_sum(float[] input) {
  float accumulator = 0;
  for (float x : input) {
    accumulator += x;
  }
  return accumulator;
}

Is it possible to make this order-independent, so that it returns the same result even when the input is shuffled? I'm not trying to reduce the rounding error: I just want it to be order-independent.

One idea is to sort the input first:

If you want to display something on screen you can use the print() function. An example of code that prints to screen in IDLE is shown below:

print("Hello World")

This is what it would look like when run in IDLE:

Inputting Data

If you want the user to enter data into the program, you can use the input() function. An example of code that will ask the user to enter their name and display it on screen using print() is shown below:

name = input("What is your name? ") # displays the message on screen and stores the input from the user in a variable called name
print("Hi "" +name)

This is what it would look like when run in IDLE:

Example program 1 - Enter a Word

The code for the program below will allow the user to enter a word and store it in a variable called word. It will then use the print() function to output the word that they entered.

word = input("Please enter a word ")
print("You entered the word "  + word)

When run in IDLE:

Example program 2 - Address Program

The code for the program below will allow the user to enter various pieces of information and store them in different variables. The print() function is then used to output all of the information.

number = input("Enter your house number: ")
street = input("Enter your street name: ")
town = input("Enter your town/city: ")
county = input("Enter your county: ")
postcode = input("Enter your postcode: ")
print("\nAddress Details:\n" + "Street: " + number + " " + street + "\nTown/City: " + town + "\nCounty: " + county + "\nPostcode: " + postcode)

When run in IDLE:

You can concatenate (join together) variables with strings in a print() function. In the address example print("Street: " + number + " " + street + "\nTown/City: " + town) will combine the strings “Street†and “Town/City†with the variables number, street and town.

\n is used to start a new line when it is displayed on screen.

Variables

A variable is used to temporarily store a piece of data.

For example:

number1 = 10

In the code above the variable is called number1 and the value it is storing is 10. Variables can hold any type of data. Using variables makes it easier for people to understand what is going on.

For example:

cost = 15
VAT = 3
total_cost = cost + VAT

Casting Variables

Python will automatically decide what type of data a variable should be, sometimes this isn’t right, therefore you will have to convert/cast variables to a different data type.

Integer

The program below will multiply a number by 5. When data is input from the user it will store it as a string. You will need to convert the variable number to an integer before performing a calculation. An example of how you do this is shown below:

number = input("Enter a whole number ")
answer = int(number) * 5 #converts the variable number to an integer and multiplies it by 5.
print(answer)
float sort_sum(float[] input) {
  return naive_sum(sort(input));
}

sort doesn't have to put the floats in numeric order; it just has to to satisfy sort(input) == sort(shuffle(input)). I think this works, but it's no longer constant space and linear time the way naive_sum was.

Another idea is to make the accumulator be a huge integer type: big enough to fit any float without rounding. If floats have an 11-bit exponent, you would need around 2^11 bits, which comes out to around 2000 bits.

float fixedpoint_sum(float[] input) {
  int2048 accumulator = 0;
  for (float x : input) {
    accumulator += float_to_fixed(x);
  }
  return fixed_to_float(accumulator);
}

Related Solutions

Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
Please code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 10.) Fibonacci Generator Write a procedure that produces N values in the Fibonacci number series and stores them in an array of doubleword. Input parameters should be a pointer to an array of doubleword, a counter of the number of...
Assembly language - please post with output Question: Using the AddTwo program from class lecture as...
Assembly language - please post with output Question: Using the AddTwo program from class lecture as a reference, write a program that calculates the following expression, using registers: A = (A + B) - (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers.
It is required that this program be written in ARM Assembly using raspberry pi. Submit an...
It is required that this program be written in ARM Assembly using raspberry pi. Submit an ARM assembly program that does the following: 1. Prompt for the user to enter a number (integer). 2. If the entered number is <100 print: "The input number is less than 100." 3. If the entered number is >=100 print: "The input number is greater than or equal to 100." 4. Prompt for the user to enter a single character. 5. If the entered...
Write an assembly language program that corresponds to the following C program ****Please give correct answer...
Write an assembly language program that corresponds to the following C program ****Please give correct answer using Pep/9 machine**** int num1; int num2; ;int main () { scanf("%d", &num1); num2 = -num1; printf("num1 = %d\n", num1); printf("num2 = %d\n", num2); return 0; }
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...
Using the windows 32 framework , write an assembly language program ; write a procedure to...
Using the windows 32 framework , write an assembly language program ; write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the...
This program is to be written in Java Language. Thank you A College has conducted a...
This program is to be written in Java Language. Thank you A College has conducted a student survey. Students were asked to rate their satisfaction with remote learning courses. Students rated their satisfaction on a scale of 1 to 5 (1 = "I hate it", 5 = "I love it"). The student responses have been recorded in a file called "StudentResponses.txt". Each line of the file contains one student response. Program 1 You are to write a program that reads...
Take the following C++ program and translate it into assembly language( pep9 ) #include using namespace...
Take the following C++ program and translate it into assembly language( pep9 ) #include using namespace std; char ch; int main() {    cin >> ch;    cout << "You inputted " << ch << endl;    ch++;    cout << "Next character is " << ch << endl; if (ch <= ‘Z’)         cout << “Could be luppercase\n”;    return 0; }
Using the MARIE computer assembly language, write a program that computes the following expression: z =...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. Note: If any of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT