Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write assembly programs to carry out the following operations. Problem 5: Assume R1 and R2 are both set to positive input values at the start.

Write assembly programs to carry out the following operations.

Problem 5:

Assume R1 and R2 are both set to positive input values at the start. Print the result of dividing R1 by R2 in quotient/remainder form. For example, if R1=9 and R2=2, you should print 4 1; if R1=9 and R2=3, you should print 3 0.

You can only use instruction below:

image text in transcribed

image text in transcribed

Instructions available: LOAD integer, destination register Loads an integer into a register. Example LOAD 5, R2 sets R2 to 5 ADD source register, destination register Adds the integer in the source register to the one in the destination register, storing the result in the destination register. Example: ADD R1, R2 MOV source register, destination register sets R2 to R1+R2 Moves the value in the source register to the destination register (source register is left unchanged, so you can also think of this as "copy") Example MOV R1, R2 sets R2 to R1 NEG register Negate the value in a register. Example: NEG R1 sets R1 to -R1 JMP label Unconditional jump to the line with the given label Example loop: ADD R1, R2 JMP loop jump to the previous line, which is labeled loop JZ register, label JNZ register, label JLZ register, label JGZ register, label Conditional jumps. JZ jumps to label if register is zero. JNZ jumps if register is non-zero. JLZ jumps if register is less than zero. JGZ jumps if register is greater than zero. PRINT register Print the value in register. In a real CPU, there wouldn't normally be a low-level instruction to print out numbers, but for our purposes it lets you write assembly programs that output results. Example: PRINT RI i prints the value in R1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions