me and my friend are trying to write a code in which we need to multiply two 32 bit numbers resulting in a 64 bit number. We wanted to multiply the numbers using the add method, the problem is that register can only store 8 bits (16 bits a pair) at a time. We've searched for solutions and it has been hard to find anything really helpful to this situation. Could you give us any hint on how to do this?
(Assembly - 8085) Multiply 32 bit numbers
2.9k Views Asked by Gonçalo At
2
There are 2 best solutions below
0
KinJin
On
Let the two numbers be AA55h and BB22h. We will use the 2nd number as a counter. The ALP is:
LXI B, AA55h LXI D, BB22h; counter LXI H, 0000h; 16bit carry initialization
Start: MOV A,C ADD C MOV C,A
MOV A,B ADC B MOV B,A
JNC Carry INX H Carry: DCX D; decrement counter JNZ Start
;;16 bit carry has been stored in HL pair ;;16 bit result has been stored in BC pair
Related Questions in ASSEMBLY
- (x64 Nasm) Writeline function on Linux
- Is the compiler Xcode uses to produce Assembly code a bad compiler?
- Why do we need AX instead of MOV DS, data directly with a segment?
- Bootloader in Assembly with Linux kernel
- How should the byte sequence 0x40 0x55 be interpreted by an x86-64 emulator?
- C++ code into assembly
- Drawing circles of increasing radius
- Assembly print on screen using pop ecx
- Equivalent to asm volatile in Gfortran?
- Show 640x480 BMP image with inline ASM c++
- Keep track of numbers entered in by a user in assembly
- 8086 Assembly Arrays with I/O
- DB ASM variable in Inline ASM C++
- What does Jump to means in callgrind?
- How to convert binary into decimal in assembly x8086?
Related Questions in 32-BIT
- Java: 32-bit fp implementation of Math.sqrt()
- Bug in FFI when passing CString followed by an int
- Gigabyte v/s Gibibyte & Gigabit v/s Gibibit
- How to install Cartopy to python-3.5 on linux-32
- Detect overflow from 64 bit addition on 32 bit machine with signed values
- C format string vulnerability: How many bytes does %x read from the stack?
- How to create BufferedImage for 32 bits per sample, 3 samples image data
- Determine if program was built with AnyCPU
- Is there any way to play back a 24-/32-bit audio stream using Java on Windows?
- Error starting MongoDB in windows 7 [32-bit]
- how to manually register a 32 bit version of SqlDmo.dll?
- Get android bit version (32 bit or 64 bit) at runtime
- NASM and a clarification on POP
- Loading from memory whose size is larger than the available size in an instruction
- Assembly: convert number to 32-bit
Related Questions in MULTIPLICATION
- VB.net: How to make original variable value fulfill 2 statements?
- Conditional subtraction Part 2
- Conditional subtraction
- VB.net: How to add different multipliers together?
- Multiply polynomials
- Perform integer division using multiplication
- multiplying rows in dataframe based on row in another datarame pandas
- Lots of cache miss, Sparse matrix multiplication
- Booth Multiplication Algorithm
- Issues With length() And Multiples Of 3
- mysql calculate multiplication with group by
- multiplication of very large with small values
- Need help in writing this multiplication code
- function to get the power of a number
- Multiplying 2 decimal values resulting wrong number
Related Questions in 8085
- Register returning a hex value 1 higher than it should (8085 assembly)
- How to add four data bytes using Stack in Intel 8085?
- An 8255 IC is interfaced to 8086 microprocessor
- 16 bit multiplication using 8085 microprocessor
- How many Machine Cycles are there in Jump Statements of 8085?
- How to converting 8085 code to z80 assembly
- (Assembly - 8085) Multiply 32 bit numbers
- Please give me an example where I need to use Push and Pop for 8085
- how to do less than or equal to in 8085 Assembly language
- What do bitshift operations in Intel 8085 assembly do?
- Split a 2 digits number in binary to single digit in binary
- 'Label' in assembly language - opcode
- Is carry flag complemented when subtrahend is converted into 2's complement in 8085 microprocessor?
- Program in 8085 Microprocessor
- 8086 masm program for palindrome checking
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Addition is addition, we learned addition in grade school.
9+1 = 0 carry the one, we do that twice, then get 0+1 = 1
Doesnt matter what base, in binary we could have this:
same deal, base 2, 1+1 = 0 carry the 1, repeat that until 1+0 = 1
But unlike paper and pencil we have a stronger limit on the number of bits in a computer, but that doesnt in any way change how it works.
I can take the prior problem and divide it into two bit sized registers.
the first one is the low order two bits 11+01 we do the math and get 00 with a carry out of 1. the second operation takes the carry out of the prior operation uses that as a carry in, then we add 01 + 00 with a carry in of 1, and get 10 with a carry out of 0.
Nothing magic there.
Then lets get more fundamental
we start with the lsbit which is 1+1 with a carry in of 0, so 0+1+1 = 0 with a carry out of 1. That carry out is the carry in of the next column the twos column. Which is the carry in of 1 plus 1 + 0 = 0 with a carry out of 1. the fours column is the same as the twos 1 + 1 + 0 = 0 with a carry out of 1. the eights column is a carry in of 1 + 0 + 0 = 1 with a carry out of 0. Every column works the same three things added together the carry in plus operand a plus operand b then you get a result bit and a carry out bit. You can chain those together as wide as you wish, millions of bits, billions of bits, infinite.
So assembly generally gives you some support here. Your alu tends to have a carry out that tends to go into a carry flag bit in some processor state register. You have your two operands and a result, the intermediate carry outs becoming carry ins are managed in the alu itself and you dont get to see those. Sometimes you have a normal add instruction and another add with carry instruction, where the carry flag is the carry in and then the carry out lands in that carry bit as well so for systems like that you would
for as wide of a set of values you want usually limited by the amount of memory you have or other similar limitations (number of registers).
If you dont have an add with carry then you have to synthesize that
Some instruction sets only have an add with carry so
I am obviously leaving the registers/operands off of these instructions as they are not important to the "how do I do math greater than the number of bits I have in a register" type of question. As shown above with the 1 and 2 bit math you need to prepare your data and place it in the operands based on the columns you are working on. If you have 8 bit registers and an 8 bit alu then you divide your N bit operands into 8 bit parts, organize them such that you work on the lower bytes first then the next higher order bytes in the second add and so on. Properly chaining your carry out of one stage into the carry in of the next.
Not sure why there was any problem searching for solutions. Grade school math covers the basics of counting and adding and carrying over to the next column, then you take that to the instruction set documentation where it describes the add and if there add with carry. Showing the add operation modifies the carry bit, and the add with carry uses and modifies the carry bit.