Wednesday, October 30, 2013

To calculate the power of a number

;Aim:- To calculate the power

.8086
.model small
.data
msg1 db 13,10, "enter the number-:$"
msg2 db 13,10, "enter the power-:$"
msg3 db 13,10, "the answer-:$"
.code
START:
MOV AX,@data
MOV DS,AX
LEA DX,msg1 ;loads the offset of MSG1 in dx
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
MOV BL,AL

LEA DX,msg2 ;loads the offset of MSG2 in dx
MOV AH,09H ;Display s string
INT 21H ;Whose offset is in dx
MOV AH,01H
INT 21H
MOV CL,AL
SUB CL,30H ;Subtract bl from ASCII 30H
SUB BL,30H
MOV AH,00H
MOV AL,01H ;Take input from keyboard


BACK:MUL BL
DEC CL
JNZ BACK
MOV BL,AL

LEA DX,msg3 ;loads the offset of MSG3 in dx
MOV AH,09H
INT 21H
MOV DL,BL
ADD DL,30H
MOV AH,02H
INT 21H
MOV AX,4C00H
INT 21H
END START

;Output
;Enter the number:3
;Enter the power:2
;the answer is-:9

1 comment:

  1. The Borgata Hotel Casino & Spa Launches The Borgata Hotel Casino
    Borgata Hotel Casino & 구미 출장마사지 Spa, 아산 출장마사지 Atlantic City's 경기도 출장샵 premiere integrated resort 광주 출장안마 destination, features 경상북도 출장샵 2,044 guest rooms and suites. Guests can enjoy the

    ReplyDelete