Question

Write an assembly language program to do the following, and run it and test it on...

Write an assembly language program to do the following, and run it and test it on the lab simulator: Read in integers until a zero is read in. Keep a total of both the quantity and the sum of the negative integers and the positive integers. Once a zero is read in (signifying the end of the input) then: • If there were more positive than negative integers, or an equal number, print out a 0 and the sum of the positive integers. • If there were more negative than positive integers, print out a 1 and the sum of the negative integers. Hand in your answer to this question as 1. A screen shot of the lab assembler program once your program has been assembled successfully, showing that it assembled successfully. 2. A complete separate print-out of your source code with comments, as it may not all be visible in the assembler simulator window. 3. Screen shots of the von Neumann assembler execution window after execution of your program executed with some sample data, for both situations (more negative integers, and more positive integers). 4. The sample data you used to test the program in both situations. Note that you can resize both windows by “pulling” on the corners until all of your code is visible.

Optionally, you can start off by making a flowchart or pseudocode solution to the problem, then converting it to assembler if you like (not required). • Use small numbers as your test data so it is easy to see if your program produces the correct result. • When inputting data, you need to change the bits in the window that pops up to the binary input value you want to use. If you keep the input numbers small, you only need to change the rightmost 3 or 4 bits. Remember that negative values are obtained by changing the leftmost bit from 0 to 1, in sign/magnitude form. • When doing a second run of your program, always close the Von Neumann window and start up again. The refresh button clears the registers, but it leaves old values in memory, which could cause problems on subsequent runs. • Remember to hand in pictures of the assembler window with your code successfully assembled, and the Von Neuman machine window after your code has executed successfully. I'll also need a list of your input to determine if your output is correct. To get pictures into a document: Use ALT-PrintScreen to get a picture of just the current window you are working in. Drop it into a Word or WordPad document with paste or CTRL-V.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER :

Here is the code for the given problem in Assembly Language:-

Assembly Program

.LC0:

.string "%d"

.LC1:

.string "0 and sum of positive integers are:%d"

.LC2:

.string "1 and sum of negative integers are:%d"

main:

pushq %rbp

movq %rsp, %rbp

subq $32, %rsp

movl $0, -20(%rbp)

movl $0, -4(%rbp)

movl $0, -8(%rbp)

movl $0, -12(%rbp)

movl $0, -16(%rbp)

.L4:

leaq -20(%rbp), %rax

movq %rax, %rsi

movl $.LC0, %edi

movl $0, %eax

call __isoc99_scanf

movl -20(%rbp), %eax

testl %eax, %eax

jle .L2

addl $1, -4(%rbp)

movl -20(%rbp), %eax

addl %eax, -12(%rbp)

jmp .L3

.L2:

addl $1, -8(%rbp)

movl -20(%rbp), %eax

addl %eax, -16(%rbp)

.L3:

movl -20(%rbp), %eax

testl %eax, %eax

jne .L4

movl -4(%rbp), %eax

cmpl -8(%rbp), %eax

jl .L5

movl -12(%rbp), %eax

movl %eax, %esi

movl $.LC1, %edi

movl $0, %eax

call printf

jmp .L6

.L5:

movl -16(%rbp), %eax

movl %eax, %esi

movl $.LC2, %edi

movl $0, %eax

call printf

.L6:

movl $0, %eax

leave

ret

Hope it helps... please give an upvote. it's very important to me... thank you:)

Add a comment
Know the answer?
Add Answer to:
Write an assembly language program to do the following, and run it and test it on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write the code in assembly language which can run in HLA. Thank you very much!!...

    Please write the code in assembly language which can run in HLA. Thank you very much!! -So we need to write the code in assembly language in Notepad++, end with .hla and run it in CMD. - This project is about writing a program to read numbers, counts the items read, calculates the total, the maximum and minimum of the numbers. -The program stops when a 0 is entered. Zero will not be part of the data. -work with integers,...

  • Question: WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT ... WRITE A PROGRAM IN LC-3...

    Question: WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT ... WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT USE PYTHON, JAVA, C or C++ or OTHERS. Your task is to write a program that counts the number of 1 bits of the value stored at location given by Datal. Your program should print the count (in hexadecimal, as it is easier) along with an appropriate heading. Test your program with the following values stored in Datal: a xFFFE...

  • Summation of a series is given by the equation . Write an ARMv8 assembly program to...

    Summation of a series is given by the equation . Write an ARMv8 assembly program to compute and store y. The input a is in X19 and the input is 64- bits, non-zero positive integer less than 10. Store the result y in X20. Assemble, test, and simulate the assembly code using DS-5 simulator. Do not upload the entire DS-5 project. Only upload the assembly file (.S file) from the DS-5 project to Canvas. Comment your assembly code u+ =...

  • MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and...

    MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...

  • Write a program that prompts the user to read three positive hex integers and display their...

    Write a program that prompts the user to read three positive hex integers and display their sum in both hex and decimal. Your program should prompt the user to read the number again, if the input is incorrect. You must use java.lang.NumberFormatException. (chapter12.AddThreeHexNumbers.java)

  • In Assembly Language Please display results and write assembler code in (gcd.s) The Euclidean algorithm is...

    In Assembly Language Please display results and write assembler code in (gcd.s) The Euclidean algorithm is a way to find the greatest common divisor of two positive integers, a and b. First let me show the computations for a=210 and b=45. Divide 210 by 45, and get the result 4 with remainder 30, so 210=4·45+30. Divide 45 by 30, and get the result 1 with remainder 15, so 45=1·30+15. Divide 30 by 15, and get the result 2 with remainder...

  • I do not know where to begin with this code Using C++ code, write a program...

    I do not know where to begin with this code Using C++ code, write a program to print "R" if 2 random integers A and b in the range [-80,   80] are both positive, "L" if A and B are both negative and "Z" otherwise.

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other in the sequence. Input The first line contains an integer n...

  • Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers

    Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...

  • Write a C++ program to read an unknown number of integer values and find the sum...

    Write a C++ program to read an unknown number of integer values and find the sum of only negative integers. Use variable n to store the user input. Hint: Check Example6E.cpp (Lecture 6) Note: Use the "Check" button to verify your answer. You can modify your code and check until you get it right. For example: Test Input Result -11 A list of integers -10 12 1 14 -1

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT