Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am writing a multiplication subroutine in LC-3. I have the basis of it. But I am wondering: when multiplying negative numbers, what would be

I am writing a multiplication subroutine in LC-3. I have the basis of it. But I am wondering: when multiplying negative numbers, what would be the best way to approach it?
Would it be possible to convert to twos compliment and then multiply or would that give an inaccurate result?
Or should I stick with my original plan of just testing each number to see if negative, and then if it is negative, I'm not really sure how to multiply the numbers without causing an overflow.
I attached the code I have below, but im just asking for help when either number is negative. image text in transcribed
ORIG x3000 LDI RO, NUMBER ;load 1st number BRn STOP LDI R1, NUMBER2 ;load 2nd number BRn STOP AND R2, R2, #0 ;set R2 equal to zero to add multiplicant Loop ADD R2, R2, RO ;LOOP thru, to continue adding the number until ADD RI, RI, #-1 ;decrement until r1 is 0 BRp Loop ;loop until R1 is 0 STI R2, STORE_MULT ;STORE RESULT STOP HALT NUMBER .FILL x3100 NUMBER2 .FILL x3101 STORE MULT .FILL x3102 END

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

Step: 3

blur-text-image

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions