TITLE Multiplication App rlzProg6.asm ; Program Description: Mainly a Shift/Mult App ; Author: Robert Zaleski ; Creation Date: Mar 1, 2004 ;; Pseudocode ;; ;; Basically we just need to pick one operand to be the shift (determining ;; when to add), and the other to be the number to add. We start with the ;; most sig of the shifter and shift the answer and add if the bit from the ;; is one. We repeat until we go through all the bits of the shifter. INCLUDE Irvine32.inc .data .code main PROC call getInts ; Since I have this written I'll use it call DumpRegs ; Print out what we're multiplying call FastMultiply ; Do this shift add multiply call DumpRegs ; Finish up with printing the result. exit main ENDP ;; This procedure takes nothing in and prompts the user for two 8 digit hex numbers which will ;; be stored into eax and ebx getInts PROC .data inputMsg BYTE "Please enter 2 hex 8-digit numbers each followed by a return",0 .code mov edx, OFFSET inputMsg ; load instructions for the and call WriteString ; Print them out call Crlf call ReadHex mov ebx, eax ; Store the first hex into ebx call ReadHex ret getInts ENDP ;; This procedure takes eax and ebx and multiplies them storing the product ;; In eax:edx, so edx has the low bits, FastMultiply PROC xor edx, edx ;; Low bits will end up here. 0 it for now mov ecx, 32 DOMUL: shl edx, 1 ;; Move the product one left ( note carry gets most sig) RCL eax, 1 ;; Move the operand one left, it will take in from edx. jnc ENDMUL ;; Go to the end of the loop if we're not adding add edx, ebx ;; Add If we got a bit jnc ENDMUL ;; Check to see if the add caused a carry inc eax ;; If it did we place it into eax ENDMUL: loop DOMUL xchg eax, edx ;; Swap them for compliance reasons. ret FastMultiply ENDP END main