Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

base multiply by its power help..!!

zhinokinzhinokin Member Posts: 3
just need a little bit help here...the problem is to multipy the base to its power...

for ex. user input
base: 2
power: 3
result : 8

my problem is that it never display the answer and i think there is another problems on it
here's my code please help me with this....

[code]

START:
call clear
call clear_reg
call ask_input_base
call ask_input_power
int 20h

clear:
mov ax,03h
int 10h
ret

ask_input_base:

CALl clear

lea dx,base
mov ah,09
int 21h

mov ah, 1
int 21h
mov bl,al


mov cl,30h
sub bl,cl
sub al,cl
mov dl, al
mov ax, 0
mov al,10
mul bl
add dl, al
mov num1, dx
ret


ask_input_power:

lea dx,power
mov ah,09
int 21h

mov ah, 1
int 21h
mov bl,al


mov cl,30h
sub bl,cl
sub al,cl
mov dl, al
mov ax, 0
mov al,10
mul bl
add dl, al
mov num2, dx


do_mult:

mov ax,num1 ; move the value of num1 to ax
mov bx,num2 ; move the value of num2 to bx
mul bx

sub num2,1 ;decrement cx until it will be equal to num2
cmp num2,1 ; compare num2 if its is equal to 1

jne do_mult

call display_ans ;jump to display_ans if they are equal
ret

display_ans:

mov ah, 09h
lea dx, msg4
int 21h

;display the answer

mov ah,2
mov num3,ax
int 21h


jmp display_back


display_back:

mov dx,offset msg
mov ah, 9
int 21h
mov ah, 1
int 21h
cmp al,'y'
jne exit
jmp start



exit:
mov ah, 4ch
int 21h


clear_reg:
Xor dx,dx
Xor si,si
Xor di,di
Xor ax,ax
ret




msg db 0ah,0dh, "Try Again [y/n] : $"

base db 0ah,0dh,"Base [1 - 9]: $"
power db 0ah,0dh,"Power [1 - 9]: $"
msg4 db 0dh,0ah , "Result : $"

num1 dw ?
num2 dw ?
num3 dw ?


[/code]

Sign In or Register to comment.