40 likes | 164 Views
Program.(08) Write a program Divide 5 by 2 and display answer value and remainder value. Store 5 into AL Store BL into 2 Divide AL Into BL Store AL into Ans Store AH into Remainder Display ANS , Remainder value . Stop program. Start. AL = 5. BL=2. ANS= AL / BL.
E N D
Program.(08) Write a program Divide 5 by 2 and display answer value and remainder value. • Store 5 into AL • Store BL into 2 • Divide AL Into BL • Store AL into Ans • Store AH into Remainder • Display ANS , Remainder value . • Stop program Start AL = 5 BL=2 ANS= AL / BL REMAINDER = AH Display ANS, Remainder End
Example Program MOV AH,2 MOV DL,ANS INT 21H MOV DL,REM INT 21H MOV AH,4CH INT 21H Main Endp End main .model small .stack 100h .data ANS db 0 REM db 0 .code Main proc MOV AX,@DATA MOV DS,AX MOV AL,5 MOV BL,2 DIV BL MOV ANS,AL MOV REM ,AH ADD ANS,30H ADD REM,30H
.model small .stack 100h .data msg1 db 0ah,0dh,"Enter Number in No1 : $" msg2 db 0ah,0dh,"Enter Number in No2 : $" res db0ah,0dh,“Divide answer is : " No1 db? symole1 db " /" No2 db ? symbole2 db "=" Ansdb? remmesdb " and Remainder is " rem db ?,"$" .code Main proc movax,@data movds,ax mov ah,9 lea dx,msg1 int 21h • movah,1 • int 21h • sub al,30h • movNo1,al • movah,9 • lea dx,msg2 • int 21h • mov ah,1 • int 21h • sub al,30h • mov No2,al • mov ax,0 • mov al,No1 • div No2 • movAns,al • movrem,ah
add Ans,30h • add No1,30h • add No2,48 • add rem,48 • movah,9 • lea dx,res • int 21h • mov ah,4ch • int 21h • main endp • end main