Do the flowchart and write a program for a subroutine to do
Do the flowchart and write a program for a subroutine to do multiplication of 2 binary numbers smaller that 15, received via memory positions $1000 and $1001 , and the result should be on $1002. DO NOT USE MUL.
Do by checking each bit, and testing bit : if it is 1, sum and shift left, if it is 0, just shift.
Do not forget to check for the case when one of the received parameters are 0.
(a) do the flowchart
(b) do the code , commented and with header.
You can use subroutines or macros, but use just on of them
Do the flowchart please
Solution
Iam giving answer in assembly language program using instruction of 8086
since iam finding difficulty in drawing the flow chart iwill give u in sentences
step1:enter the two numbers num1 and num2
step2:move the num1 to ax register and num2 to bx register
step3:clear the contents of dx register to save the result using instruction xor dx,dx
step4:rotate the contents of bx register inordrer to check wheatheer the bit is 0 or 1
step5:check whether the bit is 1 or 0 i.e.,if carry then the bit is 1 otherwise 0
step6:if jc i.e., if carry then add the contents of ax to dx and shift the contents of dx one time left
step7:if no carry then just shift the contents of dx once
step8:then verify the count stored in cx if zero thenmove the result to location $1001and exit otherwise jump to step 4 and cotinue till it is zero.
here is the assembly language program
In this Assembly Language Programming, A single program is divided into four Segments which are 1. Data Segment, 2. Code Segment, 3. Stack Segment, and 4. Extra Segment. Now, from these one is compulsory i.e. Code Segment if at all you don’t need variable(s) for your program.if you need variable(s) for your program you will need two Segments i.e. Code Segment and Data Segment.
Data segment
NUM1 DB ?
NUM2 DB ?
RESULT DB ?
MSG1 DB 10,13,”ENTER FIRST NUMBER TO MULTIPLY : $”
MSG2 DB 10,13,”ENTER SECOND NUMBER TO MULTIPLY : $”
data ends
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA ;initilizing data segment.
MOV DS,AX
LEA DX,MSG1;getting the number from keyboard
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM1,AL
MOV ax,NUM1
LEA DX,MSG2
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM2,AL
MOV BX,NUM2
XOR DX,DX
MOV CX,04H
L1;ROR BX,01H
JC L1
ADD AX,DX
L1:SHL DX,01H
CMP CX,00H
JZ L2
MOV RESULT,DX
INT 21H
ENDS
END START
MOV AH,2
MOV DL,BL
INT 21H
MOV AH,4CH
INT 21H
ENDS
END START
| |


