Question

write a program immediate.asm that adds the number 5 to a constant called first1. Note that...

write a program immediate.asm that adds the number 5 to a constant called first1. Note that this arithmetic must take place in a register.
Save the source file as imm.s
0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data
first1 : .word 10 #storing the constant 10 to first1 variable
msg1 : .asciiz "first1 = "
msg2 : .asciiz "\nAfter adding 5 to First1: "


   .text
   .globl main
main:
#copy value in first1 to $t0
lw $t0,first1
#print the string in variable in msg1
li $v0,4 #print string syscall is v0 = 4
la $a0,msg1 #copy address of msg1 to $a0
syscall

#print the value in first1
li $v0,1 #print integer syscall is v0 = 1
move $a0,$t0 #copy value in $t0 to $a0
syscall

#copy value 5 to $t1
li $t1,5
#add $t0 and $t1.Result stores in $t0
add $t0,$t0,$t1
  
#print the string in variable in msg
li $v0,4 #print string syscall is v0 = 4
la $a0,msg2 #copy address of msg2 to $a0
syscall

#print the result after adding 5 to first1
li $v0,1 #print integer syscall is v0 = 1
move $a0,$t0 #copy value in $t0 to $a0
syscall


li $v0,10 #$v0 == 10 terminate the program # 1cycle
syscall #executes the above operation #3 cycles



Add a comment
Know the answer?
Add Answer to:
write a program immediate.asm that adds the number 5 to a constant called first1. Note that...
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
  • write an 8086 assembly program that 1) adds two operand. 2) that adds operands until the...

    write an 8086 assembly program that 1) adds two operand. 2) that adds operands until the new value to be added is 0. 3) Write a program that increments by 2 the content of a register 10 times.

  • Write a program to reverse an integer number by using a function called reverse. The program...

    Write a program to reverse an integer number by using a function called reverse. The program reads in an integer number and prints its reverse order. Note that the function receives the number via a pointer, and uses the pointer to write the reverse number on the main function. The function MUST be used AS IS: void reverse(int *n) Language in C Bonus Problem: Number Reverser reverse c Write a program to reverse an integer number by using a function...

  • ARM assembly language Write a program "fibonacci.s" that computes the Nth Fibonacci number where N is...

    ARM assembly language Write a program "fibonacci.s" that computes the Nth Fibonacci number where N is not so large that overflow of integer arithmetic is a concern. When your assembly language program is called it should expect the value of N to be passed using register r0 and your program should return the Nth Fibonacci number in register r0. Please include comments as well. Do not just use the output generated by gcc -S

  • Write a C program which is called ‘multiple_copy’. This program copies one source file to two...

    Write a C program which is called ‘multiple_copy’. This program copies one source file to two destination files as follows: $./multiple_copy....... source_file....... destination_file1......... destination_file2 multiple_copy program copies the contents of source file (i.e., source_file) to any named two destination files in the command line. The number of arguments should be 4 including multiple_copy. If the number of arguments is not 4, the program should display error message saying: “Usage: multiple_copy source_file destination_file1 destination_file2”. When the source_file does not exist, the...

  • Arm Assembly Programming : Total of 3 assembly files using VisUAL arm emulator ( save as...

    Arm Assembly Programming : Total of 3 assembly files using VisUAL arm emulator ( save as .S file) 1. Write a program to solve the below expression:      Z= (a << 2) | (c & 15) 2. Write a program that adds the 32-bit two’s complement representations of −149 and 5 . Place the result in register r7. Submit your code with the resulting value in register r7 commented. 3. Write a program to mask first 9 bits of a...

  • Write a function called addNeighbors that takes an array of numbers and adds each number in...

    Write a function called addNeighbors that takes an array of numbers and adds each number in the array to the number next to it. The array will always have an even number of numbers in it. In the end you should return an array of neighbors added up. Please use JavaScript Instructions from your teacher. Medium Question #4 Write a function called addNeighbors that takes an array of numbers and adds each number in the array to the number next...

  • I need help with ARM assembly program : Using the following code as basic : 1...

    I need help with ARM assembly program : Using the following code as basic : 1 ) Write a program code that is able to calculate the following : Result = A + ( B * C ) - D Place the result as the return value so you can print it afterwards in the command prompt. 2) This time, use MLA instruction to reduce the number of instructions in question 1. Place the result as the return value so...

  • USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by...

    USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by the user. Remember that x! =x* (x-1)* (x-2)*... *3+ 2* 1. Your program should check the value input by the user to ensure it is valid (i.e., that it is a number > =1). To do this, consider looking at the is digit() function available in Python. If the user enters an incorrect input, your program should continue to ask them to enter a...

  • A. Write an Array Program Write a main program that counts the number of occurrences of...

    A. Write an Array Program Write a main program that counts the number of occurrences of the number 6.0 in a large array of doubles and then prints out the number of elements in the array and the number of values that are 6.0. Also, compute and print the average value to 7 decimal places of all the elements in the array. 1. Use a for loop. The array fArray [ is defined in a file called Lab8Adatasetx.h that will...

  • Write the hexadecimal notation for a MIPS machine language program that adds 42 to the value in register 2 placing the result in register 3 and then returns. Example of running the program: Enter valu...

    Write the hexadecimal notation for a MIPS machine language program that adds 42 to the value in register 2 placing the result in register 3 and then returns. Example of running the program: Enter value for register 1: 2 Enter value for register 2: 3 Running MIPS program. MIPS program completed normally. $01 = 0x00000002 $02 = 0x00000003 $03 = 0x0000002D ...

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