I have already coded half of the program. The problem is I don't know how to code math operation part is raise m
to the power of n (m^n)
. So, any advise for me as a beginner?
.MODEL SMALL
.DATA
greet db 13,10, "Welcome to Simple Calculator: Raise m to the power n. $"
msg1 db 13,10, 0AH,0DH,"Please enter integer (m:-99 to 99): $"
m db 3,4 dup(?)
msg2 db 10,13, 0AH,0DH,"Please enter power (n:1 to 9): $"
n db 3,4 dup(?)
total db 10,13, "Answer: $"
.CODE
START:
mov ax, seg greet
mov ds, ax
mov dx, offset greet
mov ah, 09h ;Display message
int 21h
mov ax, seg msg1
mov ds, ax
mov dx, offset msg1
mov ah, 09h
int 21h ;Print a message
mov ah, 0ah
mov dx, offset m
int 21h ;Get 'm' value
n_POWER:
mov ax, seg msg2
mov ds, ax
mov dx, offset msg2
mov ah, 09h
int 21h ;Print a message
mov ah, 0ah
mov dx, offset n ;Get 'n' value
int 21h
mov ax, m
mov n, ax
mul ax, n
mov total, n
finish:
mov ah, 09h ;Display message
int 21h
mov ax,4c00h ;Return control to DOS
int 21h
end start
Also, how can I get the negative input from the user (eg. -99
) ?