My class actually has no idea how to use assembly as all we had learned from the past few months is Java, and we were suddenly tasked to do this activity. Please give us your guidance.
Asked
Active
Viewed 178 times
0
-
What are "big" numbers? Numbers larger than can be stored in registers? Generally, you first multiply the first and second number, then you multiply the result with the third number, then you divide that result by 100. There are instructions for multiply and divide. The input and output is in specific registers. So you possibly need to `mov` the data to the relevant registers. For multiplication and division you should choose beforehand, whether to operate on signed or unsigned data. – Sebastian May 14 '22 at 06:58
-
What I meant by "big numbers" are those that range from 1-99999, as the usual examples on the internet only allow for single digit multiplication. – Alice Cherry May 14 '22 at 07:38
-
1The difficulty with more than single digit often is: reading it in from keyboard, not the multiplication itself. You would need 64-bit arithmetic to multiply 3 such numbers. – Sebastian May 14 '22 at 07:46
-
What if I lowered it to only 4 digit numbers? Would it be possible on 8086? – Alice Cherry May 14 '22 at 07:54
-
The maximum width 8086 is 16 bits x 16 bits = 32 bits. If this is enough for your result, you can split the current 32-bit intermediate result into two 16-bit registers: `REGA=65536*REGAHIGH+REGALOW`. And can multiply with a 16-bit register B: `REGA*REGB=65536*(REGAHIGH*REGB)+REGALOW*REGB`. You have to add the higher bits from the lower multiplication to the upper bits. Difficult to explain. – Sebastian May 14 '22 at 08:06
-
1https://stackoverflow.com/questions/29246857/multiplying-32-bit-two-numbers-on-8086-microprocessor/60015995#60015995 – Sebastian May 14 '22 at 08:12
-
Thanks, I think that'll help. I still have zero clue about assembly so I don't actually understand thus, I'll try to look up some tutorials online. – Alice Cherry May 14 '22 at 08:26
-
1https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/ia-large-integer-arithmetic-paper.pdf explains the normal way to do extended-precision integer multiplication (e.g. of 512-bit numbers using 64-bit registers, which is the same problem as 128-bit multiplication using 16-bit registers). The point of that whitepaper is to introduce new instructions (mulx and adox/adcx) that can make it more efficient, but the diagrams showing cross-products adding up are well done so it's useful for understanding the original way that just needs the `mul` and `adc` instructions. – Peter Cordes May 14 '22 at 11:56
-
2If your assembler expertise is low, I suggest you first try adding two numbers, before advancing to multiply three numbers. – Weather Vane May 14 '22 at 17:08