Question

Assembly Language Programming Write a complete assembly program that inputs a small signed integer n, whose...

Assembly Language Programming

Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2n + 6.

(This is not C++ or Java. Has to be masm file)

Homework Answers

Answer #1

Code:

find:
PUSH %BP
MOV %SP, %BP
@find_body:
MUL 8(%BP), 8(%BP), %0
SUB %0, 8(%BP), %0
ADD %0, $6, %0
SUB %SP, $4, %SP
MOV %0, -4(%BP)
MOV -4(%BP), %13
JMP @find_exit
@find_exit:
MOV %BP, %SP
POP %BP
RET
main:
PUSH %BP
MOV %SP, %BP
@main_body:
PUSH $6
CALL find
ADD %SP, $4, %SP
MOV $0, %13
JMP @main_exit
@main_exit:
MOV %BP, %SP
POP %BP
RET

Hope this helps.

Know the answer?
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
Similar Questions
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent Windows32 integrated development environment (IDE)] program into one that inputs two positive integers, and outputs their greatest common divisor, by implementing the following pseudo-code: input num1 and num2 (assume num1 > 0 and num2 > 0) gcd := num1 remainder := num2 repeat numerator := gcd gcd := remainder remainder := numerator % gcd until (remainder == 0) output gcd The following 3 windows...
Write a complete assembly language program that computes in EAX the value of the expression x...
Write a complete assembly language program that computes in EAX the value of the expression x − 2y + 4z for doublewords in memory at x, y, and z. Choose the current month (1–12), day (1–31), and year (all four digits) for the values of x, y, and z.
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your variables here .code main PROC    ; write your assembly code here    INVOKE ExitProcess,0 main...
Write a MASM program that computes the sum of the integers from 1 to N where...
Write a MASM program that computes the sum of the integers from 1 to N where N is a positive integer. Use the equal sign directive to define N. Save the sum in the EAX register. You must use loops. For example, 1 = 1 1 + 2 = 3 1 + 2 + 3 = 6 1 + 2 + 3 + 4 = 10 1 + 2 + 3 + 4 + 5 = 15 Language ( Assembly)...
All in C language... Write a complete program that declares an integer variable, reads a value...
All in C language... Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces. Besides the numbers, nothing else should be written to standard output except for spaces separating the values. I got this... and it's wrong #include<stdio.h> int main() { int num; scanf("%d", &num); printf("%d %d %d",num,2*num,num*num); return 0; }
Please Write the whole program in assembly i am able to calculate the fibonacci series but...
Please Write the whole program in assembly i am able to calculate the fibonacci series but not sure how to print it in reverse order. Please give a Complete code !! Programming Exercise 1 (10 points): [call it Ass2-Q1.asm] Write an ASM program that reads an integer number N and then displays the first N values of the Fibonacci number sequence, described by: Fib(0) = 0, Fib(1) = 1, Fib(N) = Fib(N-2) + Fib(N-1) Thus, if the input is N...
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
Use MARS to write and simulate a MIPS assembly language program to swap two of the...
Use MARS to write and simulate a MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. Download the template file “P4_template.asm” provided on Blackboard. Add your code to this file. Do not modify any of the code provided in the file. The main function should: • Pass the starting address of the array in $a0....
Write a program which inputs an integer value, incr, from the user at the keyboard, and...
Write a program which inputs an integer value, incr, from the user at the keyboard, and then displays a graph of the sine of the degree values from 0 to 180, in increments of incr. You must use the sin function (in a similar manner to ceil and floor) to find the sine. Note that the sin function only operates on radians so the degree value must first be converted to radians. To do so, multiply the degree value by...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT