Question

Mult Hack Assembly language Help me complete the assembly language fore Mult.asm. // Multiplies R0 and...

Mult Hack Assembly language

Help me complete the assembly language fore Mult.asm.

// Multiplies R0 and R1 and stores the result in R2.

// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)

// Put your code here.

// Start R2 at 0.

@R2

M=0

// Jump into the first STEP if R0 > 0.

@R0

D=M

@STEP

D;JNE

// If it didn't jump, go to END.

@END

0;JMP

// Adds R1 to R2 and removes 1 from R0.

// If R0 is more than 0 we step again.

(STEP)
  
// Get R2.

@R2
  
D=M

  

// Add R1 to it.
  
@R1
  
D=D+M

  

// And write the result back to R2.
  
@R2
  
M=D

  

// Reduce R0 by 1.
  
@R0
  
D=M-1
  
M=D

  

// If R0 is still > 0 then loop.
  
@STEP
  
D;JGT

(END)
  
@END
  
0;JMP

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

Multiplication of number is as follows

The numbers reside in the memory location of Register R0 and R1.

@i

M=1

(LOOP)

@i

D=M

@R1

D=D-M

@END

D;JGT

@R0

D=M

@mul

M=M+D

@i

M=M+1

@LOOP

0;JMP

(END)

@END

0;JMP

Add a comment
Know the answer?
Add Answer to:
Mult Hack Assembly language Help me complete the assembly language fore Mult.asm. // Multiplies R0 and...
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
  • Find out what the following assembly code calculates AREA my code, CODE EXPORT main ALIGN ENTRY...

    Find out what the following assembly code calculates AREA my code, CODE EXPORT main ALIGN ENTRY main PROC MOVS MOVS MOVS r0,#0 r1,#15 r2,#0 loop CMP BGT MLA ADDS r2,r1 stop re,r2,r2,ro r2,r2,#1 loop % The final result is saved in register r0 stop B stop ENDP END

  • SEARCH Hack Assembly Language Help Whenever I run my .asm file, I get a comparison failure at lin...

    SEARCH Hack Assembly Language Help Whenever I run my .asm file, I get a comparison failure at line 3. Please help me resolve this issue. Here is my .asm code, followed by Search.tst. Search.asm: 1 // Searchs for given value 2 3 (loop) 4 @1 5 A=M 6 D=M 7 @0 8 D=D-M 9 @j1 10 D;JNE 11 @0 12 M=1 13 (j1) 14 @1 15 M=M-1 16 D=M-1 17 @j2 18 D;JEQ 19 @loop 20 0;JMP 21 (j2) 22...

  • Trying to figure out how to write expression #2 in assembly language: 1. ;;X=A*C+B*D MUL R4,R0,R2...

    Trying to figure out how to write expression #2 in assembly language: 1. ;;X=A*C+B*D MUL R4,R0,R2 MUL R5,R1,R3 ADDS R4,R4,R5 ;;X is in R4 I believe this is correct but Im having trouble with #2 below: 2. Y=A^(B+C)+D I've been using the arm cortex m4 instruction set for reference.

  • Write a new subroutine in assembly to convert the upper-case letters to lower-case letter. Example of...

    Write a new subroutine in assembly to convert the upper-case letters to lower-case letter. Example of lower case to upper is provided below: Let’s look at a subroutine to capitalize all the lower-case letters in the string. We need to load each character, check to see if it is a letter, and if so, capitalize it. Each character in the string is represented with its ASCII code. For example, ‘A’ is represented with a 65 (0x41), ‘B’ with 66 (0x42),...

  • Change this program in assembly language to loop until it encounters a sentinel value, which is a...

    Change this program in assembly language to loop until it encounters a sentinel value, which is a negative number. The data begins at x3100. Use only one branch command. There will always be at least one positive integer in the list. .ORIG x3000 LEA R1, xFF AND R3, R3, #0 AND R2, R2, #0 ADD R2, R2, #12 BRz #5 LDR R4, R1, #0 ADD R3, R3, R4 ADD R1, R1, #1 ADD R2, R2, #-1 BRnzp #-6 .END

  • Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the...

    Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper. (5 marks) Explain the difference between eor and eors instruction. Use an example to show why both forms are useful. а. b. (5 marks) Explain using an example what the "Idr r3, [r7,#4]" instruction does. c. (10 marks) The following is the assembly language generated by a C compile type mystery, %function mystery: args 0, pretend = 0, frame =...

  • LC3 stack (factorial) I need help in writing factorial in Lc3 language by using stack.. ; Begin ...

    LC3 stack (factorial) I need help in writing factorial in Lc3 language by using stack.. ; Begin reserved section: do not change ANYTHING in reserved section! .ORIG x3000 BR Main ; Parameter and result Param .FILL x0004 Result .BLKW 1 ; Constants Stack .FILL x4000 One .FILL #1 MinusOne .FILL #-1 ; End reserved section: do not change ANYTHING in reserved section! ;------------------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; int Factorial(int N) ; Returns N! (must be a recursive function) ; Factorial ;__________________...

  • Translate the following C program to Pep/9 assembly language. It multiplies two integers using a ...

    Translate the following C program to Pep/9 assembly language. It multiplies two integers using a recursive shift-and-add algorithm. mpr stands for multiplier and mcand stands for multiplicand. A recursive integer multiplication algorithm #include <stdio.h> int times(int mpr, int mcand) {    if (mpr == 0) {       return 0;    }    else if (mpr % 2 == 1) {       return times(mpr / 2, mcand * 2) + mcand;    }    else {       return times(mpr / 2, mcand * 2);    } } int main() {    ...

  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...

  • A data scientist needs a MIPS assembly-language program for data analysis. He has three arrays of...

    A data scientist needs a MIPS assembly-language program for data analysis. He has three arrays of floating-point numbers. Array 'a' is a source array, and 'b' and 'c' are result arrays. Array 'a' contains '2n' floating-point numbers. 'r1' is the address of 'a[0]'. 'r4' is the address of the byte immediately following 'a', i.e., the address of the imaginary element 'a[2n]'. Each of 'b' and 'c' can store 'n' floating-point numbers. 'r2' is the address of 'b[0]'. 'r3' is the...

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