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...

  • 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...

  • Step 1: Create a new ASSEMBLY project using Keil Software (1) Make sure you use the M3 option St...

    Step 1: Create a new ASSEMBLY project using Keil Software (1) Make sure you use the M3 option Step 2: “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....

  • I need help with a code in assembly language MASM (x86)

    write an assembly language (x86) program to input in a string 10 multi-digit integers and displays them in ascending order. Modify the code below to comply with the requirement..model small.stack 100h.datastrg1 DB 'Insert numbers: $'strg2 DB 'Sorted numbers: $'Arr Db 10 dup(?)v dw ?.codemain procmov ax,@datamov ds,axmov ah,9lea dx,strg1int 21hmov dl,0ahmov ah,2int 21h;inputsmov di,0mov cx,10Input_loop:mov ah,1int 21hmov arr[di],almov dl,0ahmov ah,2int 21hinc diloop Input_loopmov v,0sort:mov di,0mov cx,10sub cx,vB:mov al,Arr[di]cmp al,Arr[di+1]jng Cmov al,Arr[di]xchg al,Arr[di+1]mov Arr[di],alc:inc diloop Binc vcmp v,10jne sort;Outputmov ah,9lea dx,strg2int...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

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
Active Questions
ADVERTISEMENT